DrawGlyphRun与样式模拟?

时间:2017-03-03 03:07:53

标签: uwp win2d

我正在使用Win2D开发UWP应用程序,我需要非常精细地控制文本的布局,所以我使用的是DrawGlyphRun。我没有看到任何方法让DrawGlyphRun使用模拟斜体和/或粗体,有没有办法做到这一点?

1 个答案:

答案 0 :(得分:0)

我实际上是在Win2D团队的帮助下完成了这项工作,不得不进入C ++并执行以下操作:

CanvasFontFace^ FontHelper::GetFontFaceWithSimulations(CanvasFontFace^ baseFont,
    CanvasFontSimulations simulations)
{
    ComPtr<IDWriteFontFaceReference> nativeSrc = GetWrappedResource<IDWriteFontFaceReference>(baseFont);

    DWRITE_FONT_SIMULATIONS flags = (DWRITE_FONT_SIMULATIONS)simulations;

    ComPtr<IDWriteFontFace3> withSimulations;
    nativeSrc->CreateFontFaceWithSimulations(flags, &withSimulations);

    ComPtr<IDWriteFontFaceReference> nativeResult;
    withSimulations->GetFontFaceReference(&nativeResult);

    CanvasFontFace^ win2dResult = GetOrCreate<CanvasFontFace>(nativeResult.Get());
    return win2dResult;
}