[Libreoffice-commits] core.git: vcl/inc vcl/source

Mark Hung marklh9 at gmail.com
Fri Nov 17 09:02:42 UTC 2017


 vcl/inc/impfontmetricdata.hxx  |    1 +
 vcl/source/font/fontmetric.cxx |   33 ++++++++++++++++++---------------
 vcl/source/outdev/font.cxx     |    1 +
 3 files changed, 20 insertions(+), 15 deletions(-)

New commits:
commit b843db1a8e3f50bc88e4278cd330bba86a62a206
Author: Mark Hung <marklh9 at gmail.com>
Date:   Tue Nov 14 02:35:32 2017 +0800

    vcl: clean ImplFontMetricData::ImplInitTextLineSize a little bit.
    
    Move initialization of FullstopCenteredFlag out
    of ImplFontMetricData::ImplInitTextLineSize since it has
    nothing to do with text lines.
    
    Change-Id: I1c2e383d980514c8727d736a3158325c1e0ccfda
    Reviewed-on: https://gerrit.libreoffice.org/44712
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Mark Hung <marklh9 at gmail.com>

diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx
index fd15e5765164..f08e86fdc914 100644
--- a/vcl/inc/impfontmetricdata.hxx
+++ b/vcl/inc/impfontmetricdata.hxx
@@ -90,6 +90,7 @@ public:
 
     void            ImplInitTextLineSize( const OutputDevice* pDev );
     void            ImplInitAboveTextLineSize();
+    void            ImplInitFlags( const OutputDevice* pDev );
     void            ImplCalcLineSpacing(const std::vector<uint8_t>& rHhea,
                                         const std::vector<uint8_t>& rOS_2,
                                         int nUPEM);
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index d2de3917604e..cd23756f0f97 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -320,21 +320,6 @@ void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev )
     mnDStrikeoutOffset1    = nStrikeoutOffset - n2LineDY2 - n2LineHeight;
     mnDStrikeoutOffset2    = mnDStrikeoutOffset1 + n2LineDY + n2LineHeight;
 
-    const vcl::Font& rFont ( pDev->GetFont() );
-    bool bCentered = true;
-    if (MsLangId::isCJK(rFont.GetLanguage()))
-    {
-        const OUString sFullstop( u'\x3001' ); // Fullwidth fullstop
-        tools::Rectangle aRect;
-        pDev->GetTextBoundRect( aRect, sFullstop );
-        const sal_uInt16 nH = rFont.GetFontSize().Height();
-        const sal_uInt16 nB = aRect.Left();
-        // Use 18.75% as a threshold to define a centered fullwidth fullstop.
-        // In general, nB/nH < 5% for most Japanese fonts.
-        bCentered = nB > (((nH >> 1)+nH)>>3);
-    }
-    SetFullstopCenteredFlag( bCentered );
-
     mnBulletOffset = ( pDev->GetTextWidth( OUString( u' ' ) ) - pDev->GetTextWidth( OUString( u'\x00b7' ) ) ) >> 1 ;
 
 }
@@ -390,6 +375,24 @@ void ImplFontMetricData::ImplInitAboveTextLineSize()
     mnAboveWUnderlineOffset = nCeiling + (nIntLeading + 1) / 2;
 }
 
+void ImplFontMetricData::ImplInitFlags( const OutputDevice* pDev )
+{
+    const vcl::Font& rFont ( pDev->GetFont() );
+    bool bCentered = true;
+    if (MsLangId::isCJK(rFont.GetLanguage()))
+    {
+        const OUString sFullstop( u'\x3001' ); // Fullwidth fullstop
+        tools::Rectangle aRect;
+        pDev->GetTextBoundRect( aRect, sFullstop );
+        const sal_uInt16 nH = rFont.GetFontSize().Height();
+        const sal_uInt16 nB = aRect.Left();
+        // Use 18.75% as a threshold to define a centered fullwidth fullstop.
+        // In general, nB/nH < 5% for most Japanese fonts.
+        bCentered = nB > (((nH >> 1)+nH)>>3);
+    }
+    SetFullstopCenteredFlag( bCentered );
+}
+
 /*
  * Calculate line spacing:
  *
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 2a5d88852fb2..9a44a10fb469 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -1078,6 +1078,7 @@ bool OutputDevice::ImplNewFont() const
 
             pFontInstance->mxFontMetric->ImplInitTextLineSize( this );
             pFontInstance->mxFontMetric->ImplInitAboveTextLineSize();
+            pFontInstance->mxFontMetric->ImplInitFlags( this );
 
             pFontInstance->mnLineHeight = pFontInstance->mxFontMetric->GetAscent() + pFontInstance->mxFontMetric->GetDescent();
 


More information about the Libreoffice-commits mailing list