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. | |
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, 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 200 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(), REPORTER::Report(), and s_reporter.
|
private |
Gets a list of all family name strings maped to lang.
aPat | reference to FcPattern container |
aFamStringMap | Map to be populated with key, value pairs representing lang to family name |
Definition at line 154 of file fontconfig.cpp.
References getFcString().
Referenced by FindFont(), and getFamilyStringByLang().
|
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.
aPat | reference to FcPattern container |
aDesiredLang | Language to research for (RFC3066 format) |
Definition at line 177 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 142 of file fontconfig.cpp.
References fontconfig::FONTCONFIG_PAT::pat, and res.
Referenced by getAllFamilyStrings().
|
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".
aSearchLang | the language being searched for |
aSupportedLang | the language being offered |
Definition at line 112 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 371 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 s_reporter.
Referenced by SCH_IO_KICAD_SEXPR::cacheLib(), PCB_IO_EAGLE::cacheLib(), SCH_IO_EAGLE::ensureLoadedLibrary(), PCB_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary(), SCH_IO_ALTIUM::ensureLoadedLibrary(), SCH_IO_CADSTAR_ARCHIVE::ensureLoadedLibrary(), SCH_IO_EASYEDA::EnumerateSymbolLib(), PCB_IO_EASYEDA::FootprintLoad(), PCB_IO_EASYEDAPRO::FootprintLoad(), PCB_IO_GEDA::FootprintLoad(), PCB_IO_KICAD_SEXPR::FootprintLoad(), PCB_IO_KICAD_SEXPR::ImportFootprint(), PCB_IO_ALTIUM_DESIGNER::loadAltiumLibrary(), PCB_IO_ALTIUM_CIRCUIT_STUDIO::LoadBoard(), PCB_IO_ALTIUM_CIRCUIT_MAKER::LoadBoard(), PCB_IO_ALTIUM_DESIGNER::LoadBoard(), PCB_IO_SOLIDWORKS::LoadBoard(), PCB_IO_CADSTAR_ARCHIVE::LoadBoard(), PCB_IO_EAGLE::LoadBoard(), PCB_IO_EASYEDA::LoadBoard(), PCB_IO_EASYEDAPRO::LoadBoard(), PCB_IO_KICAD_SEXPR::LoadBoard(), SCH_IO_ALTIUM::LoadSchematicFile(), SCH_IO_CADSTAR_ARCHIVE::LoadSchematicFile(), SCH_IO_EAGLE::LoadSchematicFile(), SCH_IO_EASYEDA::LoadSchematicFile(), SCH_IO_EASYEDAPRO::LoadSchematicFile(), SCH_IO_KICAD_SEXPR::LoadSchematicFile(), and PCB_IO_KICAD_SEXPR::validateCache().
|
static |
Definition at line 53 of file fontconfig.cpp.
Referenced by KIFONT::VERSION_INFO::FontConfig().
|
private |
Definition at line 84 of file fontconfig.h.
Referenced by ListFonts().
|
private |
Definition at line 83 of file fontconfig.h.
Referenced by ListFonts().
|
staticprivate |
Definition at line 85 of file fontconfig.h.
Referenced by FindFont().