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