13 #include <QDirIterator>
14 #include <QFontDatabase>
15 #include <QGuiApplication>
22 static void configure_font(
const QString &font_name,
const QStringList &sl,
23 QFont::StyleHint hint,
int size,
66 font.setPointSizeF(font.pointSizeF() * zoom);
105 int old_size = font.pointSize();
106 font.setPointSize(old_size + (new_size * old_size) / 100);
132 QFontDatabase database;
134 return database.families().contains(font_name);
145 for (
const auto &info : qAsConst(il)) {
148 {QStringLiteral(
"*.otf"), QStringLiteral(
"*.ttf")}, QDir::Files,
149 QDirIterator::Subdirectories);
164 const int large_size = 16;
165 const int default_size = 12;
173 sl << QStringLiteral(
"Libertinus Sans")
174 << QStringLiteral(
"Linux Biolinum O")
175 << QStringLiteral(
"Linux Biolinum");
185 sl << QStringLiteral(
"Libertinus Mono")
186 << QStringLiteral(
"Linux Libertine Mono O")
187 << QStringLiteral(
"Linux Libertine Mono");
196 sl << QStringLiteral(
"Libertinus Serif Display")
197 << QStringLiteral(
"Linux Libertine Display O")
198 << QStringLiteral(
"Linux Libertine Display");
207 QFont::StyleHint hint,
int size,
bool bold)
213 QFontDatabase database;
216 for (
auto const &str : sl) {
217 if (database.families().contains(str)) {
218 font = QFont(str,
size,
bold ? QFont::Bold : QFont::Normal);
219 font.setStyleHint(hint);
227 font.setStyleHint(hint);
void initFonts()
Initiazlizes fonts from client options.
QMap< QString, QFont > font_map
void setSizeAll(int)
Increases/decreases all fonts sizes.
void releaseFonts()
Deletes all fonts.
fcFont()
Font provider constructor.
QFont getFont(const QString &name, double zoom=1.0) const
Returns desired font.
static fcFont * m_instance
static void drop()
Deletes fc_icons instance.
static fcFont * instance()
Returns instance of fc_font.
void setFont(const QString &name, const QFont &qf)
Adds new font or overwrite old one.
void load_fonts()
Loads the fonts into the font database.
static void configure_font(const QString &font_name, const QStringList &sl, QFont::StyleHint hint, int size, bool bold=false)
Returns long font name, sets given for for use.
bool isFontInstalled(const QString &font_name)
Returns if a font is installed.
void configure_fonts()
Tries to choose good fonts for Freeciv21.
void gui_qt_apply_font(struct option *poption)
Change the given font.
#define fc_assert_ret(condition)
const char *const city_productions
const char *const chatline
const char *const default_font
const char *const notify_label
const char *const help_label
const char *const city_names
const char *const help_text
const char *const reqtree_text
const char * option_name(const struct option *poption)
Returns the name of the option.
client_options * gui_options
const struct option_set * client_optset
bool option_font_set(struct option *poption, const QFont &font)
Sets the value of this font option.
struct option * optset_option_by_name(const struct option_set *poptset, const char *name)
Returns the option corresponding of the name in this option set.
enum option_type option_type(const struct option *poption)
Returns the type of the option.
void option_font_set_default(const struct option *poption, const QFont &font)
Returns the default value of this font option.
QFont option_font_get(const struct option *poption)
Returns the current value of this font option.
#define options_iterate(poptset, poption)
#define options_iterate_end
const QStringList & get_data_dirs()
Returns a list of data directory paths, in the order in which they should be searched.
QFileInfoList find_files_in_path(const QStringList &path, const QString &pattern, bool nodups)
Search for file names matching the pattern in the provided list of directories.
void(* next)(struct iterator *it)