mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibTTF+LibGfx: Make Gfx::Font::bold_variant() work for TTF fonts
There's no need for this to be a virtual, it's just a font database lookup and can be done in the Font base class.
This commit is contained in:
parent
9f601fcbcf
commit
f5e914fb9f
Notes:
sideshowbarker
2024-07-18 08:43:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f5e914fb9f2
|
@ -317,11 +317,11 @@ String BitmapFont::qualified_name() const
|
|||
return String::formatted("{} {} {}", family(), presentation_size(), weight());
|
||||
}
|
||||
|
||||
const Font& BitmapFont::bold_variant() const
|
||||
Font const& Font::bold_variant() const
|
||||
{
|
||||
if (m_bold_variant)
|
||||
return *m_bold_variant;
|
||||
m_bold_variant = Gfx::FontDatabase::the().get(m_family, m_presentation_size, 700);
|
||||
m_bold_variant = Gfx::FontDatabase::the().get(family(), presentation_size(), 700);
|
||||
if (!m_bold_variant)
|
||||
m_bold_variant = this;
|
||||
return *m_bold_variant;
|
||||
|
|
|
@ -105,8 +105,6 @@ public:
|
|||
|
||||
String qualified_name() const override;
|
||||
|
||||
Font const& bold_variant() const override;
|
||||
|
||||
static size_t glyph_count_by_type(FontTypes type);
|
||||
static String type_name_by_type(FontTypes type);
|
||||
|
||||
|
@ -143,8 +141,6 @@ private:
|
|||
|
||||
bool m_fixed_width { false };
|
||||
bool m_owns_arrays { false };
|
||||
|
||||
mutable RefPtr<Gfx::Font> m_bold_variant;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -121,7 +121,10 @@ public:
|
|||
|
||||
virtual String qualified_name() const = 0;
|
||||
|
||||
virtual const Font& bold_variant() const = 0;
|
||||
Font const& bold_variant() const;
|
||||
|
||||
private:
|
||||
mutable RefPtr<Gfx::Font> m_bold_variant;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Utf32View.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGfx/FontDatabase.h>
|
||||
#include <LibTTF/Cmap.h>
|
||||
#include <LibTTF/Font.h>
|
||||
#include <LibTTF/Glyf.h>
|
||||
|
|
|
@ -144,7 +144,6 @@ public:
|
|||
virtual String family() const override { return m_font->family(); }
|
||||
virtual String variant() const override { return m_font->variant(); }
|
||||
virtual String qualified_name() const override { return String::formatted("{} {} {}", family(), presentation_size(), weight()); }
|
||||
virtual const Font& bold_variant() const override { return *this; } // FIXME: Perhaps remove this from the Gfx::Font interface
|
||||
|
||||
private:
|
||||
NonnullRefPtr<TTF::Font> m_font;
|
||||
|
|
Loading…
Reference in a new issue