2017-03-03 71 views
1

我正在使用Win2D的UWP應用程序,我需要非常好的控制文本的佈局,所以我使用DrawGlyphRun。我沒有看到任何使DrawGlyphRun使用模擬斜體和/或粗體的方法,有沒有什麼辦法可以做到這一點?帶風格模擬的DrawGlyphRun?

+0

你能分享你現在做了什麼一些代碼? – Scavenger

回答

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; 
}