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

Khaled Hosny khaledhosny at eglug.org
Fri Sep 6 12:16:41 PDT 2013


 config_host/config_features.h.in  |    4 ++++
 configure.ac                      |    8 ++++++++
 vcl/generic/glyphs/gcach_ftyp.cxx |   29 +++++++----------------------
 3 files changed, 19 insertions(+), 22 deletions(-)

New commits:
commit e4a1acd396785675bfc25c7cd5c66304ec40f38f
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Fri Sep 6 16:04:09 2013 +0200

    Check for FT_Face_GetCharVariantIndex at build time
    
    No more dlsym() hacks. The downside is that LibreOffice built on systems
    with old FreeType will not be able to use FT_Face_GetCharVariantIndex()
    on newer systems, but most Linux users use their distribution builds
    anyway.
    
    This only affects the use of Unicode Variation Selectors which is an
    exotic feature that wasn't even supported on Linux before 4.1.
    
    Change-Id: I674822ef5bc8d7940a821a01cc85ae7a6d39a80e
    Reviewed-on: https://gerrit.libreoffice.org/5844
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/config_host/config_features.h.in b/config_host/config_features.h.in
index 1c42ff0..100706a 100644
--- a/config_host/config_features.h.in
+++ b/config_host/config_features.h.in
@@ -116,5 +116,9 @@
 
 #define HAVE_FEATURE_READONLY_INSTALLSET 0
 
+/*
+ * Whether FreeType has FT_Face_GetCharVariantIndex or not.
+ */
+#define HAVE_FT_FACE_GETCHARVARIANTINDEX 0
 
 #endif
diff --git a/configure.ac b/configure.ac
index 2f20dd1..22807cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -608,6 +608,7 @@ linux-android*)
         AC_MSG_ERROR([the --with-android-sdk option does not point to an Android SDK])
     fi
 
+    AC_DEFINE(HAVE_FT_FACE_GETCHARVARIANTINDEX)
     BUILD_TYPE="$BUILD_TYPE FONTCONFIG FREETYPE"
     ;;
 
@@ -7686,6 +7687,13 @@ if test  "$test_freetype" = "yes"; then
     PKG_CHECK_MODULES(FREETYPE, freetype2 >= 9.9.3)
     FREETYPE_CFLAGS=$(printf '%s' "$FREETYPE_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
     SYSTEM_FREETYPE=YES
+    _save_libs="$LIBS"
+    _save_cflags="$CFLAGS"
+    LIBS="$LIBS $FREETYPE_LIBS"
+    CFLAGS="$CFLAGS $FREETYPE_CFLAGS"
+    AC_CHECK_FUNC(FT_Face_GetCharVariantIndex, AC_DEFINE(HAVE_FT_FACE_GETCHARVARIANTINDEX), [])
+    LIBS="$_save_libs"
+    CFLAGS="$_save_cflags"
 fi
 AC_SUBST(FREETYPE_CFLAGS)
 AC_SUBST(FREETYPE_LIBS)
diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx
index df56d1b..ff0a428 100644
--- a/vcl/generic/glyphs/gcach_ftyp.cxx
+++ b/vcl/generic/glyphs/gcach_ftyp.cxx
@@ -28,6 +28,7 @@
 #include "vcl/svapp.hxx"
 #include <outfont.hxx>
 #include <impfont.hxx>
+#include <config_features.h>
 #include <config_graphite.h>
 #if ENABLE_GRAPHITE
 #include <graphite2/Font.h>
@@ -67,8 +68,6 @@ typedef const FT_Vector* FT_Vector_CPtr;
 
 // TODO: move file mapping stuff to OSL
 #if defined(UNX)
-    // PORTERS: dlfcn is used for getting symbols from FT versions newer than baseline
-    #include <dlfcn.h>
     #include <unistd.h>
     #include <fcntl.h>
     #include <sys/stat.h>
@@ -115,7 +114,6 @@ static FT_Library aLibFT = 0;
 
 // enable linking with old FT versions
 static int nFTVERSION = 0;
-static FT_UInt (*pFT_Face_GetCharVariantIndex)(FT_Face, FT_ULong, FT_ULong);
 
 typedef ::boost::unordered_map<const char*, boost::shared_ptr<FtFontFile>, rtl::CStringHash, rtl::CStringEqual> FontFileList;
 
@@ -468,23 +466,6 @@ FreetypeManager::FreetypeManager()
     FT_Library_Version(aLibFT, &nMajor, &nMinor, &nPatch);
     nFTVERSION = nMajor * 1000 + nMinor * 100 + nPatch;
 
-#ifdef ANDROID
-    // For Android we use the bundled static libfreetype.a, and we
-    // want to avoid accidentally finding the FT_* symbols in the
-    // system FreeType code (which *is* present in a system library,
-    // libskia.so, but is not a public API, and in fact does crash the
-    // app if used).
-    pFT_Face_GetCharVariantIndex = FT_Face_GetCharVariantIndex;
-#else
-#ifdef RTLD_DEFAULT // true if a good dlfcn.h header was included
-    pFT_Face_GetCharVariantIndex = (FT_UInt(*)(FT_Face, FT_ULong, FT_ULong))(sal_IntPtr)dlsym( RTLD_DEFAULT, "FT_Face_GetCharVariantIndex" );
-
-    // disable FT_Face_GetCharVariantIndex for older versions
-    // https://bugzilla.mozilla.org/show_bug.cgi?id=618406#c8
-    if( nFTVERSION < 2404 )
-        pFT_Face_GetCharVariantIndex = NULL;
-#endif
-#endif
     // TODO: remove when the priorities are selected by UI
     char* pEnv;
     pEnv = ::getenv( "SAL_EMBEDDED_BITMAP_PRIORITY" );
@@ -1110,10 +1091,14 @@ int ServerFont::GetRawGlyphIndex(sal_UCS4 aChar, sal_UCS4 aVS) const
     }
 
     int nGlyphIndex = 0;
+#if HAVE_FT_FACE_GETCHARVARIANTINDEX
     // If asked, check first for variant glyph with the given Unicode variation
     // selector. This is quite uncommon so we don't bother with caching here.
-    if (aVS && pFT_Face_GetCharVariantIndex)
-        nGlyphIndex = (*pFT_Face_GetCharVariantIndex)(maFaceFT, aChar, aVS);
+    // Disabled for buggy FreeType versions:
+    // https://bugzilla.mozilla.org/show_bug.cgi?id=618406#c8
+    if (aVS && nFTVERSION >= 2404)
+        nGlyphIndex = FT_Face_GetCharVariantIndex(maFaceFT, aChar, aVS);
+#endif
 
     if (nGlyphIndex == 0)
     {


More information about the Libreoffice-commits mailing list