summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-11-25 09:19:15 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-11-26 14:28:16 +0000
commit30ebc895c95ee66adf172717249aa1789b309eff (patch)
tree3f46db588b44e543a89fd92a07668be3c1146ecc
parent1c3526bfc07cd13636bfb84f5ad45a058ec74415 (diff)
There is one font file type now
Change-Id: I47b6f36de5c77cfdf831a2b3ce10b973159520b1 Reviewed-on: https://gerrit.libreoffice.org/31231 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r--vcl/inc/unx/fontmanager.hxx103
-rw-r--r--vcl/unx/generic/fontmanager/fontcache.cxx123
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx6
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx260
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx58
-rw-r--r--vcl/unx/generic/print/glyphset.cxx26
-rw-r--r--vcl/unx/generic/print/glyphset.hxx2
-rw-r--r--vcl/unx/generic/print/text_gfx.cxx5
8 files changed, 191 insertions, 392 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index a7a2753a2f1c..0a2de15ba3a6 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -53,14 +53,6 @@ class FontSelectPattern;
namespace psp {
class PPDParser;
-namespace fonttype
-{
-enum type {
- Unknown = 0,
- TrueType = 2,
-};
-}
-
/*
* the difference between FastPrintFontInfo and PrintFontInfo
* is that the information in FastPrintFontInfo can usually
@@ -74,7 +66,6 @@ enum type {
struct FastPrintFontInfo
{
fontID m_nID; // FontID
- fonttype::type m_eType;
// font attributes
OUString m_aFamilyName;
@@ -90,7 +81,6 @@ struct FastPrintFontInfo
FastPrintFontInfo()
: m_nID(0)
- , m_eType(fonttype::Unknown)
, m_eFamilyStyle(FAMILY_DONTKNOW)
, m_eItalic(ITALIC_DONTKNOW)
, m_eWidth(WIDTH_DONTKNOW)
@@ -131,16 +121,13 @@ struct CharacterMetric
class FontCache;
// a class to manage printable fonts
-// aims are type1 and truetype fonts
class FontCache;
class VCL_PLUGIN_PUBLIC PrintFontManager
{
struct PrintFont;
- struct TrueTypeFontFile;
friend struct PrintFont;
- friend struct TrueTypeFontFile;
friend class FontCache;
struct PrintFontMetrics
@@ -171,46 +158,37 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
struct PrintFont
{
- fonttype::type m_eType;
-
// font attributes
- int m_nFamilyName; // atom
- std::vector< int > m_aAliases;
- int m_nPSName; // atom
- OUString m_aStyleName;
- FontItalic m_eItalic;
- FontWidth m_eWidth;
- FontWeight m_eWeight;
- FontPitch m_ePitch;
- rtl_TextEncoding m_aEncoding;
- CharacterMetric m_aGlobalMetricX;
- CharacterMetric m_aGlobalMetricY;
- PrintFontMetrics* m_pMetrics;
- int m_nAscend;
- int m_nDescend;
- int m_nLeading;
- int m_nXMin; // font bounding box
- int m_nYMin;
- int m_nXMax;
- int m_nYMax;
- bool m_bHaveVerticalSubstitutedGlyphs;
- bool m_bUserOverride;
-
- explicit PrintFont( fonttype::type eType );
- virtual ~PrintFont();
- virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) = 0;
- };
-
- struct TrueTypeFontFile : public PrintFont
- {
- int m_nDirectory; // atom containing system dependent path
- OString m_aFontFile; // relative to directory
- int m_nCollectionEntry; // 0 for regular fonts, 0 to ... for fonts stemming from collections
- unsigned int m_nTypeFlags; // copyright bits and PS-OpenType flag
-
- TrueTypeFontFile();
- virtual ~TrueTypeFontFile() override;
- virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) override;
+ int m_nFamilyName; // atom
+ std::vector<int> m_aAliases;
+ int m_nPSName; // atom
+ OUString m_aStyleName;
+ FontItalic m_eItalic;
+ FontWidth m_eWidth;
+ FontWeight m_eWeight;
+ FontPitch m_ePitch;
+ rtl_TextEncoding m_aEncoding;
+ CharacterMetric m_aGlobalMetricX;
+ CharacterMetric m_aGlobalMetricY;
+ PrintFontMetrics* m_pMetrics;
+ int m_nAscend;
+ int m_nDescend;
+ int m_nLeading;
+ int m_nXMin; // font bounding box
+ int m_nYMin;
+ int m_nXMax;
+ int m_nYMax;
+ bool m_bHaveVerticalSubstitutedGlyphs;
+ bool m_bUserOverride;
+
+ int m_nDirectory; // atom containing system dependent path
+ OString m_aFontFile; // relative to directory
+ int m_nCollectionEntry; // 0 for regular fonts, 0 to ... for fonts stemming from collections
+ unsigned int m_nTypeFlags; // copyright bits and PS-OpenType flag
+
+ explicit PrintFont();
+ ~PrintFont();
+ bool queryMetricPage(int nPage, utl::MultiAtomProvider* pProvider);
};
fontID m_nNextFontID;
@@ -233,14 +211,14 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
OString getFontFile( PrintFont* pFont ) const;
bool analyzeFontFile( int nDirID, const OString& rFileName, std::list< PrintFont* >& rNewFonts, const char *pFormat=nullptr ) const;
- static OUString convertTrueTypeName( void* pNameRecord ); // actually a NameRecord* formt font subsetting code
- static void analyzeTrueTypeFamilyName( void* pTTFont, std::list< OUString >& rnames ); // actually a TrueTypeFont* from font subsetting code
- bool analyzeTrueTypeFile( PrintFont* pFont ) const;
+ static OUString convertSfntName( void* pNameRecord ); // actually a NameRecord* formt font subsetting code
+ static void analyzeSfntFamilyName( void* pTTFont, std::list< OUString >& rnames ); // actually a TrueTypeFont* from font subsetting code
+ bool analyzeSfntFile(PrintFont* pFont) const;
// finds the font id for the nFaceIndex face in this font file
- // There may be multiple font ids for TrueType collections
+ // There may be multiple font ids for font collections
fontID findFontFileID( int nDirID, const OString& rFile, int nFaceIndex ) const;
- // There may be multiple font ids for TrueType collections
+ // There may be multiple font ids for font collections
std::vector<fontID> findFontFileIDs( int nDirID, const OString& rFile ) const;
static FontFamily matchFamilyName( const OUString& rFamily );
@@ -293,7 +271,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
public:
static PrintFontManager& get(); // one instance only
- // There may be multiple font ids for TrueType collections
+ // There may be multiple font ids for font collections
std::vector<fontID> addFontFile( const OString& rFileName );
void initialize();
@@ -311,13 +289,6 @@ public:
// get a specific fonts PSName name
const OUString& getPSName( fontID nFontID ) const;
- // get a specific fonts type
- fonttype::type getFontType( fontID nFontID ) const
- {
- PrintFont* pFont = getFont( nFontID );
- return pFont ? pFont->m_eType : fonttype::Unknown;
- }
-
// get a specific fonts italic type
FontItalic getFontItalic( fontID nFontID ) const
{
@@ -363,7 +334,7 @@ public:
// the user is responsible to allocate pArray large enough
bool getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray ) const;
- // creates a new font subset of an existing TrueType font
+ // creates a new font subset of an existing SFNT font
// returns true in case of success, else false
// nFont: the font to be subsetted
// rOutFile: the file to put the new subset into;
diff --git a/vcl/unx/generic/fontmanager/fontcache.cxx b/vcl/unx/generic/fontmanager/fontcache.cxx
index 5c6df511e74b..7407efbaab1d 100644
--- a/vcl/unx/generic/fontmanager/fontcache.cxx
+++ b/vcl/unx/generic/fontmanager/fontcache.cxx
@@ -37,7 +37,7 @@
#include <cstdio>
#endif
-#define CACHE_MAGIC "LibreOffice PspFontCacheFile format 7"
+#define CACHE_MAGIC "LibreOffice PspFontCacheFile format 8"
using namespace std;
using namespace psp;
@@ -133,9 +133,7 @@ void FontCache::flush()
aStream.WriteLine(aLine.makeStringAndClear());
int nEntrySize = entry_it->second.m_aEntry.size();
- // write: type;nfonts
- aLine.append(static_cast<sal_Int32>(rEntry.front()->m_eType));
- aLine.append(';');
+ // write: nfonts
aLine.append(static_cast<sal_Int32>(nEntrySize));
aStream.WriteLine(aLine.makeStringAndClear());
@@ -148,7 +146,7 @@ void FontCache::flush()
* fontnr;PSName;italic;weight;width;pitch;encoding;ascend;descend;leading;vsubst;gxw;gxh;gyw;gyh;useroverride;embed;antialias[;{metricfile,typeflags}][;stylename]
*/
if( nEntrySize > 1 )
- nSubEntry = static_cast<const PrintFontManager::TrueTypeFontFile*>(*it)->m_nCollectionEntry;
+ nSubEntry = (*it)->m_nCollectionEntry;
else
nSubEntry = 0;
@@ -200,15 +198,8 @@ void FontCache::flush()
aLine.append(static_cast<sal_Int32>(0));
aLine.append(';');
aLine.append(static_cast<sal_Int32>(0));
-
- switch( (*it)->m_eType )
- {
- case fonttype::TrueType:
- aLine.append(';');
- aLine.append(static_cast<sal_Int32>(static_cast<const PrintFontManager::TrueTypeFontFile*>(*it)->m_nTypeFlags));
- break;
- default: break;
- }
+ aLine.append(';');
+ aLine.append(static_cast<sal_Int32>((*it)->m_nTypeFlags));
if( !(*it)->m_aStyleName.isEmpty() )
{
aLine.append(';');
@@ -308,15 +299,6 @@ void FontCache::read()
const char* pLine = aLine.getStr();
- fonttype::type eType = (fonttype::type)atoi( pLine );
- if( eType != fonttype::TrueType )
- continue;
- while( *pLine && *pLine != ';' )
- pLine++;
- if( *pLine != ';' )
- continue;
-
- pLine++;
sal_Int32 nFonts = atoi( pLine );
for( int n = 0; n < nFonts; n++ )
{
@@ -324,14 +306,7 @@ void FontCache::read()
pLine = aLine.getStr();
int nLen = aLine.getLength();
- PrintFontManager::PrintFont* pFont = nullptr;
- switch( eType )
- {
- case fonttype::TrueType:
- pFont = new PrintFontManager::TrueTypeFontFile();
- break;
- default: break;
- }
+ PrintFontManager::PrintFont* pFont = new PrintFontManager::PrintFont();
sal_Int32 nIndex;
@@ -397,18 +372,11 @@ void FontCache::read()
pFont->m_bUserOverride
= (atoi( pLine + nTokenPos[15] ) != 0);
int nStyleTokenNr = 18;
- switch( eType )
- {
- case fonttype::TrueType:
- static_cast<PrintFontManager::TrueTypeFontFile*>(pFont)->m_nTypeFlags = atoi( pLine + nTokenPos[18] );
- static_cast<PrintFontManager::TrueTypeFontFile*>(pFont)->m_nCollectionEntry = nCollEntry;
- static_cast<PrintFontManager::TrueTypeFontFile*>(pFont)->m_nDirectory = nDir;
- static_cast<PrintFontManager::TrueTypeFontFile*>(pFont)->m_aFontFile = aFile;
- nStyleTokenNr++;
- break;
- break;
- default: break;
- }
+ pFont->m_nTypeFlags = atoi( pLine + nTokenPos[18] );
+ pFont->m_nCollectionEntry = nCollEntry;
+ pFont->m_nDirectory = nDir;
+ pFont->m_aFontFile = aFile;
+ nStyleTokenNr++;
if( nTokens > nStyleTokenNr )
pFont->m_aStyleName = OUString::intern( pLine + nTokenPos[nStyleTokenNr],
nLen - nTokenPos[nStyleTokenNr],
@@ -459,18 +427,10 @@ void FontCache::read()
*/
void FontCache::copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFontManager::PrintFont* pTo )
{
- if( pFrom->m_eType != pTo->m_eType )
- return;
- switch( pFrom->m_eType )
- {
- case fonttype::TrueType:
- static_cast<PrintFontManager::TrueTypeFontFile*>(pTo)->m_nDirectory = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFrom)->m_nDirectory;
- static_cast<PrintFontManager::TrueTypeFontFile*>(pTo)->m_aFontFile = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFrom)->m_aFontFile;
- static_cast<PrintFontManager::TrueTypeFontFile*>(pTo)->m_nCollectionEntry = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFrom)->m_nCollectionEntry;
- static_cast<PrintFontManager::TrueTypeFontFile*>(pTo)->m_nTypeFlags = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFrom)->m_nTypeFlags;
- break;
- default: break;
- }
+ pTo->m_nDirectory = pFrom->m_nDirectory;
+ pTo->m_aFontFile = pFrom->m_aFontFile;
+ pTo->m_nCollectionEntry = pFrom->m_nCollectionEntry;
+ pTo->m_nTypeFlags = pFrom->m_nTypeFlags;
pTo->m_nFamilyName = pFrom->m_nFamilyName;
pTo->m_aStyleName = pFrom->m_aStyleName;
pTo->m_aAliases = pFrom->m_aAliases;
@@ -498,24 +458,11 @@ void FontCache::copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFo
*/
bool FontCache::equalsPrintFont( const PrintFontManager::PrintFont* pLeft, PrintFontManager::PrintFont* pRight )
{
- if( pLeft->m_eType != pRight->m_eType )
- return false;
- switch( pLeft->m_eType )
- {
- case fonttype::TrueType:
- {
- const PrintFontManager::TrueTypeFontFile* pLT = static_cast<const PrintFontManager::TrueTypeFontFile*>(pLeft);
- const PrintFontManager::TrueTypeFontFile* pRT = static_cast<const PrintFontManager::TrueTypeFontFile*>(pRight);
- if( pRT->m_nDirectory != pLT->m_nDirectory ||
- pRT->m_aFontFile != pLT->m_aFontFile ||
- pRT->m_nCollectionEntry != pLT->m_nCollectionEntry ||
- pRT->m_nTypeFlags != pLT->m_nTypeFlags )
- return false;
- }
- break;
- default: break;
- }
- if( pRight->m_nFamilyName != pLeft->m_nFamilyName ||
+ if (pRight->m_nDirectory != pLeft->m_nDirectory ||
+ pRight->m_aFontFile != pLeft->m_aFontFile ||
+ pRight->m_nCollectionEntry != pLeft->m_nCollectionEntry ||
+ pRight->m_nTypeFlags != pLeft->m_nTypeFlags ||
+ pRight->m_nFamilyName != pLeft->m_nFamilyName ||
pRight->m_aStyleName != pLeft->m_aStyleName ||
pRight->m_nPSName != pLeft->m_nPSName ||
pRight->m_eItalic != pLeft->m_eItalic ||
@@ -549,18 +496,8 @@ bool FontCache::equalsPrintFont( const PrintFontManager::PrintFont* pLeft, Print
*/
PrintFontManager::PrintFont* FontCache::clonePrintFont( const PrintFontManager::PrintFont* pOldFont )
{
- PrintFontManager::PrintFont* pFont = nullptr;
- switch( pOldFont->m_eType )
- {
- case fonttype::TrueType:
- pFont = new PrintFontManager::TrueTypeFontFile();
- break;
- default: break;
- }
- if( pFont )
- {
- copyPrintFont( pOldFont, pFont );
- }
+ PrintFontManager::PrintFont* pFont = new PrintFontManager::PrintFont();
+ copyPrintFont( pOldFont, pFont );
return pFont;
}
@@ -595,15 +532,8 @@ void FontCache::updateFontCacheEntry( const PrintFontManager::PrintFont* pFont,
{
OString aFile;
int nDirID = 0;
- switch( pFont->m_eType )
- {
- case fonttype::TrueType:
- nDirID = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFont)->m_nDirectory;
- aFile = static_cast<const PrintFontManager::TrueTypeFontFile*>(pFont)->m_aFontFile;
- break;
- default:
- return;
- }
+ nDirID = pFont->m_nDirectory;
+ aFile = pFont->m_aFontFile;
FontCacheData::const_iterator dir = m_aCache.find( nDirID );
FontDirMap::const_iterator entry;
std::list< PrintFontManager::PrintFont* >::const_iterator font;
@@ -616,10 +546,7 @@ void FontCache::updateFontCacheEntry( const PrintFontManager::PrintFont* pFont,
{
for( font = entry->second.m_aEntry.begin(); font != entry->second.m_aEntry.end(); ++font )
{
- if( (*font)->m_eType == pFont->m_eType &&
- ( (*font)->m_eType != fonttype::TrueType ||
- static_cast<const PrintFontManager::TrueTypeFontFile*>(*font)->m_nCollectionEntry == static_cast<const PrintFontManager::TrueTypeFontFile*>(pFont)->m_nCollectionEntry
- ) )
+ if ((*font)->m_nCollectionEntry == pFont->m_nCollectionEntry)
break;
}
if( font != entry->second.m_aEntry.end() )
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index ea01866cf4a2..538bdba23eae 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -593,8 +593,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS
{
for( std::list< PrintFont* >::iterator it = aFonts.begin(); it != aFonts.end(); ++it )
{
- if( (*it)->m_eType == fonttype::TrueType &&
- static_cast<TrueTypeFontFile*>(*it)->m_nCollectionEntry == nCollectionEntry )
+ if( (*it)->m_nCollectionEntry == nCollectionEntry )
{
pUpdate = *it;
break;
@@ -604,8 +603,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS
// additional entries will be created in the cache
// if this is a new index (that is if the loop above
// ran to the end of the list)
- if( pUpdate->m_eType == fonttype::TrueType ) // sanity check, this should always be the case here
- static_cast<TrueTypeFontFile*>(pUpdate)->m_nCollectionEntry = nCollectionEntry;
+ pUpdate->m_nCollectionEntry = nCollectionEntry;
}
else
{
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 152c01b4a6a1..dbd816efb2dc 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -94,25 +94,27 @@ inline sal_uInt16 getUInt16BE( const sal_uInt8*& pBuffer )
/*
* PrintFont implementations
*/
-PrintFontManager::PrintFont::PrintFont( fonttype::type eType ) :
- m_eType( eType ),
- m_nFamilyName( 0 ),
- m_nPSName( 0 ),
- m_eItalic( ITALIC_DONTKNOW ),
- m_eWidth( WIDTH_DONTKNOW ),
- m_eWeight( WEIGHT_DONTKNOW ),
- m_ePitch( PITCH_DONTKNOW ),
- m_aEncoding( RTL_TEXTENCODING_DONTKNOW ),
- m_pMetrics( nullptr ),
- m_nAscend( 0 ),
- m_nDescend( 0 ),
- m_nLeading( 0 ),
- m_nXMin( 0 ),
- m_nYMin( 0 ),
- m_nXMax( 0 ),
- m_nYMax( 0 ),
- m_bHaveVerticalSubstitutedGlyphs( false ),
- m_bUserOverride( false )
+PrintFontManager::PrintFont::PrintFont()
+: m_nFamilyName(0)
+, m_nPSName(0)
+, m_eItalic(ITALIC_DONTKNOW)
+, m_eWidth(WIDTH_DONTKNOW)
+, m_eWeight(WEIGHT_DONTKNOW)
+, m_ePitch(PITCH_DONTKNOW)
+, m_aEncoding(RTL_TEXTENCODING_DONTKNOW)
+, m_pMetrics(nullptr)
+, m_nAscend(0)
+, m_nDescend(0)
+, m_nLeading(0)
+, m_nXMin(0)
+, m_nYMin(0)
+, m_nXMax(0)
+, m_nYMax(0)
+, m_bHaveVerticalSubstitutedGlyphs(false)
+, m_bUserOverride( false )
+, m_nDirectory(0)
+, m_nCollectionEntry(0)
+, m_nTypeFlags(TYPEFLAG_INVALID)
{
}
@@ -121,18 +123,7 @@ PrintFontManager::PrintFont::~PrintFont()
delete m_pMetrics;
}
-PrintFontManager::TrueTypeFontFile::TrueTypeFontFile()
-: PrintFont( fonttype::TrueType )
-, m_nDirectory( 0 )
-, m_nCollectionEntry( 0 )
-, m_nTypeFlags( TYPEFLAG_INVALID )
-{}
-
-PrintFontManager::TrueTypeFontFile::~TrueTypeFontFile()
-{
-}
-
-bool PrintFontManager::TrueTypeFontFile::queryMetricPage( int nPage, MultiAtomProvider* /*pProvider*/ )
+bool PrintFontManager::PrintFont::queryMetricPage( int nPage, MultiAtomProvider* /*pProvider*/ )
{
bool bSuccess = false;
@@ -365,11 +356,11 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, ::
for( int i = 0; i < nLength; i++ )
{
- TrueTypeFontFile* pFont = new TrueTypeFontFile();
+ PrintFont* pFont = new PrintFont();
pFont->m_nDirectory = nDirID;
pFont->m_aFontFile = rFontFile;
pFont->m_nCollectionEntry = i;
- if( ! analyzeTrueTypeFile( pFont ) )
+ if (!analyzeSfntFile(pFont))
{
delete pFont;
pFont = nullptr;
@@ -380,13 +371,13 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, ::
}
else
{
- TrueTypeFontFile* pFont = new TrueTypeFontFile();
+ PrintFont* pFont = new PrintFont();
pFont->m_nDirectory = nDirID;
pFont->m_aFontFile = rFontFile;
pFont->m_nCollectionEntry = 0;
// need to read the font anyway to get aliases inside the font file
- if( ! analyzeTrueTypeFile( pFont ) )
+ if (!analyzeSfntFile(pFont))
{
delete pFont;
pFont = nullptr;
@@ -411,19 +402,10 @@ fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, i
std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find( *font_it );
if( it == m_aFonts.end() )
continue;
- switch( it->second->m_eType )
- {
- case fonttype::TrueType:
- {
- TrueTypeFontFile* const pFont = static_cast< TrueTypeFontFile* const >((*it).second);
- if( pFont->m_nDirectory == nDirID &&
- pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex )
- nID = it->first;
- }
- break;
- default:
- break;
- }
+ PrintFont* const pFont = (*it).second;
+ if (pFont->m_nDirectory == nDirID &&
+ pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex)
+ nID = it->first;
}
return nID;
@@ -442,25 +424,16 @@ std::vector<fontID> PrintFontManager::findFontFileIDs( int nDirID, const OString
std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find( *font_it );
if( it == m_aFonts.end() )
continue;
- switch( it->second->m_eType )
- {
- case fonttype::TrueType:
- {
- TrueTypeFontFile* const pFont = static_cast< TrueTypeFontFile* const >((*it).second);
- if( pFont->m_nDirectory == nDirID &&
- pFont->m_aFontFile == rFontFile )
- aIds.push_back(it->first);
- }
- break;
- default:
- break;
- }
+ PrintFont* const pFont = (*it).second;
+ if (pFont->m_nDirectory == nDirID &&
+ pFont->m_aFontFile == rFontFile)
+ aIds.push_back(it->first);
}
return aIds;
}
-OUString PrintFontManager::convertTrueTypeName( void* pRecord )
+OUString PrintFontManager::convertSfntName( void* pRecord )
{
NameRecord* pNameRecord = static_cast<NameRecord*>(pRecord);
OUString aValue;
@@ -605,7 +578,7 @@ namespace
}
}
-void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< OUString >& rNames )
+void PrintFontManager::analyzeSfntFamilyName( void* pTTFont, ::std::list< OUString >& rNames )
{
OUString aFamily;
@@ -650,7 +623,7 @@ void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< OU
else
nMatch = 1000;
}
- OUString aName = convertTrueTypeName( pNameRecords + i );
+ OUString aName = convertSfntName( pNameRecords + i );
aSet.insert( aName );
if (aName.isEmpty())
continue;
@@ -672,21 +645,20 @@ void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< OU
return;
}
-bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
+bool PrintFontManager::analyzeSfntFile( PrintFont* pFont ) const
{
bool bSuccess = false;
rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
OString aFile = getFontFile( pFont );
TrueTypeFont* pTTFont = nullptr;
- TrueTypeFontFile* pTTFontFile = static_cast< TrueTypeFontFile* >(pFont);
- if( OpenTTFontFile( aFile.getStr(), pTTFontFile->m_nCollectionEntry, &pTTFont ) == SF_OK )
+ if( OpenTTFontFile( aFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) == SF_OK )
{
TTGlobalFontInfo aInfo;
GetTTGlobalFontInfo( pTTFont, & aInfo );
::std::list< OUString > aNames;
- analyzeTrueTypeFamilyName( pTTFont, aNames );
+ analyzeSfntFamilyName( pTTFont, aNames );
// set family name from XLFD if possible
if( ! pFont->m_nFamilyName )
@@ -702,11 +674,11 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
// poor font does not have a family name
// name it to file name minus the extension
- dotIndex = pTTFontFile->m_aFontFile.lastIndexOf( '.' );
+ dotIndex = pFont->m_aFontFile.lastIndexOf( '.' );
if ( dotIndex == -1 )
- dotIndex = pTTFontFile->m_aFontFile.getLength();
+ dotIndex = pFont->m_aFontFile.getLength();
- pFont->m_nFamilyName = m_pAtoms->getAtom( ATOM_FAMILYNAME, OStringToOUString( pTTFontFile->m_aFontFile.copy( 0, dotIndex ), aEncoding ) );
+ pFont->m_nFamilyName = m_pAtoms->getAtom( ATOM_FAMILYNAME, OStringToOUString( pFont->m_aFontFile.copy( 0, dotIndex ), aEncoding ) );
}
}
for( ::std::list< OUString >::iterator it = aNames.begin(); it != aNames.end(); ++it )
@@ -814,7 +786,7 @@ bool PrintFontManager::analyzeTrueTypeFile( PrintFont* pFont ) const
pFont->m_nYMax = aInfo.yMax;
// get type flags
- pTTFontFile->m_nTypeFlags = (unsigned int)aInfo.typeFlags;
+ pFont->m_nTypeFlags = (unsigned int)aInfo.typeFlags;
// get vertical substitutions flag
pFont->m_bHaveVerticalSubstitutedGlyphs = DoesVerticalSubstitution( pTTFont, 1 );
@@ -941,15 +913,10 @@ void PrintFontManager::initialize()
{
fontID aFont = m_nNextFontID++;
m_aFonts[ aFont ] = *it;
- if( (*it)->m_eType == fonttype::TrueType )
- m_aFontFileToFontID[ static_cast<TrueTypeFontFile*>(*it)->m_aFontFile ].insert( aFont );
-#if OSL_DEBUG_LEVEL > 1
- else
- fprintf(stderr, "Un-cached type '%d'\n", (*it)->m_eType);
+ m_aFontFileToFontID[(*it)->m_aFontFile].insert(aFont);
#if OSL_DEBUG_LEVEL > 2
fprintf( stderr, "adding cached font %d: %s\n", aFont, getFontFileSysPath( aFont ).getStr() );
#endif
-#endif
}
if( ! m_pFontCache->scanAdditionalFiles( aPath ) )
continue;
@@ -1004,7 +971,6 @@ void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& r
{
std::unordered_map< int, FontFamily >::const_iterator style_it =
m_aFamilyTypes.find( pFont->m_nFamilyName );
- rInfo.m_eType = pFont->m_eType;
rInfo.m_aFamilyName = m_pAtoms->getString( ATOM_FAMILYNAME, pFont->m_nFamilyName );
rInfo.m_aStyleName = pFont->m_aStyleName;
rInfo.m_eFamilyStyle = style_it != m_aFamilyTypes.end() ? style_it->second : FAMILY_DONTKNOW;
@@ -1014,7 +980,7 @@ void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& r
rInfo.m_ePitch = pFont->m_ePitch;
rInfo.m_aEncoding = pFont->m_aEncoding;
- rInfo.m_bSubsettable = (pFont->m_eType == fonttype::TrueType); // TODO: rename to SfntType
+ rInfo.m_bSubsettable = true;
rInfo.m_aAliases.clear();
for( int i : pFont->m_aAliases )
@@ -1027,9 +993,7 @@ void PrintFontManager::fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo
! pFont->m_pMetrics || pFont->m_pMetrics->isEmpty()
)
{
- // might be a truetype font not analyzed
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
fillPrintFontInfo( pFont, static_cast< FastPrintFontInfo& >( rInfo ) );
@@ -1069,8 +1033,7 @@ void PrintFontManager::getFontBoundingBox( fontID nFontID, int& xMin, int& yMin,
{
if( pFont->m_nXMin == 0 && pFont->m_nYMin == 0 && pFont->m_nXMax == 0 && pFont->m_nYMax == 0 )
{
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
xMin = pFont->m_nXMin;
yMin = pFont->m_nYMin;
@@ -1083,8 +1046,7 @@ int PrintFontManager::getFontFaceNumber( fontID nFontID ) const
{
int nRet = 0;
PrintFont* pFont = getFont( nFontID );
- if( pFont && pFont->m_eType == fonttype::TrueType )
- nRet = static_cast< TrueTypeFontFile* >(pFont)->m_nCollectionEntry;
+ nRet = pFont->m_nCollectionEntry;
if (nRet < 0)
nRet = 0;
return nRet;
@@ -1159,13 +1121,12 @@ OString PrintFontManager::getFontFile( PrintFont* pFont ) const
{
OString aPath;
- if( pFont && pFont->m_eType == fonttype::TrueType )
+ if (pFont)
{
- TrueTypeFontFile* pTTFont = static_cast< TrueTypeFontFile* >(pFont);
- std::unordered_map< int, OString >::const_iterator it = m_aAtomToDir.find( pTTFont->m_nDirectory );
+ std::unordered_map< int, OString >::const_iterator it = m_aAtomToDir.find(pFont->m_nDirectory);
aPath = it->second;
aPath += "/";
- aPath += pTTFont->m_aFontFile;
+ aPath += pFont->m_aFontFile;
}
return aPath;
}
@@ -1175,8 +1136,7 @@ const OUString& PrintFontManager::getPSName( fontID nFontID ) const
PrintFont* pFont = getFont( nFontID );
if( pFont && pFont->m_nPSName == 0 )
{
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
return m_pAtoms->getString( ATOM_PSNAME, pFont ? pFont->m_nPSName : INVALID_ATOM );
@@ -1187,9 +1147,7 @@ int PrintFontManager::getFontAscend( fontID nFontID ) const
PrintFont* pFont = getFont( nFontID );
if (pFont && pFont->m_nAscend == 0 && pFont->m_nDescend == 0)
{
- // might be a truetype font not yet analyzed
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
return pFont ? pFont->m_nAscend : 0;
}
@@ -1199,9 +1157,7 @@ int PrintFontManager::getFontDescend( fontID nFontID ) const
PrintFont* pFont = getFont( nFontID );
if (pFont && pFont->m_nAscend == 0 && pFont->m_nDescend == 0)
{
- // might be a truetype font not yet analyzed
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
return pFont ? pFont->m_nDescend : 0;
}
@@ -1216,9 +1172,7 @@ bool PrintFontManager::getMetrics( fontID nFontID, const sal_Unicode* pString, i
|| ! pFont->m_pMetrics || pFont->m_pMetrics->isEmpty()
)
{
- // might be a font not yet analyzed
- if( pFont->m_eType == fonttype::TrueType )
- analyzeTrueTypeFile( pFont );
+ analyzeSfntFile(pFont);
}
for( int i = 0; i < nLen; i++ )
@@ -1256,14 +1210,7 @@ bool PrintFontManager::createFontSubset(
if( !pFont )
return false;
- switch( pFont->m_eType )
- {
- case psp::fonttype::TrueType: rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; break;
- default:
- return false;
- }
- if( pFont->m_eType != fonttype::TrueType )
- return false;
+ rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
// reshuffle array of requested glyphs to make sure glyph0==notdef
sal_uInt8 pEnc[256];
@@ -1299,8 +1246,7 @@ bool PrintFontManager::createFontSubset(
const OString aFromFile = getFontFile( pFont );
TrueTypeFont* pTTFont = nullptr; // TODO: rename to SfntFont
- TrueTypeFontFile* pTTFontFile = static_cast< TrueTypeFontFile* >(pFont);
- if( OpenTTFontFile( aFromFile.getStr(), pTTFontFile->m_nCollectionEntry, &pTTFont ) != SF_OK )
+ if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SF_OK )
return false;
// prepare system name for write access for subset file target
@@ -1398,65 +1344,61 @@ void PrintFontManager::getGlyphWidths( fontID nFont,
std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc )
{
PrintFont* pFont = getFont( nFont );
- if( !pFont || pFont->m_eType != fonttype::TrueType )
+ if (!pFont)
return;
- if( pFont->m_eType == fonttype::TrueType )
+ TrueTypeFont* pTTFont = nullptr;
+ OString aFromFile = getFontFile( pFont );
+ if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SF_OK )
+ return;
+ int nGlyphs = GetTTGlyphCount(pTTFont);
+ if (nGlyphs > 0)
{
- TrueTypeFont* pTTFont = nullptr;
- TrueTypeFontFile* pTTFontFile = static_cast< TrueTypeFontFile* >(pFont);
- OString aFromFile = getFontFile( pFont );
- if( OpenTTFontFile( aFromFile.getStr(), pTTFontFile->m_nCollectionEntry, &pTTFont ) != SF_OK )
- return;
- int nGlyphs = GetTTGlyphCount( pTTFont );
- if( nGlyphs > 0 )
+ rWidths.resize(nGlyphs);
+ std::vector<sal_uInt16> aGlyphIds(nGlyphs);
+ for (int i = 0; i < nGlyphs; i++)
+ aGlyphIds[i] = sal_uInt16(i);
+ TTSimpleGlyphMetrics* pMetrics = GetTTSimpleGlyphMetrics(pTTFont,
+ &aGlyphIds[0],
+ nGlyphs,
+ bVertical);
+ if (pMetrics)
{
- rWidths.resize(nGlyphs);
- std::vector<sal_uInt16> aGlyphIds(nGlyphs);
- for( int i = 0; i < nGlyphs; i++ )
- aGlyphIds[i] = sal_uInt16(i);
- TTSimpleGlyphMetrics* pMetrics = GetTTSimpleGlyphMetrics( pTTFont,
- &aGlyphIds[0],
- nGlyphs,
- bVertical );
- if( pMetrics )
- {
- for( int i = 0; i< nGlyphs; i++ )
- rWidths[i] = pMetrics[i].adv;
- free( pMetrics );
- rUnicodeEnc.clear();
- }
+ for (int i = 0; i< nGlyphs; i++)
+ rWidths[i] = pMetrics[i].adv;
+ free(pMetrics);
+ rUnicodeEnc.clear();
+ }
- // fill the unicode map
- // TODO: isn't this map already available elsewhere in the fontmanager?
- const sal_uInt8* pCmapData = nullptr;
- int nCmapSize = 0;
- if( GetSfntTable( pTTFont, O_cmap, &pCmapData, &nCmapSize ) )
+ // fill the unicode map
+ // TODO: isn't this map already available elsewhere in the fontmanager?
+ const sal_uInt8* pCmapData = nullptr;
+ int nCmapSize = 0;
+ if (GetSfntTable(pTTFont, O_cmap, &pCmapData, &nCmapSize))
+ {
+ CmapResult aCmapResult;
+ if (ParseCMAP(pCmapData, nCmapSize, aCmapResult))
{
- CmapResult aCmapResult;
- if( ParseCMAP( pCmapData, nCmapSize, aCmapResult ) )
+ FontCharMapRef xFontCharMap(new FontCharMap(aCmapResult));
+ for (sal_uInt32 cOld = 0;;)
{
- FontCharMapRef xFontCharMap( new FontCharMap(aCmapResult) );
- for( sal_uInt32 cOld = 0;;)
- {
- // get next unicode covered by font
- const sal_uInt32 c = xFontCharMap->GetNextChar( cOld );
- if( c == cOld )
- break;
- cOld = c;
+ // get next unicode covered by font
+ const sal_uInt32 c = xFontCharMap->GetNextChar(cOld);
+ if (c == cOld)
+ break;
+ cOld = c;
#if 1 // TODO: remove when sal_Unicode covers all of unicode
- if( c > (sal_Unicode)~0 )
- break;
+ if (c > (sal_Unicode)~0)
+ break;
#endif
- // get the matching glyph index
- const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex( c );
- // update the requested map
- rUnicodeEnc[ (sal_Unicode)c ] = aGlyphId;
- }
+ // get the matching glyph index
+ const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c);
+ // update the requested map
+ rUnicodeEnc[(sal_Unicode)c] = aGlyphId;
}
}
}
- CloseTTFont( pTTFont );
}
+ CloseTTFont(pTTFont);
}
/// used by online unit tests via dlopen.
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index a0f1314e30e8..7bedffe07dcc 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -914,18 +914,8 @@ FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo
aDFA.SetSymbolFlag( (rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL) );
aDFA.SetSubsettableFlag( rInfo.m_bSubsettable );
aDFA.SetEmbeddableFlag(false);
-
- switch( rInfo.m_eType )
- {
- case psp::fonttype::TrueType:
- aDFA.SetQuality( 512 );
- aDFA.SetBuiltInFontFlag( false );
- break;
- default:
- aDFA.SetQuality( 0 );
- aDFA.SetBuiltInFontFlag( false );
- break;
- }
+ aDFA.SetQuality(512);
+ aDFA.SetBuiltInFontFlag(false);
aDFA.SetOrientationFlag( true );
@@ -970,28 +960,24 @@ void GenPspGraphics::AnnounceFonts( PhysicalFontCollection* pFontCollection, con
{
int nQuality = 0;
- if( aInfo.m_eType == psp::fonttype::TrueType )
+ psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+ OString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) );
+ int nPos = aFileName.lastIndexOf( '_' );
+ if( nPos == -1 || aFileName[nPos+1] == '.' )
+ nQuality += 5;
+ else
{
- // asian type 1 fonts are not known
- psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
- OString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) );
- int nPos = aFileName.lastIndexOf( '_' );
- if( nPos == -1 || aFileName[nPos+1] == '.' )
- nQuality += 5;
- else
+ static const char* pLangBoost = nullptr;
+ static bool bOnce = true;
+ if( bOnce )
{
- static const char* pLangBoost = nullptr;
- static bool bOnce = true;
- if( bOnce )
- {
- bOnce = false;
- pLangBoost = vcl::getLangBoost();
- }
-
- if( pLangBoost )
- if( aFileName.copy( nPos+1, 3 ).equalsIgnoreAsciiCase( pLangBoost ) )
- nQuality += 10;
+ bOnce = false;
+ pLangBoost = vcl::getLangBoost();
}
+
+ if( pLangBoost )
+ if( aFileName.copy( nPos+1, 3 ).equalsIgnoreAsciiCase( pLangBoost ) )
+ nQuality += 10;
}
ImplPspFontData* pFD = new ImplPspFontData( aInfo );
@@ -1127,15 +1113,7 @@ const void* GenPspGraphics::DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs
for (size_t i = 0; i < nLen; ++i)
pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0);
- switch( aFontInfo.m_eType )
- {
- case psp::fonttype::TrueType:
- rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
- break;
- default:
- DoFreeEmbedFontData( pFile, *pDataLen );
- return nullptr;
- }
+ rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF;
return pFile;
}
diff --git a/vcl/unx/generic/print/glyphset.cxx b/vcl/unx/generic/print/glyphset.cxx
index 58b640ab2aa4..7d8ee2edae56 100644
--- a/vcl/unx/generic/print/glyphset.cxx
+++ b/vcl/unx/generic/print/glyphset.cxx
@@ -49,7 +49,6 @@ GlyphSet::GlyphSet (sal_Int32 nFontID, bool bVertical)
mbVertical (bVertical)
{
PrintFontManager &rMgr = PrintFontManager::get();
- meBaseType = rMgr.getFontType (mnFontID);
maBaseName = OUStringToOString (rMgr.getPSName(mnFontID),
RTL_TEXTENCODING_ASCII_US);
mnBaseEncoding = rMgr.getFontEncoding(mnFontID);
@@ -181,20 +180,13 @@ GlyphSet::AddGlyphID (
OString
GlyphSet::GetGlyphSetName (sal_Int32 nGlyphSetID)
{
- if (meBaseType == fonttype::TrueType)
- {
- OStringBuffer aSetName( maBaseName.getLength() + 32 );
- aSetName.append( maBaseName );
- aSetName.append( "FID" );
- aSetName.append( mnFontID );
- aSetName.append( mbVertical ? "VGSet" : "HGSet" );
- aSetName.append( nGlyphSetID );
- return aSetName.makeStringAndClear();
- }
- else
- {
- return maBaseName;
- }
+ OStringBuffer aSetName( maBaseName.getLength() + 32 );
+ aSetName.append( maBaseName );
+ aSetName.append( "FID" );
+ aSetName.append( mnFontID );
+ aSetName.append( mbVertical ? "VGSet" : "HGSet" );
+ aSetName.append( nGlyphSetID );
+ return aSetName.makeStringAndClear();
}
OString
@@ -341,10 +333,6 @@ static void CreatePSUploadableFont( TrueTypeFont* pSrcFont, FILE* pTmpFile,
void
GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAllowType42, std::list< OString >& rSuppliedFonts )
{
- // only for truetype fonts
- if (meBaseType != fonttype::TrueType)
- return;
-
TrueTypeFont *pTTFont;
OString aTTFileName (rGfx.GetFontMgr().getFontFileSysPath(mnFontID));
int nFace = rGfx.GetFontMgr().getFontFaceNumber(mnFontID);
diff --git a/vcl/unx/generic/print/glyphset.hxx b/vcl/unx/generic/print/glyphset.hxx
index 7b0eba90c442..92c67560ee94 100644
--- a/vcl/unx/generic/print/glyphset.hxx
+++ b/vcl/unx/generic/print/glyphset.hxx
@@ -43,7 +43,6 @@ private:
sal_Int32 mnFontID;
bool mbVertical;
OString maBaseName;
- fonttype::type meBaseType;
rtl_TextEncoding mnBaseEncoding;
typedef std::unordered_map< sal_Unicode, sal_uInt8 > char_map_t;
@@ -71,7 +70,6 @@ public:
~GlyphSet ();
sal_Int32 GetFontID () { return mnFontID;}
- fonttype::type GetFontType () { return meBaseType;}
static OString
GetReencodedFontName (rtl_TextEncoding nEnc,
const OString &rFontName);
diff --git a/vcl/unx/generic/print/text_gfx.cxx b/vcl/unx/generic/print/text_gfx.cxx
index eda0f17b76f6..bff561a2bd1c 100644
--- a/vcl/unx/generic/print/text_gfx.cxx
+++ b/vcl/unx/generic/print/text_gfx.cxx
@@ -232,10 +232,7 @@ PrinterGfx::writeResources( osl::File* pFile, std::list< OString >& rSuppliedFon
std::list< GlyphSet >::iterator aIter;
for (aIter = maPS3Font.begin(); aIter != maPS3Font.end(); ++aIter)
{
- if (aIter->GetFontType() == fonttype::TrueType)
- {
- aIter->PSUploadFont (*pFile, *this, mbUploadPS42Fonts, rSuppliedFonts );
- }
+ aIter->PSUploadFont (*pFile, *this, mbUploadPS42Fonts, rSuppliedFonts );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */