[Libreoffice-commits] core.git: vcl/unx

Mark Hung marklh9 at gmail.com
Thu Feb 18 09:41:38 UTC 2016


 vcl/unx/generic/fontmanager/fontmanager.cxx |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

New commits:
commit 775d93d0c0dc902dab6e3bdb978501b5d6295f8b
Author: Mark Hung <marklh9 at gmail.com>
Date:   Wed Jan 13 23:08:37 2016 +0800

    tdf#96091 Correct ascend and descend values for OTC font.
    
    CffSubsetterContext::emitAsType1() calculate ascend and descend
    when emitting PDF font descriptor based on bounding box values.
    However, values can come directly from hhea or OS2 table are
    better for OTC font.
    
    The order that determines which ascend and descend values are
    used in PrintFontManager::analyzeTrueTypeFile() is changed
    in order to make winAscend/winDescend and bounding box based
    values the last choice.
    
    Change-Id: I421f6af6a4bee01d23ccf3e8e65c8f6ad80922b6
    Reviewed-on: https://gerrit.libreoffice.org/21444
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index ffa7f97..d8863a4 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -1294,11 +1294,11 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
         pFont->m_aGlobalMetricY.width = pFont->m_aGlobalMetricX.width = aInfo.xMax - aInfo.xMin;
         pFont->m_aGlobalMetricY.height = pFont->m_aGlobalMetricX.height = aInfo.yMax - aInfo.yMin;
 
-        if( aInfo.winAscent && aInfo.winDescent )
+        if( aInfo.ascender && aInfo.descender )
         {
-            pFont->m_nAscend    = aInfo.winAscent;
-            pFont->m_nDescend   = aInfo.winDescent;
-            pFont->m_nLeading   = pFont->m_nAscend + pFont->m_nDescend - 1000;
+            pFont->m_nLeading   = aInfo.linegap;
+            pFont->m_nAscend    = aInfo.ascender;
+            pFont->m_nDescend   = -aInfo.descender;
         }
         else if( aInfo.typoAscender && aInfo.typoDescender )
         {
@@ -1306,11 +1306,11 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
             pFont->m_nAscend    = aInfo.typoAscender;
             pFont->m_nDescend   = -aInfo.typoDescender;
         }
-        else
+        else if( aInfo.winAscent && aInfo.winDescent )
         {
-            pFont->m_nLeading   = aInfo.linegap;
-            pFont->m_nAscend    = aInfo.ascender;
-            pFont->m_nDescend   = -aInfo.descender;
+            pFont->m_nAscend    = aInfo.winAscent;
+            pFont->m_nDescend   = aInfo.winDescent;
+            pFont->m_nLeading   = pFont->m_nAscend + pFont->m_nDescend - 1000;
         }
 
         // last try: font bounding box
@@ -2012,6 +2012,13 @@ bool PrintFontManager::createFontSubset(
             pOutFile, pGlyphSetName,
             aRequestedGlyphIds, pEnc, nGlyphs, pWidths );
         fclose( pOutFile );
+        // For OTC, values from hhea or OS2 are better
+        psp::PrintFontInfo aFontInfo;
+        if( getFontInfo( nFont, aFontInfo ) )
+        {
+            rInfo.m_nAscent     = aFontInfo.m_nAscend;
+            rInfo.m_nDescent    = -aFontInfo.m_nDescend;
+        }
         // cleanup before early return
         CloseTTFont( pTTFont );
         return bOK;


More information about the Libreoffice-commits mailing list