OpenCPN Partial API docs
Loading...
Searching...
No Matches
FontMgr.cpp
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2013 by David S. Register *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 **************************************************************************/
23
24#include <locale>
25#include <set>
26
27#include <wx/gdicmn.h>
28#include <wx/tokenzr.h>
29
30#include "FontMgr.h"
31#include "OCPNPlatform.h"
32#include "ocpn_plugin.h"
33
35 wxFont *font;
36 int pointsize_req;
37 wxFontStyle style_req;
38 wxFontWeight weight_req;
39 bool underline_req;
40};
41
43public:
44 ~OCPNwxFontList() { FreeAll(); }
45 wxFont *FindOrCreateFont(int pointSize, wxFontFamily family,
46 wxFontStyle style, wxFontWeight weight,
47 bool underline = false,
48 const wxString &face = wxEmptyString,
49 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
50 void FreeAll(void);
51
52private:
53 bool isCached(font_cache_record &record, int pointSize, wxFontFamily family,
54 wxFontStyle style, wxFontWeight weight, bool underline,
55 const wxString &facename, wxFontEncoding encoding);
56
57 std::vector<font_cache_record> m_fontVector;
58};
59
60extern wxString g_locale;
61
70wxString s_locale;
78int g_default_font_size;
79wxString g_default_font_facename;
80
81FontMgr *FontMgr::instance = NULL;
82
83FontMgr &FontMgr::Get() {
84 if (!instance) instance = new FontMgr;
85 return *instance;
86}
87
88void FontMgr::Shutdown() {
89 if (instance) {
90 delete instance;
91 instance = NULL;
92 }
93}
94
95FontMgr::FontMgr() : m_wxFontCache(NULL), m_fontlist(NULL), pDefFont(NULL) {
96 // Create the list of fonts
97 m_fontlist = new FontList;
98 m_fontlist->DeleteContents(true);
99
100 s_locale = g_locale;
101
102 // Get a nice generic font as default
103 pDefFont = FindOrCreateFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
104 wxFONTWEIGHT_BOLD, FALSE, wxString(_T ( "" )),
105 wxFONTENCODING_SYSTEM);
106}
107
108FontMgr::~FontMgr() {
109 m_fontlist->Clear();
110 delete m_fontlist;
111
112 delete m_wxFontCache;
113}
114
115void FontMgr::SetLocale(wxString &newLocale) { s_locale = newLocale; }
116
117wxColour FontMgr::GetFontColor(const wxString &TextElement) const {
118 MyFontDesc *pmfd = GetFontDesc(TextElement);
119 return pmfd ? pmfd->m_color : wxColour(0, 0, 0);
120}
121
122bool FontMgr::SetFontColor(const wxString &TextElement,
123 const wxColour color) const {
124 MyFontDesc *pmfd = GetFontDesc(TextElement);
125 if (pmfd) {
126 pmfd->m_color = color;
127 return true;
128 }
129 return false;
130}
131
132wxString FontMgr::GetFontConfigKey(const wxString &description) {
133 // Create the configstring by combining the locale with
134 // a hash of the font description. Hash is used because the i18n
135 // description can contain characters that mess up the config file.
136
137 wxString configkey;
138 configkey = s_locale;
139 configkey.Append(_T("-"));
140
141 using namespace std;
142 locale loc;
143 const collate<char> &coll = use_facet<collate<char> >(loc);
144 // char cFontDesc[101];
145 // wcstombs( cFontDesc, description.c_str(), 100 );
146 // cFontDesc[100] = 0;
147
148 wxCharBuffer abuf = description.ToUTF8();
149
150 int fdLen = strlen(abuf);
151
152 configkey.Append(wxString::Format(
153 _T("%08lx"), coll.hash(abuf.data(), abuf.data() + fdLen)));
154 return configkey;
155}
156
157int FontMgr::GetSystemFontSize() {
158 static int sys_font_size = 0;
159 if (!sys_font_size) {
160 wxFont sys_font = *wxNORMAL_FONT;
161 sys_font_size = sys_font.GetPointSize();
162 }
163 return sys_font_size;
164}
165
166wxString FontMgr::GetSystemFontFaceName() {
167 static wxString sys_font_facename;
168 if (sys_font_facename.IsEmpty()) {
169 wxFont sys_font = *wxNORMAL_FONT;
170 sys_font_facename = sys_font.GetFaceName();
171 }
172 return sys_font_facename;
173}
174
175bool FontMgr::IsDefaultFontEntry(const MyFontDesc *font_desc) const {
176 return font_desc && font_desc->m_is_default;
177 /*
178 if (!font_desc || !font_desc->m_font) return false;
179
180 int font_size = font_desc->m_font->GetPointSize();
181 return (g_default_font_size && font_size == g_default_font_size) ||
182 (!g_default_font_size && font_size == GetSystemFontSize());
183 */
184}
185
186/* Support Legacy (Prior to O5.12) plugin API interface */
187wxFont *FontMgr::GetFontLegacy(const wxString &TextElement,
188 int user_default_size) {
189 // Look thru the font list for a match
190 MyFontDesc *pmfd;
191 auto node = m_fontlist->GetFirst();
192 while (node) {
193 pmfd = node->GetData();
194 if (pmfd->m_dialogstring == TextElement) {
195 if (pmfd->m_configstring.BeforeFirst('-') == s_locale)
196 return pmfd->m_font;
197 }
198 node = node->GetNext();
199 }
200 return GetFont(TextElement, user_default_size);
201}
202
203wxFont *FontMgr::GetFont(const wxString &TextElement, int requested_font_size) {
204 // Look thru the font list for a match
205 MyFontDesc *pmfd;
206 auto node = m_fontlist->GetFirst();
207
208 while (node) {
209 pmfd = node->GetData();
210 // Check if the font matches both the text element and the requested size.
211 if (pmfd->m_dialogstring == TextElement &&
212 (pmfd->m_configstring.BeforeFirst('-') == s_locale)) {
213 if (requested_font_size == 0 && IsDefaultFontEntry(pmfd)) {
214 // Caller did not specify a font size, so return the default font.
215 // The user may have customized the default font in Options->User Fonts,
216 // else the system default font is used.
217 return pmfd->m_font;
218 } else if (requested_font_size != 0 &&
219 pmfd->m_font->GetPointSize() == requested_font_size) {
220 return pmfd->m_font;
221 }
222 }
223 node = node->GetNext();
224 }
225
226 // Found no font, so create a nice one and add to the list
227 wxString configkey = GetFontConfigKey(TextElement);
228
229 // Now create a benign, always present native font
230 // with optional user requested default size
231
232 int new_size;
233 if (0 == requested_font_size) {
234 new_size = g_default_font_size ? g_default_font_size : GetSystemFontSize();
235 } else
236 new_size = requested_font_size;
237
238 wxString face_name = g_default_font_facename.Length()
239 ? g_default_font_facename
240 : GetSystemFontFaceName();
241
242 wxString nativefont = GetSimpleNativeFont(new_size, face_name);
243 wxFont *nf = wxFont::New(nativefont);
244
245 wxColor color = GetDefaultFontColor(TextElement);
246
247 bool is_default = (requested_font_size == 0);
248 MyFontDesc *pnewfd =
249 new MyFontDesc(TextElement, configkey, nf, color, is_default);
250 m_fontlist->Append(pnewfd);
251
252 return pnewfd->m_font;
253}
254
255MyFontDesc *FontMgr::GetFontDesc(const wxString &TextElement) const {
256 // First try to find the default font entry
257 MyFontDesc *pmfd;
258 auto node = m_fontlist->GetFirst();
259 while (node) {
260 pmfd = node->GetData();
261 if (pmfd->m_dialogstring == TextElement && pmfd->m_is_default &&
262 pmfd->m_configstring.BeforeFirst('-') == s_locale) {
263 return pmfd;
264 }
265 node = node->GetNext();
266 }
267
268 // No default entry found, fall back to first matching entry
269 node = m_fontlist->GetFirst();
270 while (node) {
271 pmfd = node->GetData();
272 if (pmfd->m_dialogstring == TextElement &&
273 pmfd->m_configstring.BeforeFirst('-') == s_locale) {
274 return pmfd;
275 }
276 node = node->GetNext();
277 }
278
279 return NULL;
280}
281
282wxColour FontMgr::GetDefaultFontColor(const wxString &TextElement) {
283 wxColor defaultColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
284
285 // Special cases here
286 if (TextElement.IsSameAs(_("Console Legend")))
287 defaultColor = wxColour(0, 255, 0);
288 else if (TextElement.IsSameAs(_("Console Value")))
289 defaultColor = wxColour(0, 255, 0);
290 else if (TextElement.IsSameAs(_("Marks")))
291 defaultColor = wxColour(0, 0, 0);
292 else if (TextElement.IsSameAs(_("RouteLegInfoRollover")))
293 defaultColor = wxColour(0, 0, 0);
294 else if (TextElement.IsSameAs(_("AISRollover")))
295 defaultColor = wxColour(0, 0, 0);
296 else if (TextElement.IsSameAs(_("ExtendedTideIcon")))
297 defaultColor = wxColour(0, 0, 0);
298 else if (TextElement.IsSameAs(_("ChartTexts")))
299 defaultColor = wxColour(0, 0, 0);
300 else if (TextElement.IsSameAs(_("AIS Target Name")))
301 defaultColor = wxColour(0, 0, 0);
302#ifdef __WXMAC__
303 // Override, to adjust for light/dark mode
304 return wxColour(0, 0, 0);
305#endif
306
307 return defaultColor;
308}
309
310wxString FontMgr::GetSimpleNativeFont(int size, wxString face) {
311 // Now create a benign, always present native string
312 wxString nativefont;
313
314 // this should work for all platforms
315 nativefont = wxFont(size, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
316 wxFONTWEIGHT_NORMAL, false, face)
317 .GetNativeFontInfoDesc();
318
319 return nativefont;
320}
321
322bool FontMgr::SetFont(const wxString &TextElement, wxFont *pFont,
323 wxColour color) {
324 // Look thru the font list for a match
325 MyFontDesc *pmfd = GetFontDesc(TextElement);
326 // Todo Think about this
327 //
328 // Cannot delete the present font, since it may be in use elsewhere
329 // This WILL leak....but only on font changes
330 // delete pmfd->m_font; // purge
331 // any old value
332 if (pmfd) {
333 pmfd->m_font = pFont;
334 pmfd->m_nativeInfo = pFont->GetNativeFontInfoDesc();
335 pmfd->m_color = color;
336
337 return true;
338 }
339 return false;
340}
341
342int FontMgr::GetNumFonts(void) const { return m_fontlist->GetCount(); }
343
344const wxString &FontMgr::GetConfigString(int i) const {
345 MyFontDesc *pfd = m_fontlist->Item(i)->GetData();
346 return pfd->m_configstring;
347}
348
349const wxString &FontMgr::GetDialogString(int i) const {
350 MyFontDesc *pfd = m_fontlist->Item(i)->GetData();
351 return pfd->m_dialogstring;
352}
353
354wxArrayString FontMgr::GetDialogStrings(const wxString &locale) const {
355 std::set<wxString> uniqueStrings;
356
357 auto node = m_fontlist->GetFirst();
358 while (node) {
359 MyFontDesc *pmfd = node->GetData();
360 if (locale.IsEmpty() || pmfd->m_configstring.BeforeFirst('-') == locale) {
361 uniqueStrings.insert(pmfd->m_dialogstring);
362 }
363 node = node->GetNext();
364 }
365 wxArrayString strings;
366 strings.reserve(uniqueStrings.size()); // Pre-allocate for efficiency
367 for (const auto &str : uniqueStrings) {
368 strings.Add(str);
369 }
370
371 return strings;
372}
373
374const wxString &FontMgr::GetNativeDesc(int i) const {
375 MyFontDesc *pfd = m_fontlist->Item(i)->GetData();
376 return pfd->m_nativeInfo;
377}
378
379wxString FontMgr::GetFullConfigDesc(int i) const {
380 MyFontDesc *pfd = m_fontlist->Item(i)->GetData();
381 wxString ret = pfd->m_dialogstring;
382 ret.Append(_T ( ":" ));
383 ret.Append(pfd->m_nativeInfo);
384 ret.Append(_T ( ":" ));
385
386 wxString cols(_T("rgb(0,0,0)"));
387 if (pfd->m_color.IsOk()) cols = pfd->m_color.GetAsString(wxC2S_CSS_SYNTAX);
388
389 ret.Append(cols);
390 return ret;
391}
392
394 // Search for a match in the list
395 MyFontDesc *pmfd;
396 auto node = m_fontlist->GetFirst();
397
398 while (node) {
399 pmfd = node->GetData();
400 if (pmfd->m_configstring == pConfigString) {
401 return pmfd;
402 }
403 node = node->GetNext();
404 }
405
406 return NULL;
407}
408
409void FontMgr::LoadFontNative(wxString *pConfigString, wxString *pNativeDesc) {
410 // Parse the descriptor string
411
412 wxStringTokenizer tk(*pNativeDesc, _T ( ":" ));
413 wxString dialogstring = tk.GetNextToken();
414 wxString nativefont = tk.GetNextToken();
415
416 wxString c = tk.GetNextToken();
417 wxColour color(c); // from string description
418
419 // Search for a match in the list
420 MyFontDesc *pmfd;
421 auto node = m_fontlist->GetFirst();
422
423 while (node) {
424 pmfd = node->GetData();
425 if (pmfd->m_configstring == *pConfigString) {
426 if (pmfd->m_configstring.BeforeFirst('-') == g_locale) {
427 pmfd->m_nativeInfo = nativefont;
428 wxFont *nf = pmfd->m_font->New(pmfd->m_nativeInfo);
429 pmfd->m_font = nf;
430 break;
431 }
432 }
433 node = node->GetNext();
434 }
435
436 // Create and add the font to the list
437 if (!node) {
438 wxFont *nf0 = new wxFont();
439
440#ifdef __OCPN__ANDROID__
441 wxFont *nf = new wxFont(nativefont);
442#else
443 wxFont *nf = nf0->New(nativefont);
444#endif
445
446 double font_size = nf->GetPointSize();
447 wxString s = nf->GetNativeFontInfoDesc();
448
449 // Scrub the native font string for bad unicode conversion
450#ifdef __WXMSW__
451 wxString face = nf->GetFaceName();
452 const wxChar *t = face.c_str();
453 if (*t > 255) {
454 delete nf;
455 wxString substitute_native = GetSimpleNativeFont(12, _T(""));
456 nf = nf0->New(substitute_native);
457 }
458#endif
459 delete nf0;
460
461 MyFontDesc *pnewfd =
462 new MyFontDesc(dialogstring, *pConfigString, nf, color);
463 m_fontlist->Append(pnewfd);
464 }
465}
466
467wxFont *FontMgr::FindOrCreateFont(int point_size, wxFontFamily family,
468 wxFontStyle style, wxFontWeight weight,
469 bool underline, const wxString &facename,
470 wxFontEncoding encoding) {
471 if (m_wxFontCache == 0) m_wxFontCache = new OCPNwxFontList;
472 return m_wxFontCache->FindOrCreateFont(point_size, family, style, weight,
473 underline, facename, encoding);
474}
475
476bool OCPNwxFontList::isCached(font_cache_record &record, int pointSize,
477 wxFontFamily family, wxFontStyle style,
478 wxFontWeight weight, bool underline,
479 const wxString &facename,
480 wxFontEncoding encoding) {
481 if (record.pointsize_req == pointSize && record.style_req == style &&
482 record.weight_req == weight && record.underline_req == underline) {
483 bool same;
484
485 wxFont *font = record.font;
486 // empty facename matches anything at all: this is bad because
487 // depending on which fonts are already created, we might get back
488 // a different font if we create it with empty facename, but it is
489 // still better than never matching anything in the cache at all
490 // in this case
491 if (!facename.empty()) {
492 const wxString &fontFace = font->GetFaceName();
493
494 // empty facename matches everything
495 same = !fontFace || fontFace == facename;
496 } else {
497 same = font->GetFamily() == family;
498 }
499 if (same && (encoding != wxFONTENCODING_DEFAULT)) {
500 // have to match the encoding too
501 same = font->GetEncoding() == encoding;
502 }
503 return same;
504 }
505 return false;
506}
507
508wxFont *OCPNwxFontList::FindOrCreateFont(int pointSize, wxFontFamily family,
509 wxFontStyle style, wxFontWeight weight,
510 bool underline,
511 const wxString &facename,
512 wxFontEncoding encoding) {
513 // from wx source code
514 // In all ports but wxOSX, the effective family of a font created using
515 // wxFONTFAMILY_DEFAULT is wxFONTFAMILY_SWISS so this is what we need to
516 // use for comparison.
517 //
518 // In wxOSX the original wxFONTFAMILY_DEFAULT seems to be kept and it uses
519 // a different font than wxFONTFAMILY_SWISS anyhow so we just preserve it.
520#ifndef __WXOSX__
521 if (family == wxFONTFAMILY_DEFAULT) family = wxFONTFAMILY_SWISS;
522#endif // !__WXOSX__
523
524 wxFont *font;
525 for (size_t i = 0; i < m_fontVector.size(); i++) {
526 font_cache_record record = m_fontVector[i];
527 if (isCached(record, pointSize, family, style, weight, underline, facename,
528 encoding))
529 return record.font;
530 }
531
532 // font not found, create the new one
533 // Support scaled HDPI displays automatically
534
535 font = NULL;
536 wxFont fontTmp(OCPN_GetDisplayContentScaleFactor() * pointSize, family, style,
537 weight, underline, facename, encoding);
538 if (fontTmp.IsOk()) {
539 font = new wxFont(fontTmp);
540 font_cache_record record;
541 record.font = font;
542 record.pointsize_req = pointSize;
543 record.style_req = style;
544 record.weight_req = weight;
545 record.underline_req = underline;
546 m_fontVector.push_back(record);
547 }
548
549 return font;
550}
551
552void OCPNwxFontList::FreeAll(void) {
553 wxFont *font;
554 for (size_t i = 0; i < m_fontVector.size(); i++) {
555 font_cache_record record = m_fontVector[i];
556 font = record.font;
557 delete font;
558 }
559 m_fontVector.clear();
560}
561
562static wxString FontCandidates[] = {_("AISTargetAlert"),
563 _("AISTargetQuery"),
564 _("StatusBar"),
565 _("AIS Target Name"),
566 _("ObjectQuery"),
567 _("RouteLegInfoRollover"),
568 _("ExtendedTideIcon"),
569 _("CurrentValue"),
570 _("Console Legend"),
571 _("Console Value"),
572 _("AISRollover"),
573 _("TideCurrentGraphRollover"),
574 _("Marks"),
575 _("ChartTexts"),
576 _("ToolTips"),
577 _("Dialog"),
578 _("Menu"),
579 _("GridText"),
580 _T("END_OF_LIST")};
581
583 wxString now_locale = g_locale;
584 wxArrayString string_array;
585
586 // Build the composite candidate array
587 wxArrayString candidateArray;
588 unsigned int i = 0;
589
590 // The fixed, static list
591 while (true) {
592 wxString candidate = FontCandidates[i];
593 if (candidate == _T("END_OF_LIST")) {
594 break;
595 }
596
597 candidateArray.Add(candidate);
598 i++;
599 }
600
601 // The Aux Key array
602 for (unsigned int i = 0; i < m_AuxKeyArray.GetCount(); i++) {
603 candidateArray.Add(m_AuxKeyArray[i]);
604 }
605
606 for (unsigned int i = 0; i < candidateArray.GetCount(); i++) {
607 wxString candidate = candidateArray[i];
608
609 // For each font identifier string in the FontCandidate array...
610
611 // In the current locale, walk the loaded list looking for a translation
612 // that is correct, according to the currently load .mo file.
613 // If found, add to a temporary array
614
615 wxString trans = wxGetTranslation(candidate);
616
617 MyFontDesc *pmfd;
618 auto node = m_fontlist->GetFirst();
619 while (node) {
620 pmfd = node->GetData();
621 wxString tlocale = pmfd->m_configstring.BeforeFirst('-');
622 if (tlocale == now_locale) {
623 if (trans == pmfd->m_dialogstring) {
624 string_array.Add(pmfd->m_dialogstring);
625 }
626 }
627
628 node = node->GetNext();
629 }
630 }
631
632 // now we have an array of correct translations
633 // Walk the loaded list again.
634 // If a list item's translation is not in the "good" array, mark it for
635 // removal
636
637 MyFontDesc *pmfd;
638 auto node = m_fontlist->GetFirst();
639 while (node) {
640 pmfd = node->GetData();
641 wxString tlocale = pmfd->m_configstring.BeforeFirst('-');
642 if (tlocale == now_locale) {
643 bool bfound = false;
644 for (unsigned int i = 0; i < string_array.GetCount(); i++) {
645 if (string_array[i] == pmfd->m_dialogstring) {
646 bfound = true;
647 break;
648 }
649 }
650 if (!bfound) { // mark for removal
651 pmfd->m_dialogstring = _T("");
652 pmfd->m_configstring = _T("");
653 }
654 }
655
656 node = node->GetNext();
657 }
658
659 // Remove the marked list items
660 node = m_fontlist->GetFirst();
661 while (node) {
662 pmfd = node->GetData();
663 if (pmfd->m_dialogstring == _T("")) {
664 bool bd = m_fontlist->DeleteObject(pmfd);
665 if (bd) node = m_fontlist->GetFirst();
666 } else
667 node = node->GetNext();
668 }
669
670 // And finally, for good measure, make sure that everything in the candidate
671 // array has a valid entry in the list
672 i = 0;
673 while (true) {
674 wxString candidate = FontCandidates[i];
675 if (candidate == _T("END_OF_LIST")) {
676 break;
677 }
678
679 GetFont(wxGetTranslation(candidate));
680 i++;
681 }
682}
683
684bool FontMgr::AddAuxKey(wxString key) {
685 for (unsigned int i = 0; i < m_AuxKeyArray.GetCount(); i++) {
686 if (m_AuxKeyArray[i] == key) return false;
687 }
688 m_AuxKeyArray.Add(key);
689 return true;
690}
691
692bool FontMgr::ResetFontToDefault(const wxString &TextElement) {
693 // Create default font with system settings
694 int size = g_default_font_size ? g_default_font_size : GetSystemFontSize();
695 wxString face = g_default_font_facename.Length() ? g_default_font_facename
696 : GetSystemFontFaceName();
697 wxString native = GetSimpleNativeFont(size, face);
698 wxFont *defaultFont = wxFont::New(native);
699
700 // Find and update the font descriptor
701 MyFontDesc *desc = GetFontDesc(TextElement);
702 if (desc) {
703 // Update font properties
704 desc->m_font = defaultFont;
705 desc->m_nativeInfo = native;
706 desc->m_color = GetDefaultFontColor(TextElement);
707 desc->m_is_default = true;
708 return true;
709 }
710
711 return false;
712}
Manages the font list.
Definition FontMgr.h:37
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.
Definition FontMgr.cpp:467
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition FontMgr.cpp:379
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition FontMgr.cpp:117
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition FontMgr.cpp:684
bool ResetFontToDefault(const wxString &TextElement)
Resets the font configuration for a UI element back to system defaults.
Definition FontMgr.cpp:692
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition FontMgr.cpp:409
bool SetFontColor(const wxString &TextElement, const wxColour color) const
Sets the text color for a UI element.
Definition FontMgr.cpp:122
static wxString GetFontConfigKey(const wxString &description)
Creates configuration key from UI element name by combining locale with hash.
Definition FontMgr.cpp:132
bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color)
Sets the default font properties for a UI element.
Definition FontMgr.cpp:322
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition FontMgr.cpp:342
wxColour GetDefaultFontColor(const wxString &TextElement)
Gets the default text color for a UI element.
Definition FontMgr.cpp:282
void ScrubList()
Cleans up stale font entries after a locale change.
Definition FontMgr.cpp:582
wxArrayString GetDialogStrings(const wxString &locale=wxEmptyString) const
Gets the list of unique dialog strings.
Definition FontMgr.cpp:354
MyFontDesc * FindFontByConfigString(wxString pConfigString)
Finds font descriptor by its configuration key.
Definition FontMgr.cpp:393
const wxString & GetNativeDesc(int i) const
Gets the native font descriptor string for the font at index i.
Definition FontMgr.cpp:374
const wxString & GetConfigString(int i) const
Gets the locale-specific configuration key for a font at index i.
Definition FontMgr.cpp:344
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:203
const wxString & GetDialogString(int i) const
Gets the UI element identifier string for the font at index i.
Definition FontMgr.cpp:349
wxString m_nativeInfo
Platform-specific font descriptor string.
Definition FontDesc.h:54
wxString m_dialogstring
UI element identifier, e.g., "AISTargetAlert", "StatusBar".
Definition FontDesc.h:46
wxString m_configstring
Configuration key in "locale-hash" format.
Definition FontDesc.h:50
wxFont * m_font
Font object.
Definition FontDesc.h:58
wxColour m_color
Text color.
Definition FontDesc.h:62
bool m_is_default
Indicates if this is the default font entry for the TextElement.
Definition FontDesc.h:64
PlugIn Object Definition/API.
double OCPN_GetDisplayContentScaleFactor()
Gets content scaling factor for current display.