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