void getFontFamilyAndStyle (DWRITE_GLYPH_RUN const* glyphRun, String& family, String& style) const { ComSmartPtr<IDWriteFont> dwFont; HRESULT hr = fontCollection->GetFontFromFontFace (glyphRun->fontFace, dwFont.resetAndGetPointerAddress()); jassert (dwFont != nullptr); { ComSmartPtr<IDWriteFontFamily> dwFontFamily; hr = dwFont->GetFontFamily (dwFontFamily.resetAndGetPointerAddress()); family = getFontFamilyName (dwFontFamily); } style = getFontFaceName (dwFont); }
Font getFontForRun (const DWRITE_GLYPH_RUN& glyphRun, float fontHeight) { for (int i = 0; i < attributedString.getNumAttributes(); ++i) if (const Font* font = attributedString.getAttribute(i)->getFont()) if (WindowsDirectWriteTypeface* wt = dynamic_cast<WindowsDirectWriteTypeface*> (font->getTypeface())) if (wt->getIDWriteFontFace() == glyphRun.fontFace) return font->withHeight (fontHeight); ComSmartPtr<IDWriteFont> dwFont; HRESULT hr = fontCollection.GetFontFromFontFace (glyphRun.fontFace, dwFont.resetAndGetPointerAddress()); jassert (dwFont != nullptr); ComSmartPtr<IDWriteFontFamily> dwFontFamily; hr = dwFont->GetFontFamily (dwFontFamily.resetAndGetPointerAddress()); return Font (getFontFamilyName (dwFontFamily), getFontFaceName (dwFont), fontHeight); }