[libreoffice/f15] Resolves: rhbz#715549 use fontconfig's detected format
Caolan McNamara
caolanm at fedoraproject.org
Tue Jul 19 12:42:48 UTC 2011
commit 00f5343f7fd88e5f4deea92f7e3d737ea58f342f
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Jul 19 13:42:35 2011 +0100
Resolves: rhbz#715549 use fontconfig's detected format
...bz-715549-use-fontconfig-s-detected-forma.patch | 213 ++++++++++++++++++++
libreoffice.spec | 5 +-
2 files changed, 217 insertions(+), 1 deletions(-)
---
diff --git a/0001-Resolves-rhbz-715549-use-fontconfig-s-detected-forma.patch b/0001-Resolves-rhbz-715549-use-fontconfig-s-detected-forma.patch
new file mode 100644
index 0000000..6e4c747
--- /dev/null
+++ b/0001-Resolves-rhbz-715549-use-fontconfig-s-detected-forma.patch
@@ -0,0 +1,213 @@
+From 4d974b37e75d1c46b9ddbf86bc6f2756014c7c46 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Tue, 19 Jul 2011 13:39:34 +0100
+Subject: [PATCH] Resolves: rhbz#715549 use fontconfig's detected format when
+ available
+
+---
+ vcl/inc/vcl/fontmanager.hxx | 2 +-
+ vcl/unx/generic/fontmanager/fontconfig.cxx | 12 +++-
+ vcl/unx/generic/fontmanager/fontmanager.cxx | 81 +++++++++++++++++----------
+ 3 files changed, 62 insertions(+), 33 deletions(-)
+
+diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
+index 410ecf1..816adbe 100644
+--- a/vcl/inc/vcl/fontmanager.hxx
++++ b/vcl/inc/vcl/fontmanager.hxx
+@@ -333,7 +333,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
+
+ void getFontAttributesFromXLFD( PrintFont* pFont, const std::list< rtl::OString >& rXLFDs ) const;
+
+- bool analyzeFontFile( int nDirID, const rtl::OString& rFileName, const std::list< rtl::OString >& rXLFDs, std::list< PrintFont* >& rNewFonts ) const;
++ bool analyzeFontFile( int nDirID, const rtl::OString& rFileName, const std::list< rtl::OString >& rXLFDs, std::list< PrintFont* >& rNewFonts, const char *pFormat=NULL ) const;
+ rtl::OUString convertTrueTypeName( void* pNameRecord ) const; // actually a NameRecord* formt font subsetting code
+ void analyzeTrueTypeFamilyName( void* pTTFont, std::list< rtl::OUString >& rnames ) const; // actually a TrueTypeFont* from font subsetting code
+ bool analyzeTrueTypeFile( PrintFont* pFont ) const;
+diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
+index e4b2f00..5e97bec 100644
+--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
++++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
+@@ -68,6 +68,9 @@ using namespace psp;
+ #ifndef FC_EMBOLDEN
+ #define FC_EMBOLDEN "embolden"
+ #endif
++#ifndef FC_FONTFORMAT
++ #define FC_FONTFORMAT "fontformat"
++#endif
+
+ #include <cstdio>
+ #include <cstdarg>
+@@ -467,6 +470,7 @@ int PrintFontManager::countFontconfigFonts( boost::unordered_map<rtl::OString, i
+ FcChar8* file = NULL;
+ FcChar8* family = NULL;
+ FcChar8* style = NULL;
++ FcChar8* format = NULL;
+ int slant = 0;
+ int weight = 0;
+ int spacing = 0;
+@@ -481,6 +485,7 @@ int PrintFontManager::countFontconfigFonts( boost::unordered_map<rtl::OString, i
+ FcResult eSpacRes = FcPatternGetInteger(pFSet->fonts[i], FC_SPACING, 0, &spacing);
+ FcResult eOutRes = FcPatternGetBool(pFSet->fonts[i], FC_OUTLINE, 0, &outline);
+ FcResult eIndexRes = FcPatternGetInteger(pFSet->fonts[i], FC_INDEX, 0, &nCollectionEntry);
++ FcResult eFormatRes = FcPatternGetString(pFSet->fonts[i], FC_FONTFORMAT, 0, &format);
+
+ if( eFileRes != FcResultMatch || eFamilyRes != FcResultMatch || eOutRes != FcResultMatch )
+ continue;
+@@ -488,13 +493,14 @@ int PrintFontManager::countFontconfigFonts( boost::unordered_map<rtl::OString, i
+ #if (OSL_DEBUG_LEVEL > 2)
+ fprintf( stderr, "found font \"%s\" in file %s\n"
+ " weight = %d, slant = %d, style = \"%s\"\n"
+- " spacing = %d, outline = %d\n"
++ " spacing = %d, outline = %d, format %s\n"
+ , family, file
+ , eWeightRes == FcResultMatch ? weight : -1
+ , eSpacRes == FcResultMatch ? slant : -1
+ , eStyleRes == FcResultMatch ? (const char*) style : "<nil>"
+ , eSpacRes == FcResultMatch ? spacing : -1
+ , eOutRes == FcResultMatch ? outline : -1
++ , eFormatRes == FcResultMatch ? (const char*)format : "<unknown>"
+ );
+ #endif
+
+@@ -529,7 +535,9 @@ int PrintFontManager::countFontconfigFonts( boost::unordered_map<rtl::OString, i
+ // not known, analyze font file to get attributes
+ // not described by fontconfig (e.g. alias names, PSName)
+ std::list< OString > aDummy;
+- analyzeFontFile( nDirID, aBase, aDummy, aFonts );
++ if (eFormatRes != FcResultMatch)
++ format = NULL;
++ analyzeFontFile( nDirID, aBase, aDummy, aFonts, (const char*)format );
+ #if OSL_DEBUG_LEVEL > 1
+ if( aFonts.empty() )
+ fprintf( stderr, "Warning: file \"%s\" is unusable to psprint\n", aOrgPath.getStr() );
+diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
+index 2dceb35..27a2629 100644
+--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
++++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
+@@ -1281,9 +1281,12 @@ int PrintFontManager::addFontFile( const ::rtl::OString& rFileName, int /*nFaceN
+ return nFontId;
+ }
+
+-// -------------------------------------------------------------------------
++enum fontFormat
++{
++ UNKNOWN, TRUETYPE, CFF, TYPE1, AFM
++};
+
+-bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, const ::std::list<OString>& rXLFDs, ::std::list< PrintFontManager::PrintFont* >& rNewFonts ) const
++bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, const ::std::list<OString>& rXLFDs, ::std::list< PrintFontManager::PrintFont* >& rNewFonts, const char *pFormat ) const
+ {
+ rNewFonts.clear();
+
+@@ -1297,8 +1300,32 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, co
+ if( access( aFullPath.getStr(), R_OK ) )
+ return false;
+
+- ByteString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
+- if( aExt.EqualsIgnoreCaseAscii( "pfb" ) || aExt.EqualsIgnoreCaseAscii( "pfa" ) )
++ fontFormat eFormat = UNKNOWN;
++ if (pFormat)
++ {
++ if (!strcmp(pFormat, "TrueType"))
++ eFormat = TRUETYPE;
++ else if (!strcmp(pFormat, "CFF"))
++ eFormat = CFF;
++ else if (!strcmp(pFormat, "Type 1"))
++ eFormat = TYPE1;
++ }
++ if (eFormat == UNKNOWN)
++ {
++ ByteString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
++ if( aExt.EqualsIgnoreCaseAscii( "pfb" ) || aExt.EqualsIgnoreCaseAscii( "pfa" ) )
++ eFormat = TYPE1;
++ else if( aExt.EqualsIgnoreCaseAscii( "afm" ) )
++ eFormat = AFM;
++ else if( aExt.EqualsIgnoreCaseAscii( "ttf" )
++ || aExt.EqualsIgnoreCaseAscii( "ttc" )
++ || aExt.EqualsIgnoreCaseAscii( "tte" ) ) // #i33947# for Gaiji support
++ eFormat = TRUETYPE;
++ else if( aExt.EqualsIgnoreCaseAscii( "otf" ) ) // check for TTF- and PS-OpenType too
++ eFormat = CFF;
++ }
++
++ if (eFormat == TYPE1)
+ {
+ // check for corresponding afm metric
+ // first look for an adjacent file
+@@ -1352,7 +1379,7 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, co
+ }
+ }
+ }
+- else if( aExt.EqualsIgnoreCaseAscii( "afm" ) )
++ else if (eFormat == AFM)
+ {
+ ByteString aFilePath( aDir );
+ aFilePath.Append( '/' );
+@@ -1365,34 +1392,14 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, co
+ else
+ delete pFont;
+ }
+- else if( aExt.EqualsIgnoreCaseAscii( "ttf" )
+- || aExt.EqualsIgnoreCaseAscii( "tte" ) // #i33947# for Gaiji support
+- || aExt.EqualsIgnoreCaseAscii( "otf" ) ) // check for TTF- and PS-OpenType too
+- {
+- TrueTypeFontFile* pFont = new TrueTypeFontFile();
+- pFont->m_nDirectory = nDirID;
+- pFont->m_aFontFile = rFontFile;
+- pFont->m_nCollectionEntry = -1;
+-
+- if( rXLFDs.size() )
+- getFontAttributesFromXLFD( pFont, rXLFDs );
+- // need to read the font anyway to get aliases inside the font file
+- if( ! analyzeTrueTypeFile( pFont ) )
+- {
+- delete pFont;
+- pFont = NULL;
+- }
+- else
+- rNewFonts.push_back( pFont );
+- }
+- else if( aExt.EqualsIgnoreCaseAscii( "ttc" ) )
++ else if (eFormat == TRUETYPE || eFormat == CFF)
+ {
+ // get number of ttc entries
+ int nLength = CountTTCFonts( aFullPath.getStr() );
+ if( nLength )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+- fprintf( stderr, "%s contains %d fonts\n", aFullPath.getStr(), nLength );
++ fprintf( stderr, "ttc: %s contains %d fonts\n", aFullPath.getStr(), nLength );
+ #endif
+ for( int i = 0; i < nLength; i++ )
+ {
+@@ -1411,10 +1418,24 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, co
+ rNewFonts.push_back( pFont );
+ }
+ }
+-#if OSL_DEBUG_LEVEL > 1
+ else
+- fprintf( stderr, "CountTTCFonts( \"%s/%s\" ) failed\n", getDirectory(nDirID).getStr(), rFontFile.getStr() );
+-#endif
++ {
++ TrueTypeFontFile* pFont = new TrueTypeFontFile();
++ pFont->m_nDirectory = nDirID;
++ pFont->m_aFontFile = rFontFile;
++ pFont->m_nCollectionEntry = -1;
++
++ if( rXLFDs.size() )
++ getFontAttributesFromXLFD( pFont, rXLFDs );
++ // need to read the font anyway to get aliases inside the font file
++ if( ! analyzeTrueTypeFile( pFont ) )
++ {
++ delete pFont;
++ pFont = NULL;
++ }
++ else
++ rNewFonts.push_back( pFont );
++ }
+ }
+ return ! rNewFonts.empty();
+ }
+--
+1.7.6
+
diff --git a/libreoffice.spec b/libreoffice.spec
index 225451c..a254c89 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -152,6 +152,7 @@ Patch63: 0001-Related-rhbz-711087-band-aid.patch
Patch64: 0001-rhbz-667082-do-not-crash-importing-section-containin.patch
Patch65: 0001-Related-rhbz-718976-crash-in-SwTxtSizeInfo-GetMultiC.patch
Patch66: 0001-fix-regression-in-SvGlobalName-operator.patch
+Patch67: 0001-Resolves-rhbz-715549-use-fontconfig-s-detected-forma.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -819,6 +820,7 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch64 -p1 -b .rhbz667082-do-not-crash-importing-section-containin.patch
%patch65 -p1 -b .rhbz718976-crash-in-SwTxtSizeInfo-GetMultiC.patch
%patch66 -p1 -b .fix-regression-in-SvGlobalName-operator.patch
+%patch67 -p1 -b .rhbz715549-use-fontconfig-s-detected-forma.patch
touch scripting/source/pyprov/delzip
touch scripting/util/provider/beanshell/delzip
@@ -2163,8 +2165,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%{basisinstdir}/program/kde-open-url
%changelog
-* Tue Jul 12 2011 Caolán McNamara <caolanm at redhat.com> 1:3.3.3.1-3-UNBUILT
+* Tue Jul 19 2011 Caolán McNamara <caolanm at redhat.com> 1:3.3.3.1-3
- fix regression in SvGlobalName operator
+- Resolves: rhbz#715549 use fontconfig's detected format
* Tue Jul 05 2011 Caolán McNamara <caolanm at redhat.com> 1:3.3.3.1-2
- Resolves: rhbz#713154 pdf export dialog too tall to fit
More information about the scm-commits
mailing list