本文整理汇总了C++中IDWriteTextFormat::SetTrimming方法的典型用法代码示例。如果您正苦于以下问题:C++ IDWriteTextFormat::SetTrimming方法的具体用法?C++ IDWriteTextFormat::SetTrimming怎么用?C++ IDWriteTextFormat::SetTrimming使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDWriteTextFormat
的用法示例。
在下文中一共展示了IDWriteTextFormat::SetTrimming方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawText
bool CDirectWriteRenderer::DrawText(
LPCWSTR pText, int Length, const RECT &Rect,
CDirectWriteFont &Font, CDirectWriteBrush &Brush, unsigned int Flags)
{
if (pText == nullptr)
return false;
if (m_pRenderTarget == nullptr)
return false;
bool fOK = false;
IDWriteTextFormat *pTextFormat = Font.GetTextFormat();
if (pTextFormat != nullptr) {
ID2D1Brush *pBrush = Brush.GetBrush();
if (pBrush != nullptr) {
pTextFormat->SetTextAlignment(
(Flags & DRAW_TEXT_ALIGN_HORZ_CENTER) != 0 ?
DWRITE_TEXT_ALIGNMENT_CENTER :
(Flags & DRAW_TEXT_ALIGN_RIGHT) != 0 ?
DWRITE_TEXT_ALIGNMENT_TRAILING :
((Flags & DRAW_TEXT_ALIGN_JUSTIFIED) != 0
&& Util::OS::IsWindows8OrLater()) ?
DWRITE_TEXT_ALIGNMENT_JUSTIFIED :
DWRITE_TEXT_ALIGNMENT_LEADING);
pTextFormat->SetParagraphAlignment(
(Flags & DRAW_TEXT_ALIGN_VERT_CENTER) != 0 ?
DWRITE_PARAGRAPH_ALIGNMENT_CENTER :
(Flags & DRAW_TEXT_ALIGN_BOTTOM) != 0 ?
DWRITE_PARAGRAPH_ALIGNMENT_FAR :
DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
pTextFormat->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
DWRITE_TRIMMING Trimming = {DWRITE_TRIMMING_GRANULARITY_NONE, 0, 0};
pTextFormat->SetTrimming(&Trimming, nullptr);
m_pRenderTarget->DrawText(
pText,
Length >= 0 ? Length : ::lstrlenW(pText),
pTextFormat,
D2DRectF(Rect),
pBrush);
fOK = true;
pBrush->Release();
}
pTextFormat->Release();
}
return fOK;
}