QGIS API Documentation 4.3.0-Master (9ff14a2eeba)
Loading...
Searching...
No Matches
qgsfontcombobox.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsfontcombobox.cpp
3 --------------------------------------
4 Date : July 2026
5 Copyright : (C) 2026 Nyall Dawson
6 Email : nyall.dawson@gmail.com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsfontcombobox.h"
17
18#include <QString>
19
20#include "moc_qgsfontcombobox.cpp"
21
22using namespace Qt::StringLiterals;
23
25 : QFontComboBox( parent )
26{
27 QFont f = font();
28 // set font size to match QFontComboBox default:
29 // https://github.com/openwebos/qt/blob/master/src/gui/widgets/qfontcombobox.cpp#L134C1-L135C1
30 // yep, ¯\‍(°_o)/¯
31 f.setPointSize( static_cast< int >( 3 / 2.0 * f.pointSize() ) );
32
33 // these fonts have broken metadata -- they aren't correctly tagged as symbol fonts,
34 // so QFontComboBox happily renders the font name in undecipherable symbol characters.
35 // Yes, it's the fonts themselves which are broken, but given that these particular fonts
36 // are used heavily in spatial contexts, its worth working around this!
37 for ( const QString &family : {
38 u"D050000L [urw]"_s,
39 u"D050000L [URW ]"_s,
40 u"D050000L"_s,
41 u"ESRI AMFM Electric"_s,
42 u"ESRI Cartography"_s,
43 u"ESRI Caves 1"_s,
44 u"ESRI Caves 2"_s,
45 u"ESRI Caves 3"_s,
46 u"ESRI Environmental & Icons"_s,
47 u"ESRI Geology"_s,
48 u"ESRI Geology USGS 95-525"_s,
49 u"ESRI Geometric Symbols"_s,
50 u"ESRI Hazardous Materials"_s,
51 u"ESRI MilMod 01"_s,
52 u"ESRI MilSym 04"_s,
53 u"ESRI NIMA DNC PT"_s,
54 u"ESRI Oil, Gas, & Water"_s,
55 u"ESRI Pipeline US 1"_s,
56 u"ESRI Public1"_s,
57 u"ESRI SDS 1.95 1"_s,
58 u"ESRI SDS 2.00 1"_s,
59 u"ESRI Transportation & Civic"_s,
60 u"ESRI US Forestry 1"_s,
61 u"ESRI US MUTCD 1"_s,
62 u"ESRI US MUTCD 2"_s,
63 u"ESRI US MUTCD 3"_s,
64 u"ESRI Weather"_s,
65 } )
66 {
67 setDisplayFont( family, f );
68 }
69}
QgsFontComboBox(QWidget *parent=nullptr)
Constructor for QgsFontComboBox, with the specified parent widget.