LibreOffice Module vcl (master)  1
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
FreetypeManager Class Referencefinal

The FreetypeManager caches various aspects of Freetype fonts. More...

#include <glyphcache.hxx>

Collaboration diagram for FreetypeManager:
[legend]

Classes

struct  IFSD_Equal
 
struct  IFSD_Hash
 

Public Member Functions

 ~FreetypeManager ()
 
void AddFontFile (const OString &rNormalizedName, int nFaceNum, int nVariantNum, sal_IntPtr nFontId, const FontAttributes &)
 
void AnnounceFonts (PhysicalFontCollection *) const
 
FreetypeFontCacheFont (LogicalFontInstance *pFontInstance)
 
void UncacheFont (FreetypeFont &)
 
void TryGarbageCollectFont (LogicalFontInstance *)
 Try to GarbageCollect an explicit logical font. More...
 
void ClearFontCache ()
 
void ClearFontOptions ()
 

Static Public Member Functions

static FreetypeManagerget ()
 

Private Types

typedef std::unordered_map< rtl::Reference< LogicalFontInstance >, std::unique_ptr< FreetypeFont >, IFSD_Hash, IFSD_EqualFontList
 
typedef std::unordered_map< sal_IntPtr, std::unique_ptr< FreetypeFontInfo > > FontInfoList
 
typedef std::unordered_map< const char *, std::unique_ptr< FreetypeFontFile >, rtl::CStringHash, rtl::CStringEqual > FontFileList
 

Private Member Functions

 FreetypeManager ()
 
void GarbageCollect ()
 
FreetypeFontCreateFont (LogicalFontInstance *pLogicalFont)
 
FreetypeFontFileFindFontFile (const OString &rNativeFileName)
 

Static Private Member Functions

static void InitFreetype ()
 

Private Attributes

FontList maFontList
 
sal_uLong mnBytesUsed
 
FreetypeFontmpCurrentGCFont
 
FontInfoList m_aFontInfoList
 
sal_IntPtr m_nMaxFontId
 
FontFileList m_aFontFileList
 

Static Private Attributes

static constexpr sal_uLong gnMaxSize = 1500000
 

Friends

class GenericUnixSalData
 

Detailed Description

The FreetypeManager caches various aspects of Freetype fonts.

It mainly consists of three std::unordered_map lists, which hold the items of the cache.

They form kind of a tree, with FreetypeFontFile as the roots, referenced by multiple FreetypeFontInfo entries, which are referenced by the FreetypeFont items.

All of these items have reference counters, but these don't control the items life-cycle, but that of the managed resources.

The respective resources are: FreetypeFontFile = holds the mmapped font file, as long as it's used by any FreetypeFontInfo. FreetypeFontInfo = holds the FT_FaceRec_ object, as long as it's used by any FreetypeFont. FreetypeFont = holds the FT_SizeRec_.

FreetypeFontInfo therefore is embedded in the Freetype subclass of PhysicalFontFace. FreetypeFont is embedded in the Freetype subclass of LogicalFontInstance.

Nowadays there is not really a reason to have separate files for the classes, as the FreetypeManager is just about handling of Freetype based fonts, not some abstract glyphs.

One additional note: the byte-size based garbage collection of unused fonts can currently be assumed to be broken. Since the move of the glyph rect cache into the ImplFontCache, so it can be used by all platforms, it just takes too long to kick-in, as there is no real accounting left.

Definition at line 78 of file glyphcache.hxx.

Member Typedef Documentation

typedef std::unordered_map<const char*, std::unique_ptr<FreetypeFontFile>, rtl::CStringHash, rtl::CStringEqual> FreetypeManager::FontFileList
private

Definition at line 126 of file glyphcache.hxx.

typedef std::unordered_map<sal_IntPtr, std::unique_ptr<FreetypeFontInfo> > FreetypeManager::FontInfoList
private

Definition at line 125 of file glyphcache.hxx.

typedef std::unordered_map<rtl::Reference<LogicalFontInstance>,std::unique_ptr<FreetypeFont>,IFSD_Hash,IFSD_Equal > FreetypeManager::FontList
private

Definition at line 124 of file glyphcache.hxx.

Constructor & Destructor Documentation

FreetypeManager::~FreetypeManager ( )
FreetypeManager::FreetypeManager ( )
explicitprivate

Member Function Documentation

void FreetypeManager::AddFontFile ( const OString &  rNormalizedName,
int  nFaceNum,
int  nVariantNum,
sal_IntPtr  nFontId,
const FontAttributes  
)
void FreetypeManager::AnnounceFonts ( PhysicalFontCollection ) const
FreetypeFont* FreetypeManager::CacheFont ( LogicalFontInstance pFontInstance)
void FreetypeManager::ClearFontCache ( )
void FreetypeManager::ClearFontOptions ( )
FreetypeFont* FreetypeManager::CreateFont ( LogicalFontInstance pLogicalFont)
private
FreetypeFontFile* FreetypeManager::FindFontFile ( const OString &  rNativeFileName)
private
void FreetypeManager::GarbageCollect ( )
private
static FreetypeManager& FreetypeManager::get ( )
static
static void FreetypeManager::InitFreetype ( )
staticprivate
void FreetypeManager::TryGarbageCollectFont ( LogicalFontInstance )

Try to GarbageCollect an explicit logical font.

This should just be called from the ~ImplFontCache destructor, which holds the mapping of the FontSelectPattern to the LogicalFontInstance per OutputDevice. All other users should just call CacheFont and UncacheFont correctly. When the ImplFontCache is destroyed with its OutputDevice, we can safely garbage collection its unused entries, as these can't be reused.

It's always safe to call this, as it just ignores the used bytes when considering a font for garbage collection, which normally keeps unreferenced fonts alive.

Referenced by ImplFontCache::~ImplFontCache().

void FreetypeManager::UncacheFont ( FreetypeFont )

Friends And Related Function Documentation

friend class GenericUnixSalData
friend

Definition at line 112 of file glyphcache.hxx.

Member Data Documentation

constexpr sal_uLong FreetypeManager::gnMaxSize = 1500000
staticprivate

Definition at line 129 of file glyphcache.hxx.

FontFileList FreetypeManager::m_aFontFileList
private

Definition at line 136 of file glyphcache.hxx.

FontInfoList FreetypeManager::m_aFontInfoList
private

Definition at line 133 of file glyphcache.hxx.

sal_IntPtr FreetypeManager::m_nMaxFontId
private

Definition at line 134 of file glyphcache.hxx.

FontList FreetypeManager::maFontList
private

Definition at line 128 of file glyphcache.hxx.

sal_uLong FreetypeManager::mnBytesUsed
mutableprivate

Definition at line 130 of file glyphcache.hxx.

Referenced by FreetypeFont::GetByteCount().

FreetypeFont* FreetypeManager::mpCurrentGCFont
private

Definition at line 131 of file glyphcache.hxx.


The documentation for this class was generated from the following file: