vcl/inc/font/LogicalFontInstance.hxx    |   17 -----------------
 vcl/source/font/LogicalFontInstance.cxx |   11 -----------
 vcl/source/gdi/pdfwriter_impl.cxx       |   16 ++++++++++++++--
 3 files changed, 14 insertions(+), 30 deletions(-)

New commits:
commit 47981aeb3a233a01a8b099d3fe2c3f5a8a9cfb7b
Author:     خالد حسني <kha...@aliftype.com>
AuthorDate: Tue Sep 6 00:10:04 2022 +0200
Commit:     خالد حسني <kha...@aliftype.com>
CommitDate: Tue Sep 6 00:50:39 2022 +0200

    Revert "vcl: Add LogicalFontInstance::GetUnscaledGLyphWidth()"
    
    This reverts commit fa1835db77b38047d8c3cea7041d38762c329867.
    
    Reason for revert: merged too early
    
    Change-Id: I7dba2e8fcc06db59b2cbc211a0f4e7d1f209aa05
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139428
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@aliftype.com>

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index 7e3adcb3e15e..8187ccc2e7e0 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -100,8 +100,6 @@ public: // TODO: make data members private
     bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
     virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
-    sal_Int32 GetUnscaledGlyphWidth(sal_GlyphId, bool) const;
-
     int GetKashidaWidth() const;
 
     void GetScale(double* nXScale, double* nYScale) const;
@@ -130,7 +128,6 @@ private:
     mutable ImplFontCache* mpFontCache;
     const vcl::font::FontSelectPattern m_aFontSelData;
     hb_font_t* m_pHbFont;
-    hb_font_t* m_pUnscaledHbFont;
     double m_nAveWidthFactor;
     rtl::Reference<vcl::font::PhysicalFontFace> m_pFontFace;
     std::optional<bool> m_xbIsGraphiteFont;
@@ -143,8 +140,6 @@ private:
 
     // The value is initialized and used in NeedOffsetCorrection().
     std::optional<FontFamilyEnum> m_xeFontFamilyEnum;
-
-    inline hb_font_t* GetUnscaledHbFont();
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
@@ -154,16 +149,4 @@ inline hb_font_t* LogicalFontInstance::GetHbFont()
     return m_pHbFont;
 }
 
-inline hb_font_t* LogicalFontInstance::GetUnscaledHbFont()
-{
-    if (!m_pUnscaledHbFont)
-    {
-        auto* pHbFont = GetHbFont();
-        auto nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont));
-        m_pUnscaledHbFont = hb_font_create_sub_font(pHbFont);
-        hb_font_set_scale(m_pUnscaledHbFont, nUPEM, nUPEM);
-    }
-    return m_pUnscaledHbFont;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 542a814fb9ac..0936bb7286b9 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -37,7 +37,6 @@ LogicalFontInstance::LogicalFontInstance(const 
vcl::font::PhysicalFontFace& rFon
     , mpFontCache(nullptr)
     , m_aFontSelData(rFontSelData)
     , m_pHbFont(nullptr)
-    , m_pUnscaledHbFont(nullptr)
     , m_nAveWidthFactor(1.0f)
     , m_pFontFace(&const_cast<vcl::font::PhysicalFontFace&>(rFontFace))
 {
@@ -51,8 +50,6 @@ LogicalFontInstance::~LogicalFontInstance()
 
     if (m_pHbFont)
         hb_font_destroy(m_pHbFont);
-    if (m_pUnscaledHbFont)
-        hb_font_destroy(m_pUnscaledHbFont);
 }
 
 hb_font_t* LogicalFontInstance::InitHbFont()
@@ -153,14 +150,6 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId 
nID, tools::Rectangle& r
     return res;
 }
 
-sal_Int32 LogicalFontInstance::GetUnscaledGlyphWidth(sal_GlyphId nGlyph, bool 
bVertical) const
-{
-    auto* pHbFont = 
const_cast<LogicalFontInstance*>(this)->GetUnscaledHbFont();
-    if (bVertical)
-        hb_font_get_glyph_v_advance(pHbFont, nGlyph);
-    return hb_font_get_glyph_h_advance(pHbFont, nGlyph);
-}
-
 bool LogicalFontInstance::IsGraphiteFont()
 {
     if (!m_xbIsGraphiteFont)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index dc5e443374ba..f1c01944a48f 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3905,7 +3905,13 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
     const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark),
                           DevicePoint(), GlyphItemFlags::NONE, 0, 0, 0);
     const std::vector<sal_Ucs> aCodeUnits={ cMark };
-    sal_Int32 nGlyphWidth = 
GetFontInstance()->GetUnscaledGlyphWidth(aItem.glyphId(), aItem.IsVertical());
+    sal_Int32 nGlyphWidth = 0;
+    SalGraphics *pGraphics = GetGraphics();
+    if (pGraphics)
+        nGlyphWidth = m_aFontCache.getGlyphWidth(pDevFont,
+                                                 aItem.glyphId(),
+                                                 aItem.IsVertical(),
+                                                 pGraphics);
 
     sal_uInt8 nMappedGlyph;
     sal_Int32 nMappedFontObject;
@@ -6296,7 +6302,13 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 
         assert(!aCodeUnits.empty() || bUseActualText || pGlyph->IsInCluster());
 
-        sal_Int32 nGlyphWidth = 
GetFontInstance()->GetUnscaledGlyphWidth(pGlyph->glyphId(), 
pGlyph->IsVertical());
+        sal_Int32 nGlyphWidth = 0;
+        SalGraphics *pGraphics = GetGraphics();
+        if (pGraphics)
+            nGlyphWidth = m_aFontCache.getGlyphWidth(pFont,
+                                                     pGlyph->glyphId(),
+                                                     pGlyph->IsVertical(),
+                                                     pGraphics);
 
         sal_uInt8 nMappedGlyph;
         sal_Int32 nMappedFontObject;

Reply via email to