本文整理汇总了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);
}
示例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);
}