Mercurial > octave
comparison libgui/src/gui-settings.cc @ 31657:61834788d3aa
get list of fonts from QFontDatabase, not QFontComboBox
* gui-settings.cc (gui_settings::get_default_font_family):
Get list of available fonts from the thread-safe QFontDatabase class,
not QFontComboBox.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Dec 2022 01:09:04 -0500 |
parents | deb553ac2c54 |
children | 1a1f47f17ed4 |
comparison
equal
deleted
inserted
replaced
31656:085b65319e00 | 31657:61834788d3aa |
---|---|
30 #include <cmath> | 30 #include <cmath> |
31 | 31 |
32 #include <QApplication> | 32 #include <QApplication> |
33 #include <QFile> | 33 #include <QFile> |
34 #include <QFileInfo> | 34 #include <QFileInfo> |
35 #include <QFontComboBox> | |
36 #include <QFontDatabase> | 35 #include <QFontDatabase> |
37 #include <QMessageBox> | 36 #include <QMessageBox> |
38 #include <QSettings> | 37 #include <QSettings> |
39 #include <QString> | 38 #include <QString> |
40 #include <QStringList> | 39 #include <QStringList> |
203 return QIcon (); | 202 return QIcon (); |
204 } | 203 } |
205 | 204 |
206 QString gui_settings::get_default_font_family (void) | 205 QString gui_settings::get_default_font_family (void) |
207 { | 206 { |
207 // Get all available fixed width fonts from the Qt font database. | |
208 | |
209 QFontDatabase font_database; | |
210 QStringList fonts; | |
211 | |
212 for (QString font : font_database.families ()) | |
213 { | |
214 if (font_database.isFixedPitch (font)) | |
215 fonts << font; | |
216 } | |
217 | |
208 QString default_family; | 218 QString default_family; |
209 | |
210 // Get all available fixed width fonts via a font combobox | |
211 QFontComboBox font_combo_box; | |
212 font_combo_box.setFontFilters (QFontComboBox::MonospacedFonts); | |
213 QStringList fonts; | |
214 | |
215 for (int index = 0; index < font_combo_box.count(); index++) | |
216 fonts << font_combo_box.itemText(index); | |
217 | 219 |
218 #if defined (Q_OS_MAC) | 220 #if defined (Q_OS_MAC) |
219 // Use hard coded default on macOS, since selection of fixed width | 221 // Use hard coded default on macOS, since selection of fixed width |
220 // default font is unreliable (see bug #59128). | 222 // default font is unreliable (see bug #59128). |
221 // Test for macOS default fixed width font | 223 // Test for macOS default fixed width font |