mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-17 01:10:28 +03:00
Ladybird: Explicitly set the font family for CSS generic fonts
We currently query Qt for system fonts using QFont::setStyleHint(). The docs from Qt have the following note regarding this API on X11: Qt does not support style hints on X11 since this information is not provided by the window system. This prevents any monospace font from working on X11 systems. For now, work around this by specifying the font-family for fonts which Qt has listed as mapping to a CSS generic font-family.
This commit is contained in:
parent
9fe6dcb50b
commit
d44df16704
Notes:
sideshowbarker
2024-07-17 02:23:25 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d44df16704 Pull-request: https://github.com/SerenityOS/serenity/pull/18516
@ -68,9 +68,19 @@ void FontPluginQt::update_generic_fonts()
|
||||
|
||||
m_generic_font_names.resize(static_cast<size_t>(Web::Platform::GenericFont::__Count));
|
||||
|
||||
auto update_mapping = [&](Web::Platform::GenericFont generic_font, QFont::StyleHint qfont_style_hint, Vector<DeprecatedString> fallbacks = {}) {
|
||||
auto update_mapping = [&](Web::Platform::GenericFont generic_font, QFont::StyleHint qfont_style_hint, ReadonlySpan<DeprecatedString> fallbacks) {
|
||||
QFont qt_font;
|
||||
qt_font.setStyleHint(qfont_style_hint);
|
||||
|
||||
// NOTE: This is a workaround for setStyleHint being a no-op on X11 systems. See:
|
||||
// https://doc.qt.io/qt-6/qfont.html#setStyleHint
|
||||
if (generic_font == Web::Platform::GenericFont::Monospace)
|
||||
qt_font.setFamily("monospace");
|
||||
else if (generic_font == Web::Platform::GenericFont::Fantasy)
|
||||
qt_font.setFamily("fantasy");
|
||||
else if (generic_font == Web::Platform::GenericFont::Cursive)
|
||||
qt_font.setFamily("cursive");
|
||||
|
||||
QFontInfo qt_info(qt_font);
|
||||
auto qt_font_family = qt_info.family();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user