|
wxMaxima
|
Class representing the font manager. More...
#include <pdffontmanager.h>
Public Member Functions | |
| void | AddSearchPath (const wxString &path) |
| Add a path entry to the font search path list. | |
| void | AddSearchPath (const wxArrayString &pathArray) |
| Add a list of path entries to the font search path list. | |
| bool | SetDefaultEmbed (bool embed) |
| Set the default embedding mode. | |
| bool | GetDefaultEmbed () |
| Get the default embedding mode. | |
| bool | SetDefaultSubset (bool subset) |
| Set the default subsetting mode. | |
| bool | GetDefaultSubset () |
| Get the default subsetting mode. | |
| wxPdfFont | RegisterFont (const wxString &fontFileName, const wxString &aliasName=wxEmptyString, int fontIndex=0) |
| Register a font. | |
| wxPdfFont | RegisterFont (const wxFont &font, const wxString &aliasName=wxEmptyString) |
| Register a font based on a wxFont object. | |
| wxPdfFont | RegisterFont (const char *fontData, size_t fontDataSize, const wxString &aliasName=wxEmptyString) |
| Register a font based on a font data buffer. | |
| int | RegisterFontCollection (const wxString &fontCollectionFileName) |
| Register a font collection. | |
| bool | RegisterFontCJK (const wxString &family) |
| Register a CJK font family. | |
| int | RegisterSystemFonts () |
| Register the fonts known to the operating system. | |
| int | RegisterFontDirectory (const wxString &directory, bool recursive=false) |
| Register all fonts located in a directory. | |
| wxPdfFont | GetFont (const wxString &fontName, int fontStyle=wxPDF_FONTSTYLE_REGULAR) const |
| Get a font by name and style. | |
| wxPdfFont | GetFont (const wxString &fontName, const wxString &fontStyle) const |
| Get a font by name and style. | |
| wxPdfFont | GetFontForWxFont (const wxFont &font) |
| Get the font corresponding to a wxFont object. | |
| wxPdfFont | GetFont (size_t fontIndex) const |
| Get a font by index. | |
| wxPdfFont | FindFallbackFont (wxUint32 unicodeChar, int fontStyle=wxPDF_FONTSTYLE_REGULAR) |
| Find an installed font containing a glyph for a character. | |
| size_t | GetFontCount () const |
| Get the number of registered fonts. | |
| bool | InitializeFontData (const wxPdfFont &font) |
| Initialize the font data of a font. | |
| bool | RegisterEncoding (const wxPdfEncoding &encoding) |
| Register a font encoding. | |
| const wxPdfEncoding * | GetEncoding (const wxString &encodingName) |
| Get the encoding having the given name. | |
| void | SetEmbeddableFontReplacement (const wxString &fontFamily, const wxString &replacementFamily) |
| Set the embeddable replacement for a font family. | |
| wxString | GetEmbeddableFontReplacement (const wxString &fontFamily) const |
| Get the embeddable replacement defined for a font family. | |
| wxPdfFont | GetEmbeddableFont (const wxPdfFont &font, int fontStyle=wxPDF_FONTSTYLE_REGULAR, bool useBuiltInReplacements=true) |
| Get an embeddable version of a font. | |
| wxPdfFont | GetEmbeddableFont (const wxString &fontFamily, int fontStyle=wxPDF_FONTSTYLE_REGULAR) |
| Get an embeddable font by family name and style. | |
Static Public Member Functions | |
| static wxPdfFontManager * | GetFontManager () |
| Get the font manager. | |
Friends | |
| class | wxPdfDocumentModule |
Class representing the font manager.
| void wxPdfFontManager::AddSearchPath | ( | const wxArrayString & | pathArray | ) |
Add a list of path entries to the font search path list.
| pathArray | a list of path entries to add to the search list |
| void wxPdfFontManager::AddSearchPath | ( | const wxString & | path | ) |
Add a path entry to the font search path list.
| path | path to add to the search list |
| wxPdfFont wxPdfFontManager::FindFallbackFont | ( | wxUint32 | unicodeChar, |
| int | fontStyle = wxPDF_FONTSTYLE_REGULAR |
||
| ) |
Find an installed font containing a glyph for a character.
Searches the fonts installed on the system for a font that can show the given character, preferably in the given style. This is the lookup used by wxPdfDocument::SetSystemFontFallback(), but it can also be used directly, for example to build an explicit fallback list with wxPdfDocument::AddFallbackFont().
On wxGTK the fontconfig library is queried (the mechanism Pango uses for its own font fallback). On other platforms a built-in list of well-known font families with a large Unicode coverage is checked (e.g. Segoe UI and Cambria Math on Windows, Lucida Grande and STIX Two Math on macOS, DejaVu Sans and Noto Sans everywhere). A font found is registered with the font manager.
Results, including negative ones, are cached, so repeated lookups are cheap.
| unicodeChar | the Unicode code point of the character |
| fontStyle | the preferred font style (only weight and italic are considered) |
| bool wxPdfFontManager::GetDefaultEmbed | ( | ) |
Get the default embedding mode.
| bool wxPdfFontManager::GetDefaultSubset | ( | ) |
Get the default subsetting mode.
| wxPdfFont wxPdfFontManager::GetEmbeddableFont | ( | const wxPdfFont & | font, |
| int | fontStyle = wxPDF_FONTSTYLE_REGULAR, |
||
| bool | useBuiltInReplacements = true |
||
| ) |
Get an embeddable version of a font.
If the given font can be embedded, a copy of it with embedding enabled is returned. Otherwise an embeddable replacement font with matching style is searched in the following order:
Each candidate family is first searched among the registered fonts. If it is not registered yet, wxPdfDocument tries to locate the font via the operating system (on wxMSW, wxGTK and wxOSX, see RegisterFont(const wxFont&)) and registers it. A system font is only accepted if its family name equals the candidate family, so that a platform specific fallback font is never used silently.
| font | the font to be made embeddable |
| fontStyle | the requested font style (in addition to the style of the font itself) |
| useBuiltInReplacements | flag whether the built-in replacement lists are used; if false, only the replacement defined by SetEmbeddableFontReplacement() is tried |
| wxPdfFont wxPdfFontManager::GetEmbeddableFont | ( | const wxString & | fontFamily, |
| int | fontStyle = wxPDF_FONTSTYLE_REGULAR |
||
| ) |
Get an embeddable font by family name and style.
Like GetEmbeddableFont(const wxPdfFont&, int), but starts from a family name. If no font of that family is registered, the replacements for the family name are tried, and finally wxPdfDocument tries to locate the family itself via the operating system.
| fontFamily | the name of the requested font family |
| fontStyle | the requested font style |
| wxString wxPdfFontManager::GetEmbeddableFontReplacement | ( | const wxString & | fontFamily | ) | const |
Get the embeddable replacement defined for a font family.
| fontFamily | the font family (or family alias) |
| const wxPdfEncoding * wxPdfFontManager::GetEncoding | ( | const wxString & | encodingName | ) |
Get the encoding having the given name.
| encodingName | name of the encoding |
| wxPdfFont wxPdfFontManager::GetFont | ( | const wxString & | fontName, |
| const wxString & | fontStyle | ||
| ) | const |
Get a font by name and style.
Based on the given name and style the list of registered fonts is searched for a matching font. The name is checked whether it represents a font family. If the name is not a family name then the name is checked whether it represents an alias for a font family. If the name is not an alias either the name is checked whether it is a full font name.
| fontName | the name of the requested font |
| fontStyle | the style of the requested font (string representation) |
| wxPdfFont wxPdfFontManager::GetFont | ( | const wxString & | fontName, |
| int | fontStyle = wxPDF_FONTSTYLE_REGULAR |
||
| ) | const |
Get a font by name and style.
Based on the given name and style the list of registered fonts is searched for a matching font. The name is checked whether it represents a font family. If the name is not a family name then the name is checked whether it represents an alias for a font family. If the name is not an alias either the name is checked whether it is a full font name.
| fontName | the name of the requested font |
| fontStyle | the style of the requested font |
| wxPdfFont wxPdfFontManager::GetFont | ( | size_t | fontIndex | ) | const |
Get a font by index.
| fontIndex | the index of the requested font in the list of registered fonts |
| size_t wxPdfFontManager::GetFontCount | ( | ) | const |
Get the number of registered fonts.
| wxPdfFont wxPdfFontManager::GetFontForWxFont | ( | const wxFont & | font | ) |
Get the font corresponding to a wxFont object.
This method is used by wxPdfDocument::SetFont(const wxFont&), wxPdfDC and wxPdfGraphicsContext to map a wxFont to a PDF font.
First a registered font matching the face name and style of the wxFont is searched. If none is registered, the font is located via the operating system and registered (see RegisterFont(const wxFont&)).
If the face name denotes one of the 14 Adobe standard fonts or one of their aliases (for example Arial, Helvetica, Times, Courier or Symbol), the font installed on the system is preferred: a wxFont stands for the font the operating system renders on screen, while the standard fonts support only the WinAnsi character set (Symbol and ZapfDingbats only their own one) and are never embedded. Only if no font can be located via the operating system the standard font is used. The result is cached, so that the operating system is asked only once per face name and style.
| font | the wxFont object |
|
static |
Get the font manager.
| bool wxPdfFontManager::InitializeFontData | ( | const wxPdfFont & | font | ) |
Initialize the font data of a font.
On registering a font the associated font data are not completely loaded into memory to save time and memory resources, but as soon as the font is actually used it must be fully initialized. Usually this method is called automatically.
| font | the font to be initialized |
true if the font could be initialized successfully, false otherwise | bool wxPdfFontManager::RegisterEncoding | ( | const wxPdfEncoding & | encoding | ) |
Register a font encoding.
| encoding | the encoding to be registered |
true if the encoding could be registered successfully | wxPdfFont wxPdfFontManager::RegisterFont | ( | const char * | fontData, |
| size_t | fontDataSize, | ||
| const wxString & | aliasName = wxEmptyString |
||
| ) |
Register a font based on a font data buffer.
Register a font based on a font data buffer for later use in creating a PDF document.
| fontData | the font data buffer holding a TrueType or OpenType font |
| fontDataSize | the size of the font data buffer |
| aliasName | an alias name for the font family (default: no alias) |
| wxPdfFont wxPdfFontManager::RegisterFont | ( | const wxFont & | font, |
| const wxString & | aliasName = wxEmptyString |
||
| ) |
Register a font based on a wxFont object.
Register a font based on a wxFont object for later use in creating a PDF document.
| font | the wxFont object to be registered |
| aliasName | an alias name for the font family (default: no alias) |
| wxPdfFont wxPdfFontManager::RegisterFont | ( | const wxString & | fontFileName, |
| const wxString & | aliasName = wxEmptyString, |
||
| int | fontIndex = 0 |
||
| ) |
Register a font.
Register a font for later use in creating a PDF document.
| fontFileName | the name of the font file (if the name is not fully qualified, it will be searched in font search path) |
| aliasName | an alias name for the font family (default: no alias) |
| fontIndex | the index of the font in a font collection (default: 0) |
| bool wxPdfFontManager::RegisterFontCJK | ( | const wxString & | family | ) |
Register a CJK font family.
Register all fonts from a font collection for later use in creating a PDF document. The following CJK font families are currently known to wxPdfDocument:
| family | the name of the CJK font family |
true if the CJK family could be registered successfully, false otherwise | int wxPdfFontManager::RegisterFontCollection | ( | const wxString & | fontCollectionFileName | ) |
Register a font collection.
Register all fonts from a font collection for later use in creating a PDF document.
| fontCollectionFileName | the name of the font collection file (if the name is not fully qualified, it will be searched in font search path) |
| int wxPdfFontManager::RegisterFontDirectory | ( | const wxString & | directory, |
| bool | recursive = false |
||
| ) |
Register all fonts located in a directory.
| directory | the directory path to be searched for font files |
| recursive | flag whether the search should include subdirectories or not (Default: false) |
| bool wxPdfFontManager::SetDefaultEmbed | ( | bool | embed | ) |
Set the default embedding mode.
Usually it is recommended to enable embedding, since this guarantees that no font substitution takes place on a target system not providing a required font.
The default embedding mode is enabled by default, but the embedding mode can be set for each font individually.
| embed | flag whether to enable or disable embedding |
| bool wxPdfFontManager::SetDefaultSubset | ( | bool | subset | ) |
Set the default subsetting mode.
Usually it is recommended to enable subsetting, since embedding only a font subset reduces the size of the resulting PDF file significantly.
The default subsetting mode is enabled by default, but the subsetting mode can be set for each font individually.
| subset | flag whether to enable or disable font subsetting |
| void wxPdfFontManager::SetEmbeddableFontReplacement | ( | const wxString & | fontFamily, |
| const wxString & | replacementFamily | ||
| ) |
Set the embeddable replacement for a font family.
Some fonts can never be embedded into a PDF document: the 14 Adobe standard fonts (Courier, Helvetica, Times, Symbol and ZapfDingbats), the Adobe CJK fonts, and fonts whose licence does not allow embedding. If a document requests that all fonts are embedded (see wxPdfDocument::SetEmbedAllFonts()), such a font is replaced by an embeddable font family. This method defines which family is used as replacement for a given font family.
Every PDF reader provides the standard fonts, so in embed-all-fonts mode they are only replaced if a replacement was defined with this method, or if the document conforms to PDF/A (which forbids non-embedded fonts).
The replacement family is tried first. If it is not available, the built-in list of metric-compatible free fonts is tried (see GetEmbeddableFont()).
The replacement family should either be registered already (for example with RegisterFont() or RegisterFontDirectory()) or be installed on the system, so that it can be located via the operating system's font services.
| fontFamily | the font family (or family alias) to be replaced, i.e. Helvetica |
| replacementFamily | the family of the embeddable replacement font, i.e. Liberation Sans. An empty string removes a previously defined replacement. |