diff options
-rw-r--r-- | vcl/inc/fontinstance.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/qt5/Qt5Graphics_Text.cxx | 8 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 15 | ||||
-rw-r--r-- | vcl/source/font/fontinstance.cxx | 16 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 11 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 10 |
8 files changed, 25 insertions, 45 deletions
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index 8bd6584c6154..90ed83d3ab33 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -67,6 +67,8 @@ public: // TODO: make data members private const PhysicalFontFace* GetFontFace() const { return m_pFontFace; } const ImplFontCache* GetFontCache() const { return mpFontCache; } + int GetKashidaWidth(); + void GetScale(double* nXScale, double* nYScale); static inline void DecodeOpenTypeTag(const uint32_t nTableTag, char* pTagName); diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 1d6969d906a0..064b2125e8be 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -90,7 +90,7 @@ class CoreTextStyle : public LogicalFontInstance public: ~CoreTextStyle(); - void GetFontMetric( ImplFontMetricDataRef const & ) const; + void GetFontMetric( ImplFontMetricDataRef const & ); bool GetGlyphBoundRect(const GlyphItem&, tools::Rectangle&) const; bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) const; diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index 2af33b0d97a5..f3c38647c3a8 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -67,13 +67,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel) rFMD->SetWidth(aRawFont.averageCharWidth()); - const QChar nKashidaCh[2] = { 0x06, 0x40 }; - quint32 nKashidaGid = 0; - QPointF aPoint; - int nNumGlyphs; - if (aRawFont.glyphIndexesForChars(nKashidaCh, 1, &nKashidaGid, &nNumGlyphs) - && aRawFont.advancesForGlyphIndexes(&nKashidaGid, &aPoint, 1)) - rFMD->SetMinKashida(lrint(aPoint.rx())); + rFMD->SetMinKashida(m_pTextStyle[nFallbackLevel]->GetKashidaWidth()); } const FontCharMapRef Qt5Graphics::GetFontCharMap() const diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index be615a1ee377..ac20c1e9f4c5 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -104,7 +104,7 @@ CoreTextStyle::~CoreTextStyle() CFRelease( mpStyleDict ); } -void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric ) const +void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric ) { // get the matching CoreText font handle // TODO: is it worth it to cache the CTFontRef in SetFont() and reuse it here? @@ -133,18 +133,7 @@ void CoreTextStyle::GetFontMetric( ImplFontMetricDataRef const & rxFontMetric ) // it also makes the calculation of the stretch factor simple rxFontMetric->SetWidth( lrint( CTFontGetSize( aCTFontRef ) * mfFontStretch) ); - UniChar nKashidaCh = 0x0640; - CGGlyph nKashidaGid = 0; - if (CTFontGetGlyphsForCharacters(aCTFontRef, &nKashidaCh, &nKashidaGid, 1)) - { -SAL_WNODEPRECATED_DECLARATIONS_PUSH - // 'kCTFontHorizontalOrientation' is deprecated: first deprecated in - // macOS 10.11 - double nKashidaAdv = CTFontGetAdvancesForGlyphs(aCTFontRef, - kCTFontHorizontalOrientation, &nKashidaGid, nullptr, 1); -SAL_WNODEPRECATED_DECLARATIONS_POP - rxFontMetric->SetMinKashida(lrint(nKashidaAdv)); - } + rxFontMetric->SetMinKashida(GetKashidaWidth()); } bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect ) const diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx index 845eb2e9e635..6837329fbfaf 100644 --- a/vcl/source/font/fontinstance.cxx +++ b/vcl/source/font/fontinstance.cxx @@ -79,6 +79,22 @@ hb_font_t* LogicalFontInstance::InitHbFont(hb_face_t* pHbFace) const return pHbFont; } +int LogicalFontInstance::GetKashidaWidth() +{ + hb_font_t* pHbFont = GetHbFont(); + hb_position_t nWidth = 0; + hb_codepoint_t nIndex = 0; + + if (hb_font_get_glyph(pHbFont, 0x0640, 0, &nIndex)) + { + double nXScale = 0; + GetScale(&nXScale, nullptr); + nWidth = hb_font_get_glyph_h_advance(pHbFont, nIndex) * nXScale; + } + + return nWidth; +} + void LogicalFontInstance::GetScale(double* nXScale, double* nYScale) { hb_face_t* pHbFace = hb_font_get_face(GetHbFont()); diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 33a3a0c83ed3..aac35c3b3f7b 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -643,11 +643,7 @@ void GenericSalLayout::ApplyDXArray(ImplLayoutArgs& rArgs) hb_font_t *pHbFont = mpFont->GetHbFont(); // Find Kashida glyph width and index. if (hb_font_get_glyph(pHbFont, 0x0640, 0, &nKashidaIndex)) - { - double nXScale = 0; - mpFont->GetScale(&nXScale, nullptr); - nKashidaWidth = hb_font_get_glyph_h_advance(pHbFont, nKashidaIndex) * nXScale; - } + nKashidaWidth = mpFont->GetKashidaWidth(); bKashidaJustify = nKashidaWidth != 0; } diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 6476950e5fe5..9bc310b67afd 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -549,16 +549,7 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const } // initialize kashida width - const int nKashidaGlyphId = FT_Get_Char_Index(maFaceFT, 0x0640); - if( nKashidaGlyphId ) - { - if (FT_Load_Glyph(maFaceFT, nKashidaGlyphId, mnLoadFlags) == FT_Err_Ok) - { - int nWidth = (maFaceFT->glyph->metrics.horiAdvance + 32) >> 6; - rxTo->SetMinKashida(nWidth); - } - } - + rxTo->SetMinKashida(mpFontInstance->GetKashidaWidth()); } void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 62d9f7d85dd7..e1c26ed902a2 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -997,15 +997,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa const RawFontData aHheaRawData(getHDC(), nHheaTag); const RawFontData aOS2RawData(getHDC(), nOS2Tag); - WCHAR nKashidaCh = 0x0640; - WORD nKashidaGid; - DWORD ret = GetGlyphIndicesW(getHDC(), &nKashidaCh, 1, &nKashidaGid, GGI_MARK_NONEXISTING_GLYPHS); - if (ret != GDI_ERROR && nKashidaGid != 0xFFFF) - { - int nKashidaWidth = 0; - if (GetCharWidthI(getHDC(), nKashidaGid, 1, nullptr, &nKashidaWidth)) - rxFontMetric->SetMinKashida(static_cast<int>(mfFontScale[nFallbackLevel] * nKashidaWidth)); - } + rxFontMetric->SetMinKashida(mpWinFontEntry[nFallbackLevel]->GetKashidaWidth()); // get the font metric OUTLINETEXTMETRICW aOutlineMetric; |