MythTV  master
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
MythFontManager Class Reference

#include <mythfontmanager.h>

Public Member Functions

 MythFontManager ()=default
 
void LoadFonts (const QString &directory, const QString &registeredFor)
 Loads the fonts in font files within the given directory structure. More...
 
void ReleaseFonts (const QString &registeredFor)
 Removes the font references for registeredFor, and unloads the application font if it's no longer in use. More...
 

Static Public Member Functions

static MythFontManagerGetGlobalFontManager (void)
 

Private Member Functions

void LoadFonts (const QString &directory, const QString &registeredFor, int *maxDirs)
 Loads the fonts in font files within the given directory structure. More...
 
void LoadFontsFromDirectory (const QString &directory, const QString &registeredFor)
 Loads fonts from font files in the specified directory. More...
 
void LoadFontFile (const QString &fontPath, const QString &registeredFor)
 Loads fonts from the file specified in fontPath. More...
 
bool RegisterFont (const QString &fontPath, const QString &registeredFor, int fontID=-1)
 Registers the font as being used by registeredFor. More...
 
bool IsFontFileLoaded (const QString &fontPath)
 Checks whether the specified font file has already been loaded. More...
 

Private Attributes

QMutex m_lock
 
FontPathToReference m_fontPathToReference
 

Detailed Description

Definition at line 17 of file mythfontmanager.h.

Constructor & Destructor Documentation

◆ MythFontManager()

MythFontManager::MythFontManager ( )
default

Referenced by GetGlobalFontManager().

Member Function Documentation

◆ LoadFonts() [1/2]

void MythFontManager::LoadFonts ( const QString &  directory,
const QString &  registeredFor 
)

Loads the fonts in font files within the given directory structure.

Scans directory and its subdirectories, up to MAX_DIRS total, looking for TrueType (.ttf) and OpenType (.otf) font files or TrueType font collections (.ttc) and loads the fonts to make them available to the application.

Parameters
directoryThe directory to scan
registeredForThe user of the font. Used with releaseFonts() to unload the font if no longer in use (by any users)
See also
LoadFonts(const QString &, const QString &, int *)

Definition at line 29 of file mythfontmanager.cpp.

Referenced by LoadFonts(), MythThemeBase::MythThemeBase(), and MythThemeBase::Reload().

◆ ReleaseFonts()

void MythFontManager::ReleaseFonts ( const QString &  registeredFor)

Removes the font references for registeredFor, and unloads the application font if it's no longer in use.

Parameters
registeredForThe user of the font, as specified to LoadFonts()

Definition at line 117 of file mythfontmanager.cpp.

Referenced by MythThemeBase::Reload(), and MythThemeBase::~MythThemeBase().

◆ GetGlobalFontManager()

MythFontManager * MythFontManager::GetGlobalFontManager ( void  )
static

Definition at line 279 of file mythfontmanager.cpp.

Referenced by GetGlobalFontManager().

◆ LoadFonts() [2/2]

void MythFontManager::LoadFonts ( const QString &  directory,
const QString &  registeredFor,
int *  maxDirs 
)
private

Loads the fonts in font files within the given directory structure.

Recursively scans all directories under directory looking for TrueType (.ttf) and OpenType (.otf) font files or TrueType font collections (.ttc) and loads the fonts to make them available to the application.

Parameters
directoryThe directory to scan
registeredForThe user of the font. Used with releaseFonts() to unload the font if no longer in use (by any users)
maxDirsThe maximum number of subdirectories to scan

Definition at line 81 of file mythfontmanager.cpp.

◆ LoadFontsFromDirectory()

void MythFontManager::LoadFontsFromDirectory ( const QString &  directory,
const QString &  registeredFor 
)
private

Loads fonts from font files in the specified directory.

Non-recursive function called by the recursive MythFontManager::LoadFonts() function.

Parameters
directoryThe directory to scan
registeredForThe user of the font.

Definition at line 167 of file mythfontmanager.cpp.

Referenced by LoadFonts().

◆ LoadFontFile()

void MythFontManager::LoadFontFile ( const QString &  fontPath,
const QString &  registeredFor 
)
private

Loads fonts from the file specified in fontPath.

Parameters
fontPathThe absolute path to the font file
registeredForThe user of the font.

Definition at line 189 of file mythfontmanager.cpp.

Referenced by LoadFontsFromDirectory().

◆ RegisterFont()

bool MythFontManager::RegisterFont ( const QString &  fontPath,
const QString &  registeredFor,
int  fontID = -1 
)
private

Registers the font as being used by registeredFor.

Parameters
fontPathThe absolute path to the font file
registeredForThe user of the font.
fontIDThe number provided by Qt when the font was registered.

Definition at line 247 of file mythfontmanager.cpp.

Referenced by LoadFontFile().

◆ IsFontFileLoaded()

bool MythFontManager::IsFontFileLoaded ( const QString &  fontPath)
private

Checks whether the specified font file has already been loaded.

Parameters
fontPathThe absolute path to the font file

Definition at line 273 of file mythfontmanager.cpp.

Referenced by LoadFontFile(), and ReleaseFonts().

Member Data Documentation

◆ m_lock

QMutex MythFontManager::m_lock
private

Definition at line 37 of file mythfontmanager.h.

Referenced by LoadFontFile(), and ReleaseFonts().

◆ m_fontPathToReference

FontPathToReference MythFontManager::m_fontPathToReference
private

Definition at line 38 of file mythfontmanager.h.

Referenced by IsFontFileLoaded(), RegisterFont(), and ReleaseFonts().


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