KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fontconfig::FONTCONFIG Class Reference

#include <fontconfig.h>

Public Types

enum class  FF_RESULT {
  FF_OK , FF_ERROR , FF_SUBSTITUTE , FF_MISSING_BOLD ,
  FF_MISSING_ITAL , FF_MISSING_BOLD_ITAL
}
 

Public Member Functions

 FONTCONFIG ()
 
FF_RESULT FindFont (const wxString &aFontName, wxString &aFontFile, int &aFaceIndex, bool aBold, bool aItalic)
 Given a fully-qualified font name ("Times:Bold:Italic") find the closest matching font and return its filepath in aFontFile.
 
void ListFonts (std::vector< std::string > &aFonts, const std::string &aDesiredLang)
 List the current available font families.
 

Static Public Member Functions

static wxString Version ()
 

Private Member Functions

bool isLanguageMatch (const wxString &aSearchLang, const wxString &aSupportedLang)
 Matches the two rfc 3306 language entries, used for when searching for matching family names.
 
void getAllFamilyStrings (FONTCONFIG_PAT &aPat, std::unordered_map< std::string, std::string > &aFamStringMap)
 Gets a list of all family name strings maped to lang.
 
std::string getFamilyStringByLang (FONTCONFIG_PAT &APat, const wxString &aDesiredLang)
 Gets a family name based on desired language.
 
std::string getFcString (FONTCONFIG_PAT &aPat, const char *aObj, int aIdx)
 Wrapper of FcPatternGetString to return a std::string.
 

Private Attributes

std::map< std::string, FONTINFOm_fontInfoCache
 
wxString m_fontCacheLastLang
 

Detailed Description

Definition at line 38 of file fontconfig.h.

Member Enumeration Documentation

◆ FF_RESULT

Enumerator
FF_OK 
FF_ERROR 
FF_SUBSTITUTE 
FF_MISSING_BOLD 
FF_MISSING_ITAL 
FF_MISSING_BOLD_ITAL 

Definition at line 45 of file fontconfig.h.

Constructor & Destructor Documentation

◆ FONTCONFIG()

FONTCONFIG::FONTCONFIG ( )

Definition at line 55 of file fontconfig.cpp.

Member Function Documentation

◆ FindFont()

FONTCONFIG::FF_RESULT FONTCONFIG::FindFont ( const wxString &  aFontName,
wxString &  aFontFile,
int &  aFaceIndex,
bool  aBold,
bool  aItalic 
)

Given a fully-qualified font name ("Times:Bold:Italic") find the closest matching font and return its filepath in aFontFile.

A return value of false indicates a serious error in the font system.

Definition at line 190 of file fontconfig.cpp.

References _, FF_ERROR, FF_MISSING_BOLD, FF_MISSING_BOLD_ITAL, FF_MISSING_ITAL, FF_OK, FF_SUBSTITUTE, g_fcInitSuccess, and getAllFamilyStrings().

◆ getAllFamilyStrings()

void FONTCONFIG::getAllFamilyStrings ( FONTCONFIG_PAT aPat,
std::unordered_map< std::string, std::string > &  aFamStringMap 
)
private

Gets a list of all family name strings maped to lang.

Parameters
aPatreference to FcPattern container
aFamStringMapMap to be populated with key, value pairs representing lang to family name

Definition at line 144 of file fontconfig.cpp.

References getFcString().

Referenced by FindFont(), and getFamilyStringByLang().

◆ getFamilyStringByLang()

std::string FONTCONFIG::getFamilyStringByLang ( FONTCONFIG_PAT APat,
const wxString &  aDesiredLang 
)
private

Gets a family name based on desired language.

This will fallback to english or first available string if no language matching string is found.

Parameters
aPatreference to FcPattern container
aDesiredLangLanguage to research for (RFC3066 format)

Definition at line 167 of file fontconfig.cpp.

References From_UTF8(), getAllFamilyStrings(), and isLanguageMatch().

Referenced by ListFonts().

◆ getFcString()

std::string FONTCONFIG::getFcString ( FONTCONFIG_PAT aPat,
const char *  aObj,
int  aIdx 
)
private

Wrapper of FcPatternGetString to return a std::string.

Parameters
aPatreference to FcPattern container
aObjThe fontconfig property object like FC_FAMILY, FC_STYLE, etc
aIdxThe ith value associated with the property object

Definition at line 132 of file fontconfig.cpp.

References fontconfig::FONTCONFIG_PAT::pat, and res.

Referenced by getAllFamilyStrings().

◆ isLanguageMatch()

bool FONTCONFIG::isLanguageMatch ( const wxString &  aSearchLang,
const wxString &  aSupportedLang 
)
private

Matches the two rfc 3306 language entries, used for when searching for matching family names.

The overall logic is simple, either both language tags matched exactly or one tag is "single" level that the other language tag contains. There's nuances to language tags beyond this but font tags will most likely never be more complex than say "zh-CN" or single tag "en".

Parameters
aSearchLangthe language being searched for
aSupportedLangthe language being offered

Definition at line 102 of file fontconfig.cpp.

References wxStringSplit().

Referenced by getFamilyStringByLang().

◆ ListFonts()

void FONTCONFIG::ListFonts ( std::vector< std::string > &  aFonts,
const std::string &  aDesiredLang 
)

List the current available font families.

Parameters
aDesiredLangThe desired language of font name to report back if available, otherwise it will fallback

Definition at line 333 of file fontconfig.cpp.

References From_UTF8(), g_fcInitSuccess, getFamilyStringByLang(), m_fontCacheLastLang, m_fontInfoCache, and traceFonts.

◆ Version()

wxString FONTCONFIG::Version ( )
static

Definition at line 49 of file fontconfig.cpp.

Referenced by KIFONT::VERSION_INFO::FontConfig().

Member Data Documentation

◆ m_fontCacheLastLang

wxString fontconfig::FONTCONFIG::m_fontCacheLastLang
private

Definition at line 72 of file fontconfig.h.

Referenced by ListFonts().

◆ m_fontInfoCache

std::map<std::string, FONTINFO> fontconfig::FONTCONFIG::m_fontInfoCache
private

Definition at line 71 of file fontconfig.h.

Referenced by ListFonts().


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