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#include <algorithm>
24#include <locale>
25#include <set>
26
27#include <wx/gdicmn.h>
28#include <wx/tokenzr.h>
29
30#include "model/config_vars.h"
31#include "FontMgr.h"
32#include "OCPNPlatform.h"
33#include "ocpn_plugin.h"
34
36 wxFont *font;
37 int pointsize_req;
38 wxFontStyle style_req;
39 wxFontWeight weight_req;
40 bool underline_req;
41};
42
44public:
45 ~OCPNwxFontList() { FreeAll(); }
46 wxFont *FindOrCreateFont(int pointSize, wxFontFamily family,
47 wxFontStyle style, wxFontWeight weight,
48 bool underline = false,
49 const wxString &face = wxEmptyString,
50 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
51 void FreeAll(void);
52
53private:
54 bool isCached(font_cache_record &record, int pointSize, wxFontFamily family,
55 wxFontStyle style, wxFontWeight weight, bool underline,
56 const wxString &facename, wxFontEncoding encoding);
57
58 std::vector<font_cache_record> m_fontVector;
59};
60
61extern wxString g_locale;
62
71wxString s_locale;
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
99 s_locale = g_locale;
100
101 // Get a nice generic font as default
102 pDefFont = FindOrCreateFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
103 wxFONTWEIGHT_BOLD, FALSE, wxString(_T ( "" )),
104 wxFONTENCODING_SYSTEM);
105}
106
107FontMgr::~FontMgr() {
108 for (auto it = m_fontlist->begin(); it != m_fontlist->end(); it++) delete *it;
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("-");
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(
153 wxString::Format("%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 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
191 MyFontDesc *pmfd = *node;
192 if (pmfd->m_dialogstring == TextElement) {
193 if (pmfd->m_configstring.BeforeFirst('-') == s_locale)
194 return pmfd->m_font;
195 }
196 }
197 return GetFont(TextElement, user_default_size);
198}
199
200wxFont *FontMgr::GetFont(const wxString &TextElement, int requested_font_size) {
201 // Look thru the font list for a match
202 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
203 MyFontDesc *pmfd = *node;
204 // Check if the font matches both the text element and the requested size.
205 if (pmfd->m_dialogstring == TextElement &&
206 (pmfd->m_configstring.BeforeFirst('-') == s_locale)) {
207 if (requested_font_size == 0 && IsDefaultFontEntry(pmfd)) {
208 // Caller did not specify a font size, so return the default font.
209 // The user may have customized the default font in Options->User Fonts,
210 // else the system default font is used.
211 return pmfd->m_font;
212 } else if (requested_font_size != 0 &&
213 pmfd->m_font->GetPointSize() == requested_font_size) {
214 return pmfd->m_font;
215 }
216 }
217 }
218
219 // Found no font, so create a nice one and add to the list
220 wxString configkey = GetFontConfigKey(TextElement);
221
222 // Now create a benign, always present native font
223 // with optional user requested default size
224
225 int new_size;
226 if (0 == requested_font_size) {
227 new_size = g_default_font_size ? g_default_font_size : GetSystemFontSize();
228 } else
229 new_size = requested_font_size;
230
231 wxString face_name = g_default_font_facename.Length()
232 ? g_default_font_facename
233 : GetSystemFontFaceName();
234
235 wxString nativefont = GetSimpleNativeFont(new_size, face_name);
236 wxFont *nf = wxFont::New(nativefont);
237
238 wxColor color = GetDefaultFontColor(TextElement);
239
240 bool is_default = (requested_font_size == 0);
241 MyFontDesc *pnewfd =
242 new MyFontDesc(TextElement, configkey, nf, color, is_default);
243 m_fontlist->push_back(pnewfd);
244
245 return pnewfd->m_font;
246}
247
248MyFontDesc *FontMgr::GetFontDesc(const wxString &TextElement) const {
249 // First try to find the default font entry
250 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
251 MyFontDesc *pmfd = *node;
252 if (pmfd->m_dialogstring == TextElement && pmfd->m_is_default &&
253 pmfd->m_configstring.BeforeFirst('-') == s_locale) {
254 return pmfd;
255 }
256 }
257
258 // No default entry found, fall back to first matching entry
259 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
260 MyFontDesc *pmfd = *node;
261 if (pmfd->m_dialogstring == TextElement &&
262 pmfd->m_configstring.BeforeFirst('-') == s_locale) {
263 return pmfd;
264 }
265 }
266 return NULL;
267}
268
269wxColour FontMgr::GetDefaultFontColor(const wxString &TextElement) {
270 wxColor defaultColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
271
272 // Special cases here
273 if (TextElement.IsSameAs(_("Console Legend")))
274 defaultColor = wxColour(0, 255, 0);
275 else if (TextElement.IsSameAs(_("Console Value")))
276 defaultColor = wxColour(0, 255, 0);
277 else if (TextElement.IsSameAs(_("Marks")))
278 defaultColor = wxColour(0, 0, 0);
279 else if (TextElement.IsSameAs(_("RouteLegInfoRollover")))
280 defaultColor = wxColour(0, 0, 0);
281 else if (TextElement.IsSameAs(_("AISRollover")))
282 defaultColor = wxColour(0, 0, 0);
283 else if (TextElement.IsSameAs(_("ExtendedTideIcon")))
284 defaultColor = wxColour(0, 0, 0);
285 else if (TextElement.IsSameAs(_("ChartTexts")))
286 defaultColor = wxColour(0, 0, 0);
287 else if (TextElement.IsSameAs(_("AIS Target Name")))
288 defaultColor = wxColour(0, 0, 0);
289#ifdef __WXMAC__
290 // Override, to adjust for light/dark mode
291 return wxColour(0, 0, 0);
292#endif
293
294 return defaultColor;
295}
296
297wxString FontMgr::GetSimpleNativeFont(int size, wxString face) {
298 // Now create a benign, always present native string
299 wxString nativefont;
300
301 // this should work for all platforms
302 nativefont = wxFont(size, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
303 wxFONTWEIGHT_NORMAL, false, face)
304 .GetNativeFontInfoDesc();
305
306 return nativefont;
307}
308
309bool FontMgr::SetFont(const wxString &TextElement, wxFont *pFont,
310 wxColour color) {
311 // Look thru the font list for a match
312 MyFontDesc *pmfd = GetFontDesc(TextElement);
313 // Todo Think about this
314 //
315 // Cannot delete the present font, since it may be in use elsewhere
316 // This WILL leak....but only on font changes
317 // delete pmfd->m_font; // purge
318 // any old value
319 if (pmfd) {
320 pmfd->m_font = pFont;
321 pmfd->m_nativeInfo = pFont->GetNativeFontInfoDesc();
322 pmfd->m_color = color;
323
324 return true;
325 }
326 return false;
327}
328
329int FontMgr::GetNumFonts(void) const { return m_fontlist->size(); }
330
331const wxString &FontMgr::GetConfigString(int i) const {
332 auto it = m_fontlist->begin();
333 std::advance(it, i);
334 return (*it)->m_configstring;
335}
336
337const wxString &FontMgr::GetDialogString(int i) const {
338 auto it = m_fontlist->begin();
339 std::advance(it, i);
340 return (*it)->m_dialogstring;
341}
342
343wxArrayString FontMgr::GetDialogStrings(const wxString &locale) const {
344 std::set<wxString> uniqueStrings;
345
346 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
347 MyFontDesc *pmfd = *node;
348 if (locale.IsEmpty() || pmfd->m_configstring.BeforeFirst('-') == locale) {
349 uniqueStrings.insert(pmfd->m_dialogstring);
350 }
351 }
352 wxArrayString strings;
353 strings.reserve(uniqueStrings.size()); // Pre-allocate for efficiency
354 for (const auto &str : uniqueStrings) {
355 strings.Add(str);
356 }
357
358 return strings;
359}
360
361const wxString &FontMgr::GetNativeDesc(int i) const {
362 auto it = m_fontlist->begin();
363 std::advance(it, i);
364 return (*it)->m_nativeInfo;
365}
366
367wxString FontMgr::GetFullConfigDesc(int i) const {
368 auto it = m_fontlist->begin();
369 std::advance(it, i);
370 MyFontDesc *pfd = *it;
371 wxString ret = pfd->m_dialogstring;
372 ret.Append(_T ( ":" ));
373 ret.Append(pfd->m_nativeInfo);
374 ret.Append(_T ( ":" ));
375
376 wxString cols("rgb(0,0,0)");
377 if (pfd->m_color.IsOk()) cols = pfd->m_color.GetAsString(wxC2S_CSS_SYNTAX);
378
379 ret.Append(cols);
380 return ret;
381}
382
384 // Search for a match in the list
385 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); ++node) {
386 MyFontDesc *pmfd = *node;
387 if (pmfd->m_configstring == pConfigString) {
388 return pmfd;
389 }
390 }
391 return NULL;
392}
393
394void FontMgr::LoadFontNative(wxString *pConfigString, wxString *pNativeDesc) {
395 // Parse the descriptor string
396
397 wxStringTokenizer tk(*pNativeDesc, _T ( ":" ));
398 wxString dialogstring = tk.GetNextToken();
399 wxString nativefont = tk.GetNextToken();
400
401 wxString c = tk.GetNextToken();
402 wxColour color(c); // from string description
403
404 // Search for a match in the list
405 auto node = m_fontlist->begin();
406 for (; node != m_fontlist->end(); ++node) {
407 MyFontDesc *pmfd = *node;
408 if (pmfd->m_configstring == *pConfigString) {
409 if (pmfd->m_configstring.BeforeFirst('-') == g_locale) {
410 pmfd->m_nativeInfo = nativefont;
411 wxFont *nf = pmfd->m_font->New(pmfd->m_nativeInfo);
412 pmfd->m_font = nf;
413 break;
414 }
415 }
416 }
417
418 // Create and add the font to the list
419 if (node == m_fontlist->end()) {
420 wxFont *nf0 = new wxFont();
421
422#ifdef __OCPN__ANDROID__
423 wxFont *nf = new wxFont(nativefont);
424#else
425 wxFont *nf = nf0->New(nativefont);
426#endif
427
428 double font_size = nf->GetPointSize();
429 wxString s = nf->GetNativeFontInfoDesc();
430
431 // Scrub the native font string for bad unicode conversion
432#ifdef __WXMSW__
433 wxString face = nf->GetFaceName();
434 const wxChar *t = face.c_str();
435 if (*t > 255) {
436 delete nf;
437 wxString substitute_native = GetSimpleNativeFont(12, "");
438 nf = nf0->New(substitute_native);
439 }
440#endif
441 delete nf0;
442
443 MyFontDesc *pnewfd =
444 new MyFontDesc(dialogstring, *pConfigString, nf, color);
445 m_fontlist->push_back(pnewfd);
446 }
447}
448
449wxFont *FontMgr::FindOrCreateFont(int point_size, wxFontFamily family,
450 wxFontStyle style, wxFontWeight weight,
451 bool underline, const wxString &facename,
452 wxFontEncoding encoding) {
453 if (m_wxFontCache == 0) m_wxFontCache = new OCPNwxFontList;
454 return m_wxFontCache->FindOrCreateFont(point_size, family, style, weight,
455 underline, facename, encoding);
456}
457
458bool OCPNwxFontList::isCached(font_cache_record &record, int pointSize,
459 wxFontFamily family, wxFontStyle style,
460 wxFontWeight weight, bool underline,
461 const wxString &facename,
462 wxFontEncoding encoding) {
463 if (record.pointsize_req == pointSize && record.style_req == style &&
464 record.weight_req == weight && record.underline_req == underline) {
465 bool same;
466
467 wxFont *font = record.font;
468 // empty facename matches anything at all: this is bad because
469 // depending on which fonts are already created, we might get back
470 // a different font if we create it with empty facename, but it is
471 // still better than never matching anything in the cache at all
472 // in this case
473 if (!facename.empty()) {
474 const wxString &fontFace = font->GetFaceName();
475
476 // empty facename matches everything
477 same = !fontFace || fontFace == facename;
478 } else {
479 same = font->GetFamily() == family;
480 }
481 if (same && (encoding != wxFONTENCODING_DEFAULT)) {
482 // have to match the encoding too
483 same = font->GetEncoding() == encoding;
484 }
485 return same;
486 }
487 return false;
488}
489
490wxFont *OCPNwxFontList::FindOrCreateFont(int pointSize, wxFontFamily family,
491 wxFontStyle style, wxFontWeight weight,
492 bool underline,
493 const wxString &facename,
494 wxFontEncoding encoding) {
495 // from wx source code
496 // In all ports but wxOSX, the effective family of a font created using
497 // wxFONTFAMILY_DEFAULT is wxFONTFAMILY_SWISS so this is what we need to
498 // use for comparison.
499 //
500 // In wxOSX the original wxFONTFAMILY_DEFAULT seems to be kept and it uses
501 // a different font than wxFONTFAMILY_SWISS anyhow so we just preserve it.
502#ifndef __WXOSX__
503 if (family == wxFONTFAMILY_DEFAULT) family = wxFONTFAMILY_SWISS;
504#endif // !__WXOSX__
505
506 wxFont *font;
507 for (size_t i = 0; i < m_fontVector.size(); i++) {
508 font_cache_record record = m_fontVector[i];
509 if (isCached(record, pointSize, family, style, weight, underline, facename,
510 encoding))
511 return record.font;
512 }
513
514 // font not found, create the new one
515 // Support scaled HDPI displays automatically
516
517 font = NULL;
518 wxFont fontTmp(OCPN_GetDisplayContentScaleFactor() * pointSize, family, style,
519 weight, underline, facename, encoding);
520 if (fontTmp.IsOk()) {
521 font = new wxFont(fontTmp);
522 font_cache_record record;
523 record.font = font;
524 record.pointsize_req = pointSize;
525 record.style_req = style;
526 record.weight_req = weight;
527 record.underline_req = underline;
528 m_fontVector.push_back(record);
529 }
530
531 return font;
532}
533
534void OCPNwxFontList::FreeAll(void) {
535 wxFont *font;
536 for (size_t i = 0; i < m_fontVector.size(); i++) {
537 font_cache_record record = m_fontVector[i];
538 font = record.font;
539 delete font;
540 }
541 m_fontVector.clear();
542}
543
544static wxString FontCandidates[] = {_("AISTargetAlert"),
545 _("AISTargetQuery"),
546 _("StatusBar"),
547 _("AIS Target Name"),
548 _("ObjectQuery"),
549 _("RouteLegInfoRollover"),
550 _("ExtendedTideIcon"),
551 _("CurrentValue"),
552 _("Console Legend"),
553 _("Console Value"),
554 _("AISRollover"),
555 _("TideCurrentGraphRollover"),
556 _("Marks"),
557 _("ChartTexts"),
558 _("ToolTips"),
559 _("Dialog"),
560 _("Menu"),
561 _("GridText"),
562 "END_OF_LIST"};
563
565 wxString now_locale = g_locale;
566 wxArrayString string_array;
567
568 // Build the composite candidate array
569 wxArrayString candidateArray;
570 unsigned int i = 0;
571
572 // The fixed, static list
573 while (true) {
574 wxString candidate = FontCandidates[i];
575 if (candidate == "END_OF_LIST") {
576 break;
577 }
578
579 candidateArray.Add(candidate);
580 i++;
581 }
582
583 // The Aux Key array
584 for (unsigned int i = 0; i < m_AuxKeyArray.GetCount(); i++) {
585 candidateArray.Add(m_AuxKeyArray[i]);
586 }
587
588 for (unsigned int i = 0; i < candidateArray.GetCount(); i++) {
589 wxString candidate = candidateArray[i];
590
591 // For each font identifier string in the FontCandidate array...
592
593 // In the current locale, walk the loaded list looking for a translation
594 // that is correct, according to the currently load .mo file.
595 // If found, add to a temporary array
596
597 wxString trans = wxGetTranslation(candidate);
598
599 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); node++) {
600 MyFontDesc *pmfd = *node;
601 wxString tlocale = pmfd->m_configstring.BeforeFirst('-');
602 if (tlocale == now_locale) {
603 if (trans == pmfd->m_dialogstring) {
604 string_array.Add(pmfd->m_dialogstring);
605 }
606 }
607 }
608 }
609
610 // now we have an array of correct translations
611 // Walk the loaded list again.
612 // If a list item's translation is not in the "good" array, mark it for
613 // removal
614
615 for (auto node = m_fontlist->begin(); node != m_fontlist->end(); node++) {
616 MyFontDesc *pmfd = *node;
617 wxString tlocale = pmfd->m_configstring.BeforeFirst('-');
618 if (tlocale == now_locale) {
619 bool bfound = false;
620 for (unsigned int i = 0; i < string_array.GetCount(); i++) {
621 if (string_array[i] == pmfd->m_dialogstring) {
622 bfound = true;
623 break;
624 }
625 }
626 if (!bfound) { // mark for removal
627 pmfd->m_dialogstring = "";
628 pmfd->m_configstring = "";
629 }
630 }
631 }
632
633 // Remove the marked list items
634 auto node = m_fontlist->begin();
635 while (node != m_fontlist->end()) {
636 MyFontDesc *pmfd = *node;
637 if (pmfd->m_dialogstring == "") {
638 auto found = std::find(m_fontlist->begin(), m_fontlist->end(), pmfd);
639 if (found != m_fontlist->end()) m_fontlist->erase(found);
640 node = m_fontlist->begin();
641 } else {
642 ++node;
643 }
644 }
645
646 // And finally, for good measure, make sure that everything in the candidate
647 // array has a valid entry in the list
648 i = 0;
649 while (true) {
650 wxString candidate = FontCandidates[i];
651 if (candidate == "END_OF_LIST") {
652 break;
653 }
654
655 GetFont(wxGetTranslation(candidate));
656 i++;
657 }
658}
659
660bool FontMgr::AddAuxKey(wxString key) {
661 for (unsigned int i = 0; i < m_AuxKeyArray.GetCount(); i++) {
662 if (m_AuxKeyArray[i] == key) return false;
663 }
664 m_AuxKeyArray.Add(key);
665 return true;
666}
667
668bool FontMgr::ResetFontToDefault(const wxString &TextElement) {
669 // Create default font with system settings
670 int size = g_default_font_size ? g_default_font_size : GetSystemFontSize();
671 wxString face = g_default_font_facename.Length() ? g_default_font_facename
672 : GetSystemFontFaceName();
673 wxString native = GetSimpleNativeFont(size, face);
674 wxFont *defaultFont = wxFont::New(native);
675
676 // Find and update the font descriptor
677 MyFontDesc *desc = GetFontDesc(TextElement);
678 if (desc) {
679 // Update font properties
680 desc->m_font = defaultFont;
681 desc->m_nativeInfo = native;
682 desc->m_color = GetDefaultFontColor(TextElement);
683 desc->m_is_default = true;
684 return true;
685 }
686
687 return false;
688}
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:449
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition FontMgr.cpp:367
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:660
bool ResetFontToDefault(const wxString &TextElement)
Resets the font configuration for a UI element back to system defaults.
Definition FontMgr.cpp:668
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition FontMgr.cpp:394
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:309
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition FontMgr.cpp:329
wxColour GetDefaultFontColor(const wxString &TextElement)
Gets the default text color for a UI element.
Definition FontMgr.cpp:269
void ScrubList()
Cleans up stale font entries after a locale change.
Definition FontMgr.cpp:564
wxArrayString GetDialogStrings(const wxString &locale=wxEmptyString) const
Gets the list of unique dialog strings.
Definition FontMgr.cpp:343
MyFontDesc * FindFontByConfigString(wxString pConfigString)
Finds font descriptor by its configuration key.
Definition FontMgr.cpp:383
const wxString & GetNativeDesc(int i) const
Gets the native font descriptor string for the font at index i.
Definition FontMgr.cpp:361
const wxString & GetConfigString(int i) const
Gets the locale-specific configuration key for a font at index i.
Definition FontMgr.cpp:331
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:200
const wxString & GetDialogString(int i) const
Gets the UI element identifier string for the font at index i.
Definition FontMgr.cpp:337
wxString m_nativeInfo
Platform-specific font descriptor string.
Definition FontDesc.h:55
wxString m_dialogstring
UI element identifier, e.g., "AISTargetAlert", "StatusBar".
Definition FontDesc.h:47
wxString m_configstring
Configuration key in "locale-hash" format.
Definition FontDesc.h:51
wxFont * m_font
Font object.
Definition FontDesc.h:59
wxColour m_color
Text color.
Definition FontDesc.h:63
bool m_is_default
Indicates if this is the default font entry for the TextElement.
Definition FontDesc.h:65
Global variables stored in configuration file.
PlugIn Object Definition/API.
double OCPN_GetDisplayContentScaleFactor()
Gets content scaling factor for current display.