[Libreoffice-commits] core.git: 5 commits - config_host.mk.in configure.ac vcl/generic

Khaled Hosny khaledhosny at eglug.org
Sat May 11 00:02:47 PDT 2013


 config_host.mk.in                 |    1 
 configure.ac                      |   27 +---
 vcl/generic/glyphs/gcach_ftyp.cxx |  240 +++++++++-----------------------------
 3 files changed, 66 insertions(+), 202 deletions(-)

New commits:
commit fe9def183be4025f8c2ebba5f486fff1c20ecc80
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sat May 11 08:44:11 2013 +0200

    USE_FT_EMBOLDEN has never been used
    
    Change-Id: Idd30f6fcf9d1e4d2af5f49caffa91d6ce30bb196

diff --git a/config_host.mk.in b/config_host.mk.in
index cfe407c..76ac1a7 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -540,7 +540,6 @@ export UNIXWRAPPERNAME=@UNIXWRAPPERNAME@
 export UNOWINREG_DLL=@UNOWINREG_DLL@
 export UPD=@UPD@
 export URELIBS=@URELIBS@
-export USE_FT_EMBOLDEN=@USE_FT_EMBOLDEN@
 export USE_XINERAMA=@USE_XINERAMA@
 export use_shl_version=@use_shl_version@
 export UUIDGEN=@UUIDGEN@
diff --git a/configure.ac b/configure.ac
index 5aba388..10d0648 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7308,23 +7308,6 @@ dnl Check for system libwpg
 dnl ===================================================================
 libo_CHECK_SYSTEM_MODULE([libwpg],[WPG],[libwpg-0.2],["-I${OUTDIR}/inc/external"],["-L${OUTDIR}/lib -lwpglib"])
 
-dnl ===================================================================
-dnl Check whether freetype2 supports emboldening
-dnl ===================================================================
-if test  "$test_freetype" = "yes"; then
-    save_CPPFLAGS="$CPPFLAGS"
-    save_LDFLAGS="$LDFLAGS"
-    save_LIBS="$LIBS"
-    CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS"
-    LDFLAGS="$LDFLAGS $FREETYPE_LIBS"
-    AC_CHECK_LIB(freetype, FT_GlyphSlot_Embolden,
-                 [USE_FT_EMBOLDEN="YES"], [USE_FT_EMBOLDEN="NO"], [])
-    LDFLAGS="$save_LDFLAGS"
-    CPPFLAGS="$save_CPPFLAGS"
-    LIBS="$save_LIBS"
-fi
-AC_SUBST(USE_FT_EMBOLDEN)
-
 # ===================================================================
 # Check for system libxslt
 # to prevent incompatibilities between internal libxml2 and external libxslt,
commit 96137f1ef8e1e2c8787b899edf8b2969c2eff5dc
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sat May 11 08:29:46 2013 +0200

    Drop code for FreeTyope version we don't support
    
    Change-Id: I404ac35010c243fad65b6d83c10c75665a0568f0

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 1b31f2c..9995964 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -63,13 +63,8 @@
 #endif
 #include "rtl/instance.hxx"
 
-#ifndef FREETYPE_PATCH
-    // VERSION_MINOR in freetype.h is too coarse
-    // if patch-level is not available we need to fine-tune the version ourselves
-    #define FTVERSION 2005
-#else
-    #define FTVERSION (1000*FREETYPE_MAJOR + 100*FREETYPE_MINOR + FREETYPE_PATCH)
-#endif
+#define FTVERSION (1000*FREETYPE_MAJOR + 100*FREETYPE_MINOR + FREETYPE_PATCH)
+
 #if FTVERSION >= 2200
 typedef const FT_Vector* FT_Vector_CPtr;
 #else // FTVERSION < 2200
@@ -521,11 +516,6 @@ FreetypeManager::FreetypeManager()
         pFTLibraryVersion( aLibFT, &nMajor, &nMinor, &nPatch );
     nFTVERSION = nMajor * 1000 + nMinor * 100 + nPatch;
 
-    // disable embedded bitmaps for Freetype-2.1.3 unless explicitly
-    // requested by env var below because it crashes StarOffice on RH9
-    // reason: double free in freetype's embedded bitmap handling
-    if( nFTVERSION == 2103 )
-        nDefaultPrioEmbedded = 0;
     // disable artificial emboldening with the Freetype API for older versions
     if( nFTVERSION < 2110 )
         pFTEmbolden = NULL;
@@ -716,14 +706,10 @@ ServerFont::ServerFont( const FontSelectPattern& rFSD, FtFontInfo* pFI )
     FT_Encoding eEncoding = FT_ENCODING_UNICODE;
     if( mpFontInfo->IsSymbolFont() )
     {
-#if (FTVERSION < 2000)
-        eEncoding = FT_ENCODING_NONE;
-#else
         if( FT_IS_SFNT( maFaceFT ) )
             eEncoding = ft_encoding_symbol;
         else
             eEncoding = FT_ENCODING_ADOBE_CUSTOM; // freetype wants this for PS symbol fonts
-#endif
     }
     rc = FT_Select_Charmap( maFaceFT, eEncoding );
     // no standard encoding applies => we need an encoding converter
@@ -854,13 +840,11 @@ void ServerFont::SetFontOptions( boost::shared_ptr<ImplFontOptions> pFontOptions
     if( mpFontOptions->DontUseHinting() )
       mnPrioAutoHint = 0;
 
-#if (FTVERSION >= 2005) || defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
     if( mnPrioAutoHint <= 0 )
-#endif
         mnLoadFlags |= FT_LOAD_NO_HINTING;
 
 #if defined(FT_LOAD_TARGET_LIGHT) && defined(FT_LOAD_TARGET_NORMAL)
-    if( !(mnLoadFlags & FT_LOAD_NO_HINTING) && (nFTVERSION >= 2103))
+    if( !(mnLoadFlags & FT_LOAD_NO_HINTING) )
     {
        mnLoadFlags |= FT_LOAD_TARGET_NORMAL;
        switch( mpFontOptions->GetHintStyle() )
@@ -1113,14 +1097,6 @@ int ServerFont::ApplyGlyphTransform( int nGlyphFlags,
         // orthogonal transforms are better handled by bitmap operations
         if( bStretched || (bForBitmapProcessing && (nAngle % 900) != 0) )
         {
-            // workaround for compatibility with older FT versions
-            if( nFTVERSION < 2102 )
-            {
-                FT_Fixed t = aMatrix.xy;
-                aMatrix.xy = aMatrix.yx;
-                aMatrix.yx = t;
-            }
-
             // apply non-orthogonal or stretch transformations
             FT_Glyph_Transform( pGlyphFT, &aMatrix, NULL );
             nAngle = 0;
@@ -1259,11 +1235,7 @@ static int lcl_GetCharWidth( FT_FaceRec_* pFaceFT, double fStretch, int nGlyphFl
     if( nGlyphFlags & GF_ROTMASK )  // for bVertical rotated glyphs
     {
         const FT_Size_Metrics& rMetrics = pFaceFT->size->metrics;
-#if (FTVERSION < 2000)
-        nCharWidth = (int)((rMetrics.height - rMetrics.descender) * fStretch);
-#else
         nCharWidth = (int)((rMetrics.height + rMetrics.descender) * fStretch);
-#endif
     }
 
     return (nCharWidth + 32) >> 6;
@@ -1285,20 +1257,7 @@ void ServerFont::InitGlyphData( int nGlyphIndex, GlyphData& rGD ) const
 //      nLoadFlags |= FT_LOAD_NO_BITMAP;
 
     FT_Error rc = -1;
-#if (FTVERSION <= 2008)
-    // #88364# freetype<=2005 prefers autohinting to embedded bitmaps
-    // => first we have to try without hinting
-    if( (nLoadFlags & (FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)) == 0 )
-    {
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags|FT_LOAD_NO_HINTING );
-        if( (rc==FT_Err_Ok) && (maFaceFT->glyph->format!=FT_GLYPH_FORMAT_BITMAP) )
-            rc = -1; // mark as "loading embedded bitmap" was unsuccessful
-        nLoadFlags |= FT_LOAD_NO_BITMAP;
-    }
-
-    if( rc != FT_Err_Ok )
-#endif
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
+    rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
 
     if( rc != FT_Err_Ok )
     {
@@ -1370,32 +1329,18 @@ bool ServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& rRawBitmap ) const
     if( mbArtItalic )
         nLoadFlags |= FT_LOAD_NO_BITMAP;
 
-#if (FTVERSION >= 2002)
     // for 0/90/180/270 degree fonts enable hinting even if not advisable
     // non-hinted and non-antialiased bitmaps just look too ugly
     if( (mnCos==0 || mnSin==0) && (mnPrioAutoHint > 0) )
         nLoadFlags &= ~FT_LOAD_NO_HINTING;
-#endif
 
     if( mnPrioEmbedded <= mnPrioAutoHint )
         nLoadFlags |= FT_LOAD_NO_BITMAP;
 
     FT_Error rc = -1;
-#if (FTVERSION <= 2008)
-    // #88364# freetype<=2005 prefers autohinting to embedded bitmaps
-    // => first we have to try without hinting
-    if( (nLoadFlags & (FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)) == 0 )
-    {
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags|FT_LOAD_NO_HINTING );
-        if( (rc==FT_Err_Ok) && (maFaceFT->glyph->format != FT_GLYPH_FORMAT_BITMAP) )
-            rc = -1; // mark as "loading embedded bitmap" was unsuccessful
-        nLoadFlags |= FT_LOAD_NO_BITMAP;
-    }
+    rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
 
     if( rc != FT_Err_Ok )
-#endif
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
-    if( rc != FT_Err_Ok )
         return false;
 
     if( mbArtBold && pFTEmbolden )
@@ -1412,10 +1357,7 @@ bool ServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& rRawBitmap ) const
     {
         FT_Matrix aMatrix;
         aMatrix.xx = aMatrix.yy = 0x10000L;
-        if( nFTVERSION >= 2102 )    // Freetype 2.1.2 API swapped xy with yx
-            aMatrix.xy = 0x6000L, aMatrix.yx = 0;
-        else
-            aMatrix.yx = 0x6000L, aMatrix.xy = 0;
+        aMatrix.xy = 0x6000L, aMatrix.yx = 0;
         FT_Glyph_Transform( pGlyphFT, &aMatrix, NULL );
     }
 
@@ -1437,8 +1379,7 @@ bool ServerFont::GetGlyphBitmap1( int nGlyphIndex, RawBitmap& rRawBitmap ) const
     {
         if( pGlyphFT->format == FT_GLYPH_FORMAT_OUTLINE )
             ((FT_OutlineGlyphRec*)pGlyphFT)->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
-        // #i15743# freetype API 2.1.3 changed the FT_RENDER_MODE_MONO constant
-        FT_Render_Mode nRenderMode = (FT_Render_Mode)((nFTVERSION<2103) ? 1 : FT_RENDER_MODE_MONO);
+        FT_Render_Mode nRenderMode = FT_RENDER_MODE_MONO;
 
         rc = FT_Glyph_To_Bitmap( &pGlyphFT, nRenderMode, NULL, sal_True );
         if( rc != FT_Err_Ok )
@@ -1538,32 +1479,14 @@ bool ServerFont::GetGlyphBitmap8( int nGlyphIndex, RawBitmap& rRawBitmap ) const
     if( mbArtItalic )
         nLoadFlags |= FT_LOAD_NO_BITMAP;
 
-#if (FTVERSION <= 2004) && !defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER)
-    // autohinting in FT<=2.0.4 makes antialiased glyphs look worse
-    nLoadFlags |= FT_LOAD_NO_HINTING;
-#else
     if( (nGlyphFlags & GF_UNHINTED) || (mnPrioAutoHint < mnPrioAntiAlias) )
         nLoadFlags |= FT_LOAD_NO_HINTING;
-#endif
 
     if( mnPrioEmbedded <= mnPrioAntiAlias )
         nLoadFlags |= FT_LOAD_NO_BITMAP;
 
     FT_Error rc = -1;
-#if (FTVERSION <= 2008)
-    // #88364# freetype<=2005 prefers autohinting to embedded bitmaps
-    // => first we have to try without hinting
-    if( (nLoadFlags & (FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP)) == 0 )
-    {
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags|FT_LOAD_NO_HINTING );
-        if( (rc==FT_Err_Ok) && (maFaceFT->glyph->format != FT_GLYPH_FORMAT_BITMAP) )
-            rc = -1; // mark as "loading embedded bitmap" was unsuccessful
-        nLoadFlags |= FT_LOAD_NO_BITMAP;
-    }
-
-    if( rc != FT_Err_Ok )
-#endif
-        rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
+    rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
 
     if( rc != FT_Err_Ok )
         return false;
@@ -1582,10 +1505,7 @@ bool ServerFont::GetGlyphBitmap8( int nGlyphIndex, RawBitmap& rRawBitmap ) const
     {
         FT_Matrix aMatrix;
         aMatrix.xx = aMatrix.yy = 0x10000L;
-        if( nFTVERSION >= 2102 )    // Freetype 2.1.2 API swapped xy with yx
-            aMatrix.xy = 0x6000L, aMatrix.yx = 0;
-        else
-            aMatrix.yx = 0x6000L, aMatrix.xy = 0;
+        aMatrix.xy = 0x6000L, aMatrix.yx = 0;
         FT_Glyph_Transform( pGlyphFT, &aMatrix, NULL );
     }
 
@@ -2236,8 +2156,7 @@ bool ServerFont::GetGlyphOutline( int nGlyphIndex,
 
 #ifdef FT_LOAD_TARGET_LIGHT
     // enable "light hinting" if available
-    if( nFTVERSION >= 2103 )
-        nLoadFlags |= FT_LOAD_TARGET_LIGHT;
+    nLoadFlags |= FT_LOAD_TARGET_LIGHT;
 #endif
 
     FT_Error rc = FT_Load_Glyph( maFaceFT, nGlyphIndex, nLoadFlags );
@@ -2259,10 +2178,7 @@ bool ServerFont::GetGlyphOutline( int nGlyphIndex,
     {
         FT_Matrix aMatrix;
         aMatrix.xx = aMatrix.yy = 0x10000L;
-        if( nFTVERSION >= 2102 )    // Freetype 2.1.2 API swapped xy with yx
-            aMatrix.xy = 0x6000L, aMatrix.yx = 0;
-        else
-            aMatrix.yx = 0x6000L, aMatrix.xy = 0;
+        aMatrix.xy = 0x6000L, aMatrix.yx = 0;
         FT_Glyph_Transform( pGlyphFT, &aMatrix, NULL );
     }
 
commit 1266602a0d47c348043c301677399a24eeeebcce
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sat May 11 07:46:15 2013 +0200

    Fix FreeType version check
    
    FreeType has 3 different kinds of versions
    * release, like 2.4.10
    * libtool, like 13.0.7 (this what pkg-config returns)
    * soname
    
    FreeType's docs/VERSION.DLL provides a table mapping between the three
    
    We were checking for >= 2.0 which is always true of course, so I
    replaced it with 9.4.3 i.e. 2.1.5; the first FreeType release to provide
    a freetype2.pc file (I could have omitted the version check at all,
    since it is practically the same), but this should be replaced with a
    real minimum required version.
    
    Change-Id: I95f6c398a5b19d4bb728a6dddc957a9f95f27efa

diff --git a/configure.ac b/configure.ac
index 9871f4c..5aba388 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7279,7 +7279,15 @@ dnl Check whether freetype is available
 dnl ===================================================================
 if test  "$test_freetype" = "yes"; then
     AC_MSG_CHECKING([whether freetype is available])
-    PKG_CHECK_MODULES( FREETYPE, freetype2 >= 2.0 )
+    # FreeType has 3 different kinds of versions
+    # * release, like 2.4.10
+    # * libtool, like 13.0.7 (this what pkg-config returns)
+    # * soname
+    # FreeType's docs/VERSION.DLL provides a table mapping between the three
+    #
+    # 9.4.3 is 2.1.5; the first FreeType release to provide a freetype2.pc file
+    # XXX: replace this with a real minimum required version
+    PKG_CHECK_MODULES( FREETYPE, freetype2 >= 9.4.3 )
 else
     case "$BUILD_TYPE" in
     *FREETYPE*)
commit f9560c8f9982eaef09b74baa479c187f049c4f9e
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sat May 11 07:07:29 2013 +0200

    Cleanup FreeType ascender/descender handling a bit
    
    Change-Id: I9734f15811020ce1a7b761688d602c7e244167c7

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index a10aeb3..1b31f2c 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -949,16 +949,57 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
 
     rFactor = 0x100;
 
-    rTo.mnWidth             = mnWidth;
+    const TT_OS2* pOS2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 );
+    const double fScale = (double)GetFontSelData().mnHeight / maFaceFT->units_per_EM;
+
+    rTo.mnAscent = 0;
+    rTo.mnDescent = 0;
+    rTo.mnExtLeading = 0;
+    rTo.mnSlant = 0;
+    rTo.mnIntLeading = (rTo.mnAscent + rTo.mnDescent) - ((maFaceFT->units_per_EM + 32) >> 6);
+    rTo.mnWidth = mnWidth;
+
+    // Calculating ascender and descender:
+    // FreeType >= 2.4.6 does the right thing, so we just use what it gives us,
+    // for earlier versions we emulate its behaviour; take them from 'hhea'
+    // table, if zero take them from 'OS/2' table.
+    if (nFTVERSION >= 2406)
+    {
+        const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
+        rTo.mnAscent = (rMetrics.ascender + 32) >> 6;
+        rTo.mnDescent = (-rMetrics.descender + 32) >> 6;
+        rTo.mnExtLeading = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + rTo.mnDescent);
+    }
+    else
+    {
+        const TT_HoriHeader* pHHea = (const TT_HoriHeader*)FT_Get_Sfnt_Table(maFaceFT, ft_sfnt_hhea);
+        if (pHHea)
+        {
+            rTo.mnAscent = pHHea->Ascender * fScale + 0.5;
+            rTo.mnDescent = -pHHea->Descender * fScale + 0.5;
+            rTo.mnExtLeading = pHHea->Line_Gap * fScale + 0.5;
+        }
 
-    const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
-    rTo.mnAscent            = (+rMetrics.ascender + 32) >> 6;
-    rTo.mnDescent           = (-rMetrics.descender + 32) >> 6;
-    rTo.mnExtLeading        = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + rTo.mnDescent);
-    rTo.mnIntLeading        = (rTo.mnAscent + rTo.mnDescent) - ((maFaceFT->units_per_EM + 32) >> 6);
-    rTo.mnSlant             = 0;
+        if (!(rTo.mnAscent || rTo.mnDescent))
+        {
+            if (pOS2 && (pOS2->version != 0xFFFF))
+            {
+                if (pOS2->sTypoAscender || pOS2->sTypoDescender)
+                {
+                    rTo.mnAscent = pOS2->sTypoAscender * fScale + 0.5;
+                    rTo.mnDescent = -pOS2->sTypoDescender * fScale + 0.5;
+                    rTo.mnExtLeading = pOS2->sTypoLineGap * fScale + 0.5;
+                }
+                else
+                {
+                    rTo.mnAscent = pOS2->usWinAscent * fScale + 0.5;
+                    rTo.mnDescent = pOS2->usWinDescent * fScale + 0.5;
+                    rTo.mnDescent = 0;
+                }
+            }
+        }
+    }
 
-    const TT_OS2* pOS2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 );
     if( pOS2 && (pOS2->version != 0xFFFF) )
     {
         // map the panose info from the OS2 table to their VCL counterparts
@@ -989,15 +1030,6 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
             case 1: // fall through
             default: rTo.SetPitch( PITCH_DONTKNOW ); break;
         }
-
-        const double fScale = (double)GetFontSelData().mnHeight / maFaceFT->units_per_EM;
-        if( pOS2->sTypoAscender || pOS2->sTypoDescender )
-        {
-            rTo.mnAscent     = (long)(  pOS2->sTypoAscender  * fScale + 0.5 );
-            rTo.mnDescent    = (long)( -pOS2->sTypoDescender * fScale + 0.5 );
-            rTo.mnExtLeading = (long)(  pOS2->sTypoLineGap   * fScale + 0.5 );
-            rTo.mnIntLeading = (long)( (pOS2->sTypoAscender - pOS2->sTypoDescender - maFaceFT->units_per_EM) * fScale + 0.5 );
-        }
     }
 
     // initialize kashida width
commit 5e77c9e17ba7dd9d296c9b755093f01e7eb4f514
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sat May 11 00:50:59 2013 +0200

    Revert 052f181dad89ad34d90513bc9dcd3e3239727933
    
    Which in itself was effectively a revert of
    3364fefe1e2dec522211040f2f9ea37bf5cd7466
    
    Keeping the old broken line height calculation code is just masking of
    the real problem; there are some code elsewhere that have fragile
    workarounds to the real bug here (the removed code here shows a good
    example of such workarounds). On Mac we use the correct metrics as well,
    so we need to find the quirks and fix them, instead of pretending they
    do not exist.
    
    This fixes fdo#55469, among others.
    
    Change-Id: I36f13b28eaba022b7c388feae7e0bfd0ed1c3e89

diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index 13e6aa9..a10aeb3 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -928,18 +928,6 @@ int ServerFont::GetEmUnits() const
 
 void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
 {
-    const int UNDETERMINED = 0xFEED;
-    static int nUseNewLineHeight = UNDETERMINED;
-    if (nUseNewLineHeight == UNDETERMINED)
-    {
-        osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex());
-        if (nUseNewLineHeight == UNDETERMINED)
-        {
-            const char* pEnv = getenv( "SAL_USE_NEW_LINEHEIGHT");
-            nUseNewLineHeight = (pEnv ? atoi(pEnv) : 0);
-        }
-    }
-
     static_cast<ImplFontAttributes&>(rTo) = mpFontInfo->GetFontAttributes();
 
     rTo.mbScalableFont  = true;
@@ -966,15 +954,8 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
     const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics;
     rTo.mnAscent            = (+rMetrics.ascender + 32) >> 6;
     rTo.mnDescent           = (-rMetrics.descender + 32) >> 6;
-    if (nUseNewLineHeight)
-    {
-        rTo.mnExtLeading    = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + rTo.mnDescent);
-        rTo.mnIntLeading    = (rTo.mnAscent + rTo.mnDescent) - ((maFaceFT->units_per_EM + 32) >> 6);
-    }
-    else
-    {
-        rTo.mnIntLeading    = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + rTo.mnDescent);
-    }
+    rTo.mnExtLeading        = ((rMetrics.height + 32) >> 6) - (rTo.mnAscent + rTo.mnDescent);
+    rTo.mnIntLeading        = (rTo.mnAscent + rTo.mnDescent) - ((maFaceFT->units_per_EM + 32) >> 6);
     rTo.mnSlant             = 0;
 
     const TT_OS2* pOS2 = (const TT_OS2*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_os2 );
@@ -1010,67 +991,12 @@ void ServerFont::FetchFontMetric( ImplFontMetricData& rTo, long& rFactor ) const
         }
 
         const double fScale = (double)GetFontSelData().mnHeight / maFaceFT->units_per_EM;
-        if (nUseNewLineHeight)
-        {
-            if( pOS2->sTypoAscender || pOS2->sTypoDescender )
-            {
-                rTo.mnAscent     = (long)(  pOS2->sTypoAscender  * fScale + 0.5 );
-                rTo.mnDescent    = (long)( -pOS2->sTypoDescender * fScale + 0.5 );
-                rTo.mnExtLeading = (long)(  pOS2->sTypoLineGap   * fScale + 0.5 );
-                rTo.mnIntLeading = (long)( (pOS2->sTypoAscender - pOS2->sTypoDescender - maFaceFT->units_per_EM) * fScale + 0.5 );
-            }
-        }
-        else
+        if( pOS2->sTypoAscender || pOS2->sTypoDescender )
         {
-            // #108862# sanity check, some fonts treat descent as signed !!!
-            int nDescent = pOS2->usWinDescent;
-            if( nDescent > 5*maFaceFT->units_per_EM )
-                nDescent = (short)pOS2->usWinDescent; // interpret it as signed!
-
-            if( pOS2->usWinAscent || pOS2->usWinDescent ) // #i30551#
-            {
-                rTo.mnAscent     = (long)( +pOS2->usWinAscent * fScale + 0.5 );
-                rTo.mnDescent    = (long)( +nDescent * fScale + 0.5 );
-                rTo.mnIntLeading = (long)( (+pOS2->usWinAscent + pOS2->usWinDescent - maFaceFT->units_per_EM) * fScale + 0.5 );
-            }
-            rTo.mnExtLeading = 0;
-            const TT_HoriHeader* pHHEA = (const TT_HoriHeader*)FT_Get_Sfnt_Table( maFaceFT, ft_sfnt_hhea );
-            if( (pHHEA != NULL) && (pOS2->usWinAscent || pOS2->usWinDescent) )
-            {
-                int nExtLeading = pHHEA->Line_Gap;
-                nExtLeading -= (pOS2->usWinAscent + pOS2->usWinDescent);
-                nExtLeading += (pHHEA->Ascender - pHHEA->Descender);
-                if( nExtLeading > 0 )
-                    rTo.mnExtLeading = (long)(nExtLeading * fScale + 0.5);
-            }
-
-            // Check for CJK capabilities of the current font
-            // #107888# workaround for Asian...
-            // TODO: remove when ExtLeading fully implemented
-            sal_Bool bCJKCapable = ((pOS2->ulUnicodeRange2 & 0x2DF00000) != 0);
-
-            if ( bCJKCapable && (pOS2->usWinAscent || pOS2->usWinDescent) )
-            {
-                rTo.mnIntLeading += rTo.mnExtLeading;
-
-                // #109280# The line height for Asian fonts is too small.
-                // Therefore we add half of the external leading to the
-                // ascent, the other half is added to the descent.
-                const long nHalfTmpExtLeading = rTo.mnExtLeading / 2;
-                const long nOtherHalfTmpExtLeading = rTo.mnExtLeading - nHalfTmpExtLeading;
-
-                // #110641# external leading for Asian fonts.
-                // The factor 0.3 has been verified during experiments.
-                const long nCJKExtLeading = (long)(0.30 * (rTo.mnAscent + rTo.mnDescent));
-
-                if ( nCJKExtLeading > rTo.mnExtLeading )
-                    rTo.mnExtLeading = nCJKExtLeading - rTo.mnExtLeading;
-                else
-                    rTo.mnExtLeading = 0;
-
-                rTo.mnAscent += nHalfTmpExtLeading;
-                rTo.mnDescent += nOtherHalfTmpExtLeading;
-            }
+            rTo.mnAscent     = (long)(  pOS2->sTypoAscender  * fScale + 0.5 );
+            rTo.mnDescent    = (long)( -pOS2->sTypoDescender * fScale + 0.5 );
+            rTo.mnExtLeading = (long)(  pOS2->sTypoLineGap   * fScale + 0.5 );
+            rTo.mnIntLeading = (long)( (pOS2->sTypoAscender - pOS2->sTypoDescender - maFaceFT->units_per_EM) * fScale + 0.5 );
         }
     }
 


More information about the Libreoffice-commits mailing list