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


C++ IDWriteFactory::CreateGdiCompatibleTextLayout方法代码示例

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


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

示例1: PixelsToDipsX

    void
DWriteContext::DrawText(HDC hdc, const WCHAR* text, int len,
	int x, int y, int w, int h, int cellWidth, COLORREF color)
{
    HRESULT hr = S_OK;
    IDWriteBitmapRenderTarget *bmpRT = NULL;

    // Skip when any fonts are not set.
    if (mTextFormat == NULL)
	return;

    // Check possibility of zero divided error.
    if (cellWidth == 0 || mDpiScaleX == 0.0f || mDpiScaleY == 0.0f)
	return;

    if (SUCCEEDED(hr))
	hr = mGdiInterop->CreateBitmapRenderTarget(hdc, w, h, &bmpRT);

    if (SUCCEEDED(hr))
    {
	IDWriteTextLayout *textLayout = NULL;

	HDC memdc = bmpRT->GetMemoryDC();
	BitBlt(memdc, 0, 0, w, h, hdc, x, y, SRCCOPY);

	hr = mDWriteFactory->CreateGdiCompatibleTextLayout(
		text, len, mTextFormat, PixelsToDipsX(w),
		PixelsToDipsY(h), mDpiScaleX, NULL, TRUE, &textLayout);

	if (SUCCEEDED(hr))
	{
	    DWRITE_TEXT_RANGE textRange = { 0, (UINT32)len };
	    textLayout->SetFontWeight(mFontWeight, textRange);
	    textLayout->SetFontStyle(mFontStyle, textRange);
	}

	if (SUCCEEDED(hr))
	{
	    GdiTextRenderer *renderer = new GdiTextRenderer(bmpRT,
		    mRenderingParams);
	    GdiTextRendererContext data = {
		color,
		PixelsToDipsX(cellWidth),
		0.0f
	    };
	    textLayout->Draw(&data, renderer, 0, 0);
	    SafeRelease(&renderer);
	}

	BitBlt(hdc, x, y, w, h, memdc, 0, 0, SRCCOPY);

	SafeRelease(&textLayout);
    }

    SafeRelease(&bmpRT);
}
开发者ID:Qubit0-1,项目名称:vim,代码行数:56,代码来源:gui_dwrite.cpp

示例2: CreateGdiCompatibleTextLayout

 virtual HRESULT STDMETHODCALLTYPE CreateGdiCompatibleTextLayout(
     WCHAR const* string,
     UINT32 stringLength,
     IDWriteTextFormat* textFormat,
     FLOAT layoutWidth,
     FLOAT layoutHeight,
     FLOAT pixelsPerDip,
     DWRITE_MATRIX const* transform,
     BOOL useGdiNatural,
     IDWriteTextLayout** textLayout
     )
 {
     return orig_this->CreateGdiCompatibleTextLayout(string, stringLength, textFormat, layoutWidth, layoutHeight, pixelsPerDip, transform, useGdiNatural, textLayout);
 }
开发者ID:s-yukikaze,项目名称:dynfont,代码行数:14,代码来源:dynfont.cpp


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