PoDoFo  0.9.4
Public Types | Public Member Functions | List of all members
PoDoFo::PdfFontCache Class Reference

#include <PdfFontCache.h>

Public Types

enum  EFontCreationFlags { eFontCreationFlags_None = 0, eFontCreationFlags_AutoSelectBase14 = 1, eFontCreationFlags_Type1Subsetting = 2 }
 

Public Member Functions

 PdfFontCache (PdfVecObjects *pParent)
 
 PdfFontCache (const PdfFontConfigWrapper &rFontConfig, PdfVecObjects *pParent)
 
 ~PdfFontCache ()
 
void EmptyCache ()
 
PdfFontGetFont (PdfObject *pObject)
 
PdfFontGetFont (const char *pszFontName, bool bBold, bool bItalic, bool bSymbolCharset, bool bEmbedd, EFontCreationFlags eFontCreationFlags=eFontCreationFlags_AutoSelectBase14, const PdfEncoding *const =PdfEncodingFactory::GlobalWinAnsiEncodingInstance(), const char *pszFileName=NULL)
 
PdfFontGetFont (FT_Face face, bool bSymbolCharset, bool bEmbedd, const PdfEncoding *const =PdfEncodingFactory::GlobalWinAnsiEncodingInstance())
 
PdfFontGetDuplicateFontType1 (PdfFont *pFont, const char *pszSuffix)
 
PdfFontGetFontSubset (const char *pszFontName, bool bBold, bool bItalic, bool bSymbolCharset, const PdfEncoding *const =PdfEncodingFactory::GlobalWinAnsiEncodingInstance(), const char *pszFileName=NULL)
 
void EmbedSubsetFonts ()
 
FT_Library GetFontLibrary () const
 
void SetFontConfigWrapper (const PdfFontConfigWrapper &rFontConfig)
 

Detailed Description

This class assists PdfDocument with caching font information.

Additional to font caching, this class is also responsible for font matching.

PdfFont is an actual font that can be used in a PDF file (i.e. it does also font embedding) and PdfFontMetrics provides only metrics informations.

This class is an internal class of PoDoFo and should not be used in user applications

See also
PdfDocument

Member Enumeration Documentation

Flags to control font creation.

Enumerator
eFontCreationFlags_None 

No special settings.

eFontCreationFlags_AutoSelectBase14 

Create automatically a base14 font if the fontname matches one of them.

eFontCreationFlags_Type1Subsetting 

Create subsetted type1-font, which includes only used characters.

Constructor & Destructor Documentation

PoDoFo::PdfFontCache::PdfFontCache ( PdfVecObjects pParent)

Create an empty font cache

Parameters
pParenta PdfVecObjects which is required to create new font objects
PoDoFo::PdfFontCache::PdfFontCache ( const PdfFontConfigWrapper rFontConfig,
PdfVecObjects pParent 
)

Create an empty font cache

Parameters
rFontConfigprovide a handle to fontconfig, as initializing a new fontconfig intance might be time consuming.
pParenta PdfVecObjects which is required to create new font objects
PoDoFo::PdfFontCache::~PdfFontCache ( )

Destroy and empty the font cache

Member Function Documentation

void PoDoFo::PdfFontCache::EmbedSubsetFonts ( )

Embeds all pending subset-fonts

void PoDoFo::PdfFontCache::EmptyCache ( )

Empty the internal font cache. This should be done when ever a new document is created or openened.

PdfFont * PoDoFo::PdfFontCache::GetDuplicateFontType1 ( PdfFont pFont,
const char *  pszSuffix 
)

Get a font with specific id from the cache. If the font does not yet exist, copy from existing type1-font and set id.

Parameters
pFontan existing font
pszSuffixSuffix to add to font-id
Returns
a PdfFont object or NULL if the font could not be created or found.
PdfFont * PoDoFo::PdfFontCache::GetFont ( PdfObject pObject)

Get a font from the cache. If the font does not yet exist, add it to the cache. This font is created from an existing object.

Parameters
pObjecta PdfObject that is a font
Returns
a PdfFont object or NULL if the font could not be created or found.
PdfFont * PoDoFo::PdfFontCache::GetFont ( const char *  pszFontName,
bool  bBold,
bool  bItalic,
bool  bSymbolCharset,
bool  bEmbedd,
EFontCreationFlags  eFontCreationFlags = eFontCreationFlags_AutoSelectBase14,
const PdfEncoding * const  pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
const char *  pszFileName = NULL 
)

Get a font from the cache. If the font does not yet exist, add it to the cache.

Parameters
pszFontNamea valid fontname
bBoldif true search for a bold font
bItalicif true search for an italic font
bSymbolCharsetwhether to use symbol charset, rather than unicode charset
bEmbeddif true a font for embedding into PDF will be created
eFontCreationFlagsspecial flag to specify how fonts should be created
pEncodingthe encoding of the font. The font will not take ownership of this object.
pszFileNameoptional path to a valid font file
Returns
a PdfFont object or NULL if the font could not be created or found.
PdfFont * PoDoFo::PdfFontCache::GetFont ( FT_Face  face,
bool  bSymbolCharset,
bool  bEmbedd,
const PdfEncoding * const  pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance() 
)

Get a font from the cache. If the font does not yet exist, add it to the cache.

Parameters
facea valid freetype font face (will be free'd by PoDoFo)
bSymbolCharsetwhether to use symbol charset, rather than unicode charset
bEmbeddif true a font for embedding into PDF will be created
pEncodingthe encoding of the font. The font will not take ownership of this object.
Returns
a PdfFont object or NULL if the font could not be created or found.
FT_Library PoDoFo::PdfFontCache::GetFontLibrary ( ) const
inline

Returns the font library from font cache

Returns
the internal handle to the freetype library
PdfFont * PoDoFo::PdfFontCache::GetFontSubset ( const char *  pszFontName,
bool  bBold,
bool  bItalic,
bool  bSymbolCharset,
const PdfEncoding * const  pEncoding = PdfEncodingFactory::GlobalWinAnsiEncodingInstance(),
const char *  pszFileName = NULL 
)

Get a fontsubset from the cache. If the font does not yet exist, add it to the cache.

Parameters
pszFontNamea valid fontname
bBoldif true search for a bold font
bItalicif true search for an italic font
bSymbolCharsetwhether to use symbol charset, rather than unicode charset
pEncodingthe encoding of the font. All characters of the encoding will be included in this subset. The font will not take ownership of this object.
pszFileNameoptional path to a valid font file
Returns
a PdfFont object or NULL if the font could not be created or found.
void PoDoFo::PdfFontCache::SetFontConfigWrapper ( const PdfFontConfigWrapper rFontConfig)
inline

Set wrapper for the fontconfig library. Useful to avoid initializing Fontconfig multiple times.

This setter can be called until first use of Fontconfig as the library is initialized at first use.