19#include <QApplication>
20#include <QFontDatabase>
21#include <QGuiApplication>
134 char *font_opt,
bool bold =
false)
142 fn_bytes = role.toUtf8();
143 log_error(
_(
"Failed to setup font for role %s."),
158 int max, smaller, default_size;
161 const QScreen *screen = QApplication::primaryScreen();
162 qreal logical_dpi = screen->logicalDotsPerInchX();
163 qreal physical_dpi = screen->physicalDotsPerInchX();
164 qreal screen_size = screen->geometry().width() / physical_dpi + 5;
165 qreal scale = (physical_dpi * screen_size / (logical_dpi * 27))
166 / screen->devicePixelRatio();
168 max = qRound(scale * 16);
169 smaller = qRound(scale * 12);
170 default_size = qRound(scale *14);
173 sl <<
"Segoe UI" <<
"Cousine" <<
"Liberation Sans" <<
"Droid Sans"
174 <<
"Ubuntu" <<
"Noto Sans" <<
"DejaVu Sans" <<
"Luxi Sans"
175 <<
"Lucida Sans" <<
"Trebuchet MS" <<
"Times New Roman";
189 sl <<
"Cousine" <<
"Liberation Mono" <<
"Source Code Pro"
190 <<
"Source Code Pro [ADBO]"
191 <<
"Noto Mono" <<
"Ubuntu Mono" <<
"Courier New";
202 sl <<
"Arimo" <<
"Play" <<
"Tinos" <<
"Ubuntu" <<
"Times New Roman"
203 <<
"Droid Sans" <<
"Noto Sans";
210 sl <<
"Papyrus" <<
"Segoe Script" <<
"Comic Sans MS"
211 <<
"Droid Sans" <<
"Noto Sans" <<
"Ubuntu";
224 QFontDatabase database;
236 QList<int> sizes = QFontDatabase::smoothSizes(
str, style);
238 QList<int> sizes = database.smoothSizes(
str, style);
241 if (!sizes.isEmpty()) {
242 QListIterator<int> i(sizes);
247 while (i.hasNext()) {
250 if (cur <=
size && lower < cur) {
253 if (cur >=
size && (upper < 0 || upper > cur)) {
269 fn_bytes = f->toString().toUtf8();
271 return fn_bytes.data();
static QString bold(QString text)
static fc_font * m_instance
static fc_font * instance()
void set_font(QString name, QFont *qf)
QFont * get_font(QString name)
QMap< QString, QFont * > font_map
QString configure_font(QString font_name, QStringList sl, int size, bool bold)
static void configure_single(QString role, QStringList sl, int size, char *font_opt, bool bold=false)
#define log_error(message,...)
const char *const city_productions
const char *const chatline
const char *const default_font
const char *const notify_label
const char *const city_names
const char *const help_text
const char *const reqtree_text
const struct option_set * client_optset
const char * option_name(const struct option *poption)
enum option_type option_type(const struct option *poption)
struct client_options gui_options
const char * option_font_get(const struct option *poption)
#define options_iterate(poptset, poption)
#define options_iterate_end
char gui_qt_font_city_names[FONT_NAME_SIZE]
char gui_qt_font_city_productions[FONT_NAME_SIZE]
char gui_qt_font_help_text[FONT_NAME_SIZE]
char gui_qt_font_default[FONT_NAME_SIZE]
char gui_qt_font_reqtree_text[FONT_NAME_SIZE]
char gui_qt_font_chatline[FONT_NAME_SIZE]
char gui_qt_font_notify_label[FONT_NAME_SIZE]
size_t fc_strlcpy(char *dest, const char *src, size_t n)