summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/fontmanager.hxx2
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx12
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx81
3 files changed, 62 insertions, 33 deletions
diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
index 145c4d0a2169..467297668b5a 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 66faa526872c..38a5e93e56f3 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 1427daedb193..8936df327aeb 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();
}