mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:47:35 +00:00
LibGUI+LibGfx+LibTTF: Make fontpicker handle TTF fonts
This commit is contained in:
parent
5a70ccecb3
commit
0f41f5d9ba
6 changed files with 46 additions and 21 deletions
|
@ -159,6 +159,7 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(const StringView& name)
|
|||
|
||||
RefPtr<Gfx::Font> FontDatabase::get(const String& family, unsigned size, unsigned weight)
|
||||
{
|
||||
dbgln("FontDatabase: Request font {} {} {}", family, size, weight);
|
||||
for (auto typeface : m_private->typefaces) {
|
||||
if (typeface->family() == family && typeface->weight() == weight)
|
||||
return typeface->get_font(size);
|
||||
|
|
|
@ -38,6 +38,16 @@ unsigned Typeface::weight() const
|
|||
return m_ttf_font->weight();
|
||||
}
|
||||
|
||||
bool Typeface::is_fixed_width() const
|
||||
{
|
||||
ASSERT(m_ttf_font || m_bitmap_fonts.size() > 0);
|
||||
|
||||
if (is_fixed_size())
|
||||
return m_bitmap_fonts[0]->is_fixed_width();
|
||||
|
||||
return m_ttf_font->is_fixed_width();
|
||||
}
|
||||
|
||||
void Typeface::add_bitmap_font(RefPtr<BitmapFont> font)
|
||||
{
|
||||
m_bitmap_fonts.append(font);
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
String variant() const { return m_variant; }
|
||||
unsigned weight() const;
|
||||
|
||||
bool is_fixed_width() const;
|
||||
bool is_fixed_size() const { return !m_bitmap_fonts.is_empty(); }
|
||||
void for_each_fixed_size_font(Function<void(const Font&)>) const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue