|
KiCad PCB EDA Suite
|
#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, const std::vector< wxString > *aEmbeddedFiles=nullptr) |
| 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, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForce=false) |
| List the current available font families. | |
Static Public Member Functions | |
| static wxString | Version () |
| static void | SetReporter (REPORTER *aReporter) |
| Set the reporter to use for reporting font substitution warnings. | |
| static REPORTER * | GetReporter () |
| Get the current reporter used for font substitution warnings. | |
Private Member Functions | |
| bool | isLanguageMatch (const wxString &aSearchLang, const wxString &aSupportedLang) |
| Match 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) |
| Get a list of all family name strings mapped to lang. | |
| std::string | getFamilyStringByLang (FONTCONFIG_PAT &APat, const wxString &aDesiredLang) |
| Get 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, FONTINFO > | m_fontInfoCache |
| wxString | m_fontCacheLastLang |
Static Private Attributes | |
| static REPORTER * | s_reporter = nullptr |
Definition at line 39 of file fontconfig.h.
|
strong |
| Enumerator | |
|---|---|
| FF_OK | |
| FF_ERROR | |
| FF_SUBSTITUTE | |
| FF_MISSING_BOLD | |
| FF_MISSING_ITAL | |
| FF_MISSING_BOLD_ITAL | |
Definition at line 46 of file fontconfig.h.
| FONTCONFIG::FONTCONFIG | ( | ) |
Definition at line 59 of file fontconfig.cpp.
| FONTCONFIG::FF_RESULT FONTCONFIG::FindFont | ( | const wxString & | aFontName, |
| wxString & | aFontFile, | ||
| int & | aFaceIndex, | ||
| bool | aBold, | ||
| bool | aItalic, | ||
| const std::vector< wxString > * | aEmbeddedFiles = nullptr ) |
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 213 of file fontconfig.cpp.
References _, config, FF_ERROR, FF_MISSING_BOLD, FF_MISSING_BOLD_ITAL, FF_MISSING_ITAL, FF_OK, FF_SUBSTITUTE, g_fcInitSuccess, getAllFamilyStrings(), and s_reporter.
Referenced by KIFONT::OUTLINE_FONT::LoadFont().
|
private |
Get a list of all family name strings mapped to lang.
| aPat | reference to FcPattern container |
| aFamStringMap | Map to be populated with key, value pairs representing lang to family name |
Definition at line 164 of file fontconfig.cpp.
References getFcString().
Referenced by FindFont(), and getFamilyStringByLang().
|
private |
Get a family name based on desired language.
This will fallback to English or first available string if no language matching string is found.
| aPat | reference to FcPattern container |
| aDesiredLang | Language to research for (RFC3066 format) |
Definition at line 190 of file fontconfig.cpp.
References From_UTF8(), getAllFamilyStrings(), and isLanguageMatch().
Referenced by ListFonts().
|
private |
Wrapper of FcPatternGetString to return a std::string.
| aPat | reference to FcPattern container |
| aObj | The fontconfig property object like FC_FAMILY, FC_STYLE, etc |
| aIdx | The ith value associated with the property object |
Definition at line 152 of file fontconfig.cpp.
References fontconfig::FONTCONFIG_PAT::pat, and res.
Referenced by getAllFamilyStrings().
|
static |
Get the current reporter used for font substitution warnings.
Definition at line 71 of file fontconfig.cpp.
References g_fontConfigMutex, and s_reporter.
|
private |
Match 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 are nuances to language tags beyond this but font tags will most likely never be more complex than say "zh-CN" or single tag "en".
| aSearchLang | the language being searched for |
| aSupportedLang | the language being offered |
Definition at line 122 of file fontconfig.cpp.
References wxStringSplit().
Referenced by getFamilyStringByLang().
| void FONTCONFIG::ListFonts | ( | std::vector< std::string > & | aFonts, |
| const std::string & | aDesiredLang, | ||
| const std::vector< wxString > * | aEmbeddedFiles = nullptr, | ||
| bool | aForce = false ) |
List the current available font families.
| aDesiredLang | The desired language of font name to report back if available, otherwise it will fallback. |
| aEmbeddedFiles | A list of embedded to use for searching fonts, if nullptr, this is not used |
| aForce | If true, force rebuilding the font cache |
Definition at line 387 of file fontconfig.cpp.
References config, From_UTF8(), g_fcInitSuccess, getFamilyStringByLang(), m_fontCacheLastLang, m_fontInfoCache, and traceFonts.
|
static |
Set the reporter to use for reporting font substitution warnings.
| aReporter | The reporter to use for reporting font substitution warnings. |
Definition at line 64 of file fontconfig.cpp.
References g_fontConfigMutex, and s_reporter.
Referenced by FONTCONFIG_REPORTER_SCOPE::FONTCONFIG_REPORTER_SCOPE(), and FONTCONFIG_REPORTER_SCOPE::~FONTCONFIG_REPORTER_SCOPE().
|
static |
Definition at line 53 of file fontconfig.cpp.
Referenced by KIFONT::VERSION_INFO::FontConfig().
|
private |
Definition at line 93 of file fontconfig.h.
Referenced by ListFonts().
|
private |
Definition at line 92 of file fontconfig.h.
Referenced by ListFonts().
|
staticprivate |
Definition at line 94 of file fontconfig.h.
Referenced by FindFont(), GetReporter(), and SetReporter().