OpenCPN Partial API docs
|
Manages the font list. More...
#include <FontMgr.h>
Public Member Functions | |
void | SetLocale (wxString &newLocale) |
wxFont * | GetFont (const wxString &TextElement, int requested_font_size=0) |
Gets a font object for a UI element. | |
wxColour | GetFontColor (const wxString &TextElement) const |
Gets the text color for a UI element. | |
wxColour | GetDefaultFontColor (const wxString &TextElement) |
Gets the default text color for a UI element. | |
bool | SetFontColor (const wxString &TextElement, const wxColour color) const |
Sets the text color for a UI element. | |
int | GetNumFonts (void) const |
Gets the total number of font configurations currently loaded. | |
const wxString & | GetConfigString (int i) const |
Gets the locale-specific configuration key for a font at index i. | |
const wxString & | GetDialogString (int i) const |
Gets the UI element identifier string for the font at index i. | |
wxArrayString | GetDialogStrings (const wxString &locale=wxEmptyString) const |
Gets the list of unique dialog strings. | |
const wxString & | GetNativeDesc (int i) const |
Gets the native font descriptor string for the font at index i. | |
wxString | GetFullConfigDesc (int i) const |
Gets description of font at index i. | |
wxArrayString & | GetAuxKeyArray () |
Gets array of plugin-defined font configuration keys. | |
bool | AddAuxKey (wxString key) |
Adds new plugin-defined font configuration key. | |
void | LoadFontNative (wxString *pConfigString, wxString *pNativeDesc) |
Loads font settings from a string descriptor. | |
bool | SetFont (const wxString &TextElement, wxFont *pFont, wxColour color) |
Sets the default font properties for a UI element. | |
void | ScrubList () |
Cleans up stale font entries after a locale change. | |
MyFontDesc * | FindFontByConfigString (wxString pConfigString) |
Finds font descriptor by its configuration key. | |
wxFont * | FindOrCreateFont (int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT) |
Creates or finds a matching font in the font cache. | |
wxFont * | FindOrCreateFont (int pointSize, int family, int style, int weight, bool underline=false, const wxString &face=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT) |
bool | ResetFontToDefault (const wxString &TextElement) |
Resets the font configuration for a UI element back to system defaults. | |
Static Public Member Functions | |
static FontMgr & | Get () |
static wxString | GetFontConfigKey (const wxString &description) |
Creates configuration key from UI element name by combining locale with hash. | |
static void | Shutdown () |
bool FontMgr::AddAuxKey | ( | wxString | key | ) |
Adds new plugin-defined font configuration key.
Allows plugins to register their UI elements for font configuration. Each element must have a unique identifier.
key | New plugin UI element identifier to add |
Definition at line 668 of file FontMgr.cpp.
MyFontDesc * FontMgr::FindFontByConfigString | ( | wxString | pConfigString | ) |
Finds font descriptor by its configuration key.
pConfigString | Key in "locale-hash" format |
Definition at line 376 of file FontMgr.cpp.
wxFont * FontMgr::FindOrCreateFont | ( | int | point_size, |
wxFontFamily | family, | ||
wxFontStyle | style, | ||
wxFontWeight | weight, | ||
bool | underline = false , |
||
const wxString & | facename = wxEmptyString , |
||
wxFontEncoding | encoding = wxFONTENCODING_DEFAULT |
||
) |
Creates or finds a matching font in the font cache.
If a font with the specified characteristics exists in the cache, returns that font. Otherwise, creates a new font, adds it to the cache and returns it.
point_size | Font size in points. |
family | Font family like wxFONTFAMILY_SWISS. |
style | Font style like wxFONTSTYLE_NORMAL. |
weight | Font weight like wxFONTWEIGHT_NORMAL. |
underline | True to underline the font. |
facename | Name of the font face, empty for default. |
encoding | Font encoding, wxFONTENCODING_DEFAULT for default. |
Definition at line 450 of file FontMgr.cpp.
|
inline |
|
static |
Definition at line 83 of file FontMgr.cpp.
|
inline |
Gets array of plugin-defined font configuration keys.
Plugins can add their own UI elements requiring font configuration beyond the standard elements defined in FontCandidates[] (like "AISTargetAlert", "StatusBar"). These plugin-specific keys allow plugins to participate in OpenCPN's font management system.
const wxString & FontMgr::GetConfigString | ( | int | i | ) | const |
Gets the locale-specific configuration key for a font at index i.
Used to store and retrieve font configurations by combining the current locale with a hash of the font's text element name (e.g. "AISTargetAlert", "StatusBar").
For example, given a text element "Dialog" in French locale "fr_FR", the returned key might be "fr_FR-a7b9c123" where a7b9c123 is the hash of "Dialog".
i | Font index between 0 and GetNumFonts()-1 |
Definition at line 327 of file FontMgr.cpp.
wxColour FontMgr::GetDefaultFontColor | ( | const wxString & | TextElement | ) |
Gets the default text color for a UI element.
Returns predefined defaults for certain elements like Console Legend (green), Marks (black). Falls back to system window text color if no special default. On macOS, always returns black to support light/dark mode.
TextElement | UI element identifier |
Definition at line 265 of file FontMgr.cpp.
const wxString & FontMgr::GetDialogString | ( | int | i | ) | const |
Gets the UI element identifier string for the font at index i.
Returns the human-readable identifier like "AISTargetAlert" or "StatusBar" used to reference this font in the UI.
i | Font index between 0 and GetNumFonts()-1 |
Definition at line 332 of file FontMgr.cpp.
wxArrayString FontMgr::GetDialogStrings | ( | const wxString & | locale = wxEmptyString | ) | const |
Gets the list of unique dialog strings.
locale | If provided, only returns strings for this locale. |
Definition at line 337 of file FontMgr.cpp.
wxFont * FontMgr::GetFont | ( | const wxString & | TextElement, |
int | requested_font_size = 0 |
||
) |
Gets a font object for a UI element.
Each UI element (like "AISTargetAlert", "StatusBar") has a font configuration. Returns existing font if found, otherwise creates a new one using system defaults or user preferences.
Supported TextElements: AISTargetAlert, AISTargetQuery, StatusBar, AIS Target Name, ObjectQuery, RouteLegInfoRollover, ExtendedTideIcon, CurrentValue, Console Legend, Console Value, AISRollover, TideCurrentGraphRollover, Marks, ChartTexts, ToolTips, Dialog, Menu, GridText
TextElement | UI element identifier (e.g., "AISTargetAlert", "StatusBar") |
requested_font_size | Requested font size in points, 0 to use system/user default |
Definition at line 186 of file FontMgr.cpp.
wxColour FontMgr::GetFontColor | ( | const wxString & | TextElement | ) | const |
Gets the text color for a UI element.
Looks up stored color for the element. Returns black if not found.
TextElement | UI element identifier |
Definition at line 117 of file FontMgr.cpp.
|
static |
Creates configuration key from UI element name by combining locale with hash.
description | UI element name to hash (e.g. "AISTargetAlert") |
Definition at line 132 of file FontMgr.cpp.
wxString FontMgr::GetFullConfigDesc | ( | int | i | ) | const |
Gets description of font at index i.
i | Font index between 0 and GetNumFonts()-1 |
Definition at line 362 of file FontMgr.cpp.
const wxString & FontMgr::GetNativeDesc | ( | int | i | ) | const |
Gets the native font descriptor string for the font at index i.
Returns platform-specific complete font specification string that can be used to recreate the exact font. Contains size, family, style, weight and other attributes. Format varies by platform.
i | Font index between 0 and GetNumFonts()-1 |
Definition at line 357 of file FontMgr.cpp.
int FontMgr::GetNumFonts | ( | void | ) | const |
Gets the total number of font configurations currently loaded.
Each configuration defines the font and color for a specific UI element like "AISTargetAlert" in a specific locale.
Definition at line 325 of file FontMgr.cpp.
void FontMgr::LoadFontNative | ( | wxString * | pConfigString, |
wxString * | pNativeDesc | ||
) |
Loads font settings from a string descriptor.
[in] | pConfigString | Lookup key in "locale-hash" format to find font config |
[in] | pNativeDesc | Font settings to load, format: "TextElement:NativeFontString:rgb(r,g,b)" where:
|
Updates the font configuration in m_fontlist matching pConfigString with the settings from pNativeDesc. Creates new entry if not found.
Definition at line 392 of file FontMgr.cpp.
bool FontMgr::ResetFontToDefault | ( | const wxString & | TextElement | ) |
Resets the font configuration for a UI element back to system defaults.
This function:
TextElement | The UI element identifier (e.g. "AISTargetAlert"). |
Definition at line 676 of file FontMgr.cpp.
void FontMgr::ScrubList | ( | ) |
Cleans up stale font entries after a locale change.
The function preserves customized font settings while removing outdated entries that might reference old translations.
Definition at line 565 of file FontMgr.cpp.
bool FontMgr::SetFont | ( | const wxString & | TextElement, |
wxFont * | pFont, | ||
wxColour | color | ||
) |
Sets the default font properties for a UI element.
Updates the font and color of the default font entry for the given TextElement. Creates a copy of the provided font to avoid memory management issues. Only affects the default font entry - specific size variants are unchanged.
TextElement | UI element identifier (e.g., "AISTargetAlert") |
pFont | New font to use |
color | New text color |
Definition at line 305 of file FontMgr.cpp.
bool FontMgr::SetFontColor | ( | const wxString & | TextElement, |
const wxColour | color | ||
) | const |
Sets the text color for a UI element.
Updates stored color for the element in the current locale.
TextElement | UI element identifier |
color | New text color to set |
Definition at line 122 of file FontMgr.cpp.
void FontMgr::SetLocale | ( | wxString & | newLocale | ) |
Definition at line 115 of file FontMgr.cpp.
|
static |
Definition at line 88 of file FontMgr.cpp.