当前位置: 首页>>代码示例>>C++>>正文


C++ IDWriteFactory类代码示例

本文整理汇总了C++中IDWriteFactory的典型用法代码示例。如果您正苦于以下问题:C++ IDWriteFactory类的具体用法?C++ IDWriteFactory怎么用?C++ IDWriteFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IDWriteFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: p

D3D11CanvasWindowGraphicsPtr D3D11CanvasWindowGraphics::Create(
	HWND hWnd, D3D11DriverPtr driver, CameraPtr camera)
{
	D3D11CanvasWindowGraphicsPtr p(new D3D11CanvasWindowGraphics);

	p->m_hWnd = hWnd;
	p->m_driver = driver;
	p->m_camera = camera;

	ID3D11Device* pDevice = p->m_driver->GetD3D11Device();
	IDXGIFactory1* pDXGIFactory = p->m_driver->GetDXGIFactory();
	IDWriteFactory* pDWriteFactory = p->m_driver->GetDWriteFactory();

	// Create text format

	CHECK_HR(pDWriteFactory->CreateTextFormat(
		L"Calibri", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,
		DWRITE_FONT_STRETCH_NORMAL, 24.0f, L"en-US", p->m_textFormat.Receive()));

	// Create swap chain

	DXGI_SWAP_CHAIN_DESC scd = { 0 };
	scd.BufferDesc.Format = BACKBUFFER_FORMAT;
	scd.SampleDesc.Count = 1;
	scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	scd.BufferCount = 1;
	scd.OutputWindow = hWnd;
	scd.Windowed = TRUE;
	CHECK_HR(pDXGIFactory->CreateSwapChain(pDevice, &scd, p->m_swapChain.Receive()));

	p->CreateSwapChainResources();

	return p;
}
开发者ID:AdamosX,项目名称:noser-sandbox,代码行数:34,代码来源:D3D11CanvasWindowGraphics.cpp

示例2: defined

void DWriteFontTypeface::onFilterRec(SkScalerContext::Rec* rec) const {
    if (rec->fFlags & SkScalerContext::kLCD_Vertical_Flag) {
        rec->fMaskFormat = SkMask::kA8_Format;
    }

    unsigned flagsWeDontSupport = SkScalerContext::kVertical_Flag |
                                  SkScalerContext::kDevKernText_Flag |
                                  SkScalerContext::kForceAutohinting_Flag |
                                  SkScalerContext::kEmbolden_Flag |
                                  SkScalerContext::kLCD_Vertical_Flag;
    rec->fFlags &= ~flagsWeDontSupport;

    SkPaint::Hinting h = rec->getHinting();
    // DirectWrite does not provide for hinting hints.
    h = SkPaint::kSlight_Hinting;
    rec->setHinting(h);

#if defined(SK_FONT_HOST_USE_SYSTEM_SETTINGS)
    IDWriteFactory* factory = sk_get_dwrite_factory();
    if (factory != nullptr) {
        SkTScopedComPtr<IDWriteRenderingParams> defaultRenderingParams;
        if (SUCCEEDED(factory->CreateRenderingParams(&defaultRenderingParams))) {
            float gamma = defaultRenderingParams->GetGamma();
            rec->setDeviceGamma(gamma);
            rec->setPaintGamma(gamma);

            rec->setContrast(defaultRenderingParams->GetEnhancedContrast());
        }
    }
#endif
}
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:31,代码来源:SkTypeface_win_dw.cpp

示例3: GetFitCharCount

int CDirectWriteRenderer::GetFitCharCount(LPCWSTR pText, int Length, int Width, CDirectWriteFont &Font)
{
	if (pText == nullptr || Length == 0)
		return 0;
	if (m_pRenderTarget == nullptr)
		return 0;

	int FitCharCount = 0;

	IDWriteFactory *pFactory = m_System.GetDWriteFactory();

	if (pFactory != nullptr) {
		IDWriteTextFormat *pTextFormat = Font.GetTextFormat();

		if (pTextFormat != nullptr) {
			IDWriteTextLayout *pTextLayout;

			pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
			pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
			if (Length < 0)
				Length = ::lstrlenW(pText);
			HRESULT hr = pFactory->CreateTextLayout(
				pText,
				Length,
				pTextFormat,
				static_cast<float>(Width),
				m_pRenderTarget->GetSize().height,
				&pTextLayout);
			if (SUCCEEDED(hr)) {
				Util::CTempBuffer<DWRITE_CLUSTER_METRICS, 256> ClusterMetrics(Length);
				UINT32 ClusterCount;

				hr = pTextLayout->GetClusterMetrics(ClusterMetrics.GetBuffer(), Length, &ClusterCount);
				if (SUCCEEDED(hr)) {
					float Pos = 0.0f;

					for (UINT32 i = 0; i < ClusterCount; i++) {
						Pos += ClusterMetrics[i].width;
						if (static_cast<int>(std::ceil(Pos)) > Width)
							break;
						FitCharCount += ClusterMetrics[i].length;
					}
				}

				pTextLayout->Release();
			}

			pTextFormat->Release();
		}

		pFactory->Release();
	}

	return FitCharCount;
}
开发者ID:DBCTRADO,项目名称:TVTest,代码行数:55,代码来源:DirectWrite.cpp

示例4: setupLayout

    bool setupLayout (const AttributedString& text, const float maxWidth, const float maxHeight,
                      ID2D1RenderTarget& renderTarget, IDWriteFactory& directWriteFactory,
                      IDWriteFontCollection& fontCollection, ComSmartPtr<IDWriteTextLayout>& textLayout)
    {
        // To add color to text, we need to create a D2D render target
        // Since we are not actually rendering to a D2D context we create a temporary GDI render target

        Font defaultFont;
        BOOL fontFound = false;
        uint32 fontIndex;
        fontCollection.FindFamilyName (defaultFont.getTypeface()->getName().toWideCharPointer(), &fontIndex, &fontFound);

        if (! fontFound)
            fontIndex = 0;

        ComSmartPtr<IDWriteFontFamily> dwFontFamily;
        HRESULT hr = fontCollection.GetFontFamily (fontIndex, dwFontFamily.resetAndGetPointerAddress());

        ComSmartPtr<IDWriteFont> dwFont;
        hr = dwFontFamily->GetFirstMatchingFont (DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STYLE_NORMAL,
                                                 dwFont.resetAndGetPointerAddress());
        jassert (dwFont != nullptr);

        const float defaultFontHeightToEmSizeFactor = getFontHeightToEmSizeFactor (*dwFont);

        ComSmartPtr<IDWriteTextFormat> dwTextFormat;
        hr = directWriteFactory.CreateTextFormat (defaultFont.getTypefaceName().toWideCharPointer(), &fontCollection,
                                                  DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
                                                  defaultFont.getHeight() * defaultFontHeightToEmSizeFactor,
                                                  L"en-us", dwTextFormat.resetAndGetPointerAddress());

        setTextFormatProperties (text, *dwTextFormat);

        {
            DWRITE_TRIMMING trimming = { DWRITE_TRIMMING_GRANULARITY_CHARACTER, 0, 0 };
            ComSmartPtr<IDWriteInlineObject> trimmingSign;
            hr = directWriteFactory.CreateEllipsisTrimmingSign (dwTextFormat, trimmingSign.resetAndGetPointerAddress());
            hr = dwTextFormat->SetTrimming (&trimming, trimmingSign);
        }

        const int textLen = text.getText().length();

        hr = directWriteFactory.CreateTextLayout (text.getText().toWideCharPointer(), textLen, dwTextFormat,
                                                  maxWidth, maxHeight, textLayout.resetAndGetPointerAddress());

        if (FAILED (hr) || textLayout == nullptr)
            return false;

        const int numAttributes = text.getNumAttributes();

        for (int i = 0; i < numAttributes; ++i)
            addAttributedRange (*text.getAttribute (i), *textLayout, textLen, renderTarget, fontCollection);

        return true;
    }
开发者ID:Flowersoft,项目名称:MIDI2LR,代码行数:55,代码来源:juce_win32_DirectWriteTypeLayout.cpp

示例5: delegate_dwritefactory

    delegate_dwritefactory(IDWriteFactory *inst) : refnum(0), orig_this(inst), mycoll(nullptr)
    {
        OutputDebugString("delegate_dwritefactory::delegate_dwritefactory");
	InitializeCriticalSection(&collcs);
        fontfile_collection_loader &loader = fontfile_collection_loader::get_instance();
        if (SUCCEEDED(orig_this->RegisterFontCollectionLoader(&loader))) {
            EnterCriticalSection(&fontpathscs);
            orig_this->CreateCustomFontCollection(&loader, nullptr, 0, &mycoll);
            LeaveCriticalSection(&fontpathscs);
        }
	factories.insert(this);
    }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:12,代码来源:dynfont.cpp

示例6: GetTextMetrics

bool CDirectWriteRenderer::GetTextMetrics(
	LPCWSTR pText, int Length, CDirectWriteFont &Font, TextMetrics *pMetrics)
{
	if (pText == nullptr || pMetrics == nullptr)
		return false;
	if (m_pRenderTarget == nullptr)
		return false;

	HRESULT hr = E_UNEXPECTED;
	IDWriteFactory *pFactory = m_System.GetDWriteFactory();

	if (pFactory != nullptr) {
		IDWriteTextFormat *pTextFormat = Font.GetTextFormat();

		if (pTextFormat != nullptr) {
			D2D1_SIZE_F Size;
			IDWriteTextLayout *pTextLayout;

			pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
			pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
			if (Length < 0)
				Length = ::lstrlenW(pText);
			Size = m_pRenderTarget->GetSize();
			hr = pFactory->CreateTextLayout(
				pText,
				Length,
				pTextFormat,
				Size.width,
				Size.height,
				&pTextLayout);
			if (SUCCEEDED(hr)) {
				DWRITE_TEXT_METRICS Metrics;

				hr = pTextLayout->GetMetrics(&Metrics);
				if (SUCCEEDED(hr)) {
					pMetrics->Width = Metrics.width;
					pMetrics->WidthIncludingTrailingWhitespace = Metrics.widthIncludingTrailingWhitespace;
					pMetrics->Height = Metrics.height;
				}

				pTextLayout->Release();
			}

			pTextFormat->Release();
		}

		pFactory->Release();
	}

	return SUCCEEDED(hr);
}
开发者ID:DBCTRADO,项目名称:TVTest,代码行数:51,代码来源:DirectWrite.cpp

示例7: DwCreateRenderingTarget

FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap, void** renderTarget)
{
    if (pBitmap->GetFormat() > FXDIB_Argb) {
        return FALSE;
    }
    IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory;
    IDWriteGdiInterop* pGdiInterop = NULL;
    IDWriteBitmapRenderTarget* pBitmapRenderTarget = NULL;
    IDWriteRenderingParams* pRenderingParams = NULL;
    HRESULT hr = S_OK;
    hr = pDwFactory->GetGdiInterop(&pGdiInterop);
    if (FAILED(hr)) {
        goto failed;
    }
    hr = pGdiInterop->CreateBitmapRenderTarget(NULL, pBitmap->GetWidth(), pBitmap->GetHeight(),
            &pBitmapRenderTarget);
    if (FAILED(hr)) {
        goto failed;
    }
    hr = pDwFactory->CreateCustomRenderingParams(
             1.0f,
             0.0f,
             1.0f,
             DWRITE_PIXEL_GEOMETRY_RGB,
             DWRITE_RENDERING_MODE_DEFAULT,
             &pRenderingParams
         );
    if (FAILED(hr)) {
        goto failed;
    }
    hr = pBitmapRenderTarget->SetPixelsPerDip(1.0f);
    if (FAILED(hr)) {
        goto failed;
    }
    *(CDwGdiTextRenderer**)renderTarget = FX_NEW CDwGdiTextRenderer(pBitmap, pBitmapRenderTarget, pRenderingParams);
    if (*(CDwGdiTextRenderer**)renderTarget == NULL) {
        goto failed;
    }
    SafeRelease(&pGdiInterop);
    SafeRelease(&pBitmapRenderTarget);
    SafeRelease(&pRenderingParams);
    return TRUE;
failed:
    SafeRelease(&pGdiInterop);
    SafeRelease(&pBitmapRenderTarget);
    SafeRelease(&pRenderingParams);
    return FALSE;
}
开发者ID:codemonkey85,项目名称:pdfium,代码行数:48,代码来源:fx_win32_dwrite.cpp

示例8: UpdateRenderingParams

bool CDirectWriteRenderer::UpdateRenderingParams()
{
	if (m_pRenderTarget == nullptr)
		return false;

	bool fUpdated = false;
	IDWriteFactory *pFactory = m_System.GetDWriteFactory();

	if (pFactory != nullptr) {
		IDWriteRenderingParams *pRenderingParams;

		HRESULT hr = pFactory->CreateMonitorRenderingParams(m_hMonitor, &pRenderingParams);
		if (SUCCEEDED(hr)) {
			if (m_RenderingParams.Mask != 0) {
				IDWriteRenderingParams *pCustomRenderingParams;
				hr = pFactory->CreateCustomRenderingParams(
					(m_RenderingParams.Mask & RenderingParams::PARAM_GAMMA) != 0 ?
						m_RenderingParams.Gamma : pRenderingParams->GetGamma(),
					(m_RenderingParams.Mask & RenderingParams::PARAM_ENHANCED_CONTRAST) != 0 ?
						m_RenderingParams.EnhancedContrast : pRenderingParams->GetEnhancedContrast(),
					(m_RenderingParams.Mask & RenderingParams::PARAM_CLEARTYPE_LEVEL) != 0 ?
						m_RenderingParams.ClearTypeLevel : pRenderingParams->GetClearTypeLevel(),
					(m_RenderingParams.Mask & RenderingParams::PARAM_PIXEL_GEOMETRY) != 0 ?
						m_RenderingParams.PixelGeometry : pRenderingParams->GetPixelGeometry(),
					(m_RenderingParams.Mask & RenderingParams::PARAM_RENDERING_MODE) != 0 ?
						m_RenderingParams.RenderingMode : pRenderingParams->GetRenderingMode(),
					&pCustomRenderingParams);
				if (SUCCEEDED(hr)) {
					m_pRenderTarget->SetTextRenderingParams(pCustomRenderingParams);
					pCustomRenderingParams->Release();
				}
			} else {
				m_pRenderTarget->SetTextRenderingParams(pRenderingParams);
			}

			if (SUCCEEDED(hr))
				fUpdated = true;

			pRenderingParams->Release();
		}

		pFactory->Release();
	}

	return fUpdated;
}
开发者ID:DBCTRADO,项目名称:TVTest,代码行数:46,代码来源:DirectWrite.cpp

示例9: SafeRelease

LPVOID	CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData, FX_DWORD size, int simulation_style)
{
    IDWriteFactory* pDwFactory = (IDWriteFactory*)m_pDWriteFactory;
    IDWriteFontFile* pDwFontFile = NULL;
    IDWriteFontFace* pDwFontFace = NULL;
    BOOL isSupportedFontType = FALSE;
    DWRITE_FONT_FILE_TYPE fontFileType;
    DWRITE_FONT_FACE_TYPE fontFaceType;
    UINT32 numberOfFaces;
    DWRITE_FONT_SIMULATIONS fontStyle = (DWRITE_FONT_SIMULATIONS)(simulation_style & 3);
    HRESULT hr = S_OK;
    hr = pDwFactory->CreateCustomFontFileReference(
             (void const*)pData,
             (UINT32)size,
             CDwFontFileLoader::GetLoader(),
             &pDwFontFile
         );
    if (FAILED(hr)) {
        goto failed;
    }
    hr = pDwFontFile->Analyze(
             &isSupportedFontType,
             &fontFileType,
             &fontFaceType,
             &numberOfFaces
         );
    if (FAILED(hr) || !isSupportedFontType || fontFaceType == DWRITE_FONT_FACE_TYPE_UNKNOWN) {
        goto failed;
    }
    hr = pDwFactory->CreateFontFace(
             fontFaceType,
             1,
             &pDwFontFile,
             0,
             fontStyle,
             &pDwFontFace
         );
    if (FAILED(hr)) {
        goto failed;
    }
    SafeRelease(&pDwFontFile);
    return pDwFontFace;
failed:
    SafeRelease(&pDwFontFile);
    return NULL;
}
开发者ID:abbro-ca,项目名称:pdfium,代码行数:46,代码来源:fx_win32_dwrite.cpp

示例10: CreateTextFormat

    virtual HRESULT STDMETHODCALLTYPE CreateTextFormat(
        WCHAR const* fontFamilyName,
        IDWriteFontCollection* fontCollection,
        DWRITE_FONT_WEIGHT fontWeight,
        DWRITE_FONT_STYLE fontStyle,
        DWRITE_FONT_STRETCH fontStretch,
        FLOAT fontSize,
        WCHAR const* localeName,
        IDWriteTextFormat** textFormat
        )
    {
        UINT32 index;
        BOOL exists;
        HRESULT result;
        OutputDebugString("delegate_dwritefactory::CreateTextFormat");
        OutputDebugStringW(fontFamilyName);
        EnterCriticalSection(&collcs);
        result = this->mycoll->FindFamilyName(fontFamilyName, &index, &exists);
        if (SUCCEEDED(result)) {
            result = E_FAIL;
            if (exists != FALSE) {
                OutputDebugString("delegate_dwritefactory::CreateTextFormat -> mycoll");
                result = orig_this->CreateTextFormat(fontFamilyName, this->mycoll, fontWeight, fontStyle, fontStretch, fontSize, localeName, textFormat);
            }
        }
        LeaveCriticalSection(&collcs);
	if (FAILED(result)) {
            OutputDebugString("delegate_dwritefactory::CreateTextFormat -> fallback");
            result = orig_this->CreateTextFormat(fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, localeName, textFormat);
        }
        return result;
    }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:32,代码来源:dynfont.cpp

示例11: ToTextAntialiasMode

    void
DWriteContext::SetRenderingParams(
	const DWriteRenderingParams *params)
{
    if (mDWriteFactory == NULL)
	return;

    IDWriteRenderingParams *renderingParams = NULL;
    D2D1_TEXT_ANTIALIAS_MODE textAntialiasMode =
	D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
    HRESULT hr;
    if (params != NULL)
    {
	hr = mDWriteFactory->CreateCustomRenderingParams(params->gamma,
		params->enhancedContrast, params->clearTypeLevel,
		ToPixelGeometry(params->pixelGeometry),
		ToRenderingMode(params->renderingMode), &renderingParams);
	textAntialiasMode = ToTextAntialiasMode(params->textAntialiasMode);
    }
    else
	hr = mDWriteFactory->CreateRenderingParams(&renderingParams);
    if (SUCCEEDED(hr) && renderingParams != NULL)
    {
	SafeRelease(&mRenderingParams);
	mRenderingParams = renderingParams;
	mTextAntialiasMode = textAntialiasMode;
    }
}
开发者ID:Qubit0-1,项目名称:vim,代码行数:28,代码来源:gui_dwrite.cpp

示例12: Initialize

HRESULT CDwFontContext::Initialize()
{
    if (hr_ == S_FALSE) {
        return hr_ = dwriteFactory_->RegisterFontFileLoader(CDwFontFileLoader::GetLoader());
    }
    return hr_;
}
开发者ID:abbro-ca,项目名称:pdfium,代码行数:7,代码来源:fx_win32_dwrite.cpp

示例13: CreateEllipsisTrimmingSign

 virtual HRESULT STDMETHODCALLTYPE CreateEllipsisTrimmingSign(
     IDWriteTextFormat* textFormat,
     IDWriteInlineObject** trimmingSign
     )
 {
     return orig_this->CreateEllipsisTrimmingSign(textFormat, trimmingSign);
 }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:7,代码来源:dynfont.cpp

示例14: GetSystemFontCollection

 virtual HRESULT STDMETHODCALLTYPE GetSystemFontCollection(
     IDWriteFontCollection** fontCollection,
     BOOL checkForUpdates = FALSE
     )
 {
     return orig_this->GetSystemFontCollection(fontCollection, checkForUpdates);
 }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:7,代码来源:dynfont.cpp

示例15: CreateMonitorRenderingParams

 virtual HRESULT STDMETHODCALLTYPE CreateMonitorRenderingParams(
     HMONITOR monitor,
     IDWriteRenderingParams** renderingParams
     )
 {
     return orig_this->CreateMonitorRenderingParams(monitor, renderingParams);
 }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:7,代码来源:dynfont.cpp


注:本文中的IDWriteFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。