diff options
-rw-r--r-- | vcl/inc/font/PhysicalFontFace.hxx | 2 | ||||
-rw-r--r-- | vcl/source/font/LogicalFontInstance.cxx | 12 | ||||
-rw-r--r-- | vcl/source/font/fontmetric.cxx | 5 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 4 |
4 files changed, 11 insertions, 12 deletions
diff --git a/vcl/inc/font/PhysicalFontFace.hxx b/vcl/inc/font/PhysicalFontFace.hxx index 75133503e8af..303976c59776 100644 --- a/vcl/inc/font/PhysicalFontFace.hxx +++ b/vcl/inc/font/PhysicalFontFace.hxx @@ -138,6 +138,8 @@ public: const ColorPalette& GetColorPalette(size_t) const; std::vector<ColorLayer> GetGlyphColorLayers(sal_GlyphId) const; + uint32_t UnitsPerEm() const { return hb_face_get_upem(GetHbFace()); } + virtual hb_face_t* GetHbFace() const; virtual hb_blob_t* GetHbTable(hb_tag_t) const { diff --git a/vcl/source/font/LogicalFontInstance.cxx b/vcl/source/font/LogicalFontInstance.cxx index ce6ea99ee8f3..b882ce93dfe4 100644 --- a/vcl/source/font/LogicalFontInstance.cxx +++ b/vcl/source/font/LogicalFontInstance.cxx @@ -54,10 +54,11 @@ LogicalFontInstance::~LogicalFontInstance() hb_font_t* LogicalFontInstance::InitHbFont() { - hb_face_t* pHbFace = GetFontFace()->GetHbFace(); + auto pFace = GetFontFace(); + hb_face_t* pHbFace = pFace->GetHbFace(); assert(pHbFace); hb_font_t* pHbFont = hb_font_create(pHbFace); - unsigned int nUPEM = hb_face_get_upem(pHbFace); + auto nUPEM = pFace->UnitsPerEm(); hb_font_set_scale(pHbFont, nUPEM, nUPEM); hb_ot_font_set_funcs(pHbFont); ImplInitHbFont(pHbFont); @@ -74,9 +75,7 @@ int LogicalFontInstance::GetKashidaWidth() const void LogicalFontInstance::GetScale(double* nXScale, double* nYScale) const { - hb_face_t* pHbFace = hb_font_get_face(const_cast<LogicalFontInstance*>(this)->GetHbFont()); - unsigned int nUPEM = hb_face_get_upem(pHbFace); - + double nUPEM = GetFontFace()->UnitsPerEm(); double nHeight(m_aFontSelData.mnHeight); // On Windows, mnWidth is relative to average char width not font height, @@ -162,8 +161,7 @@ double LogicalFontInstance::GetGlyphWidth(sal_GlyphId nGlyph, bool bVertical, bo if (bPDF) { - unsigned int nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont)); - return (nWidth * 1000) / nUPEM; + return (nWidth * 1000) / GetFontFace()->UnitsPerEm(); } else { diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index 2d918d4dca68..f03edd201982 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -380,7 +380,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(LogicalFontInstance *pFontInstance) vcl::TTGlobalFontInfo rInfo = {}; GetTTFontMetrics(aHhea.data(), aHhea.size(), aOS_2.data(), aOS_2.size(), &rInfo); - double nUPEM = hb_face_get_upem(pFace->GetHbFace()); + double nUPEM = pFace->UnitsPerEm(); double fScale = mnHeight / nUPEM; double fAscent = 0, fDescent = 0, fExtLeading = 0; @@ -438,8 +438,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(LogicalFontInstance *pFontInstance) void ImplFontMetricData::ImplInitBaselines(LogicalFontInstance *pFontInstance) { hb_font_t* pHbFont = pFontInstance->GetHbFont(); - hb_face_t* pHbFace = hb_font_get_face(pHbFont); - double nUPEM = hb_face_get_upem(pHbFace); + double nUPEM = pFontInstance->GetFontFace()->UnitsPerEm(); double fScale = mnHeight / nUPEM; hb_position_t nBaseline = 0; diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 748e5502ee73..8d6126c2fcfd 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -165,13 +165,13 @@ float WinFontInstance::getHScale() const return nWidth / nHeight; } -void WinFontInstance::ImplInitHbFont(hb_font_t* pHbFont) +void WinFontInstance::ImplInitHbFont(hb_font_t* /*pHbFont*/) { assert(m_pGraphics); // Calculate the AverageWidthFactor, see LogicalFontInstance::GetScale(). if (GetFontSelectPattern().mnWidth) { - double nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont)); + double nUPEM = GetFontFace()->UnitsPerEm(); LOGFONTW aLogFont; GetObjectW(m_hFont, sizeof(LOGFONTW), &aLogFont); |