LibGfx: Remove Font::qualified_name() and some FontDatabase APIs

...because the FontDatabase APIs were not used, and they were the only
users of qualified_name().
This commit is contained in:
Andreas Kling 2024-06-04 15:55:27 +02:00
parent eccfdede10
commit d95f5692a3
Notes: sideshowbarker 2024-07-18 03:35:30 +09:00
4 changed files with 0 additions and 47 deletions

View File

@ -186,8 +186,6 @@ public:
virtual String family() const = 0;
virtual String variant() const = 0;
virtual String qualified_name() const = 0;
virtual NonnullRefPtr<Font> with_size(float point_size) const = 0;
Font const& bold_variant() const;

View File

@ -8,13 +8,10 @@
#include <AK/FlyString.h>
#include <AK/LexicalPath.h>
#include <AK/Queue.h>
#include <AK/QuickSort.h>
#include <LibCore/Resource.h>
#include <LibFileSystem/FileSystem.h>
#include <LibGfx/Font/Font.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibGfx/Font/OpenType/Font.h>
#include <LibGfx/Font/Typeface.h>
#include <LibGfx/Font/WOFF/Font.h>
namespace Gfx {
@ -66,35 +63,6 @@ FontDatabase::FontDatabase()
load_all_fonts_from_uri("resource://fonts"sv);
}
void FontDatabase::for_each_font(Function<void(Gfx::Font const&)> callback)
{
Vector<RefPtr<Gfx::Font>> fonts;
fonts.ensure_capacity(m_private->full_name_to_font_map.size());
for (auto& it : m_private->full_name_to_font_map)
fonts.append(it.value);
quick_sort(fonts, [](auto& a, auto& b) { return a->qualified_name() < b->qualified_name(); });
for (auto& font : fonts)
callback(*font);
}
RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
{
auto it = m_private->full_name_to_font_map.find(name);
if (it == m_private->full_name_to_font_map.end()) {
auto parts = name.split_view(" "sv);
if (parts.size() >= 4) {
auto slope = parts.take_last().to_number<int>().value_or(0);
auto weight = parts.take_last().to_number<int>().value_or(0);
auto size = parts.take_last().to_number<int>().value_or(0);
auto family = MUST(String::join(' ', parts));
return get(family, size, weight, Gfx::FontWidth::Normal, slope);
}
dbgln("Font lookup failed: '{}'", name);
return nullptr;
}
return it->value;
}
RefPtr<Gfx::Font> FontDatabase::get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope)
{
auto it = m_private->typefaces.find(family);
@ -133,15 +101,6 @@ RefPtr<Typeface> FontDatabase::get_or_create_typeface(FlyString const& family, F
return typeface;
}
void FontDatabase::for_each_typeface(Function<void(Typeface const&)> callback)
{
for (auto const& it : m_private->typefaces) {
for (auto const& jt : it.value) {
callback(*jt);
}
}
}
void FontDatabase::for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)> callback)
{
auto it = m_private->typefaces.find(family_name);

View File

@ -23,10 +23,7 @@ public:
RefPtr<Gfx::Font> get(FlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope);
RefPtr<Gfx::Font> get(FlyString const& family, FlyString const& variant, float point_size);
RefPtr<Gfx::Font> get_by_name(StringView);
void for_each_font(Function<void(Gfx::Font const&)>);
void for_each_typeface(Function<void(Typeface const&)>);
void for_each_typeface_with_family_name(FlyString const& family_name, Function<void(Typeface const&)>);
void load_all_fonts_from_uri(StringView);

View File

@ -56,7 +56,6 @@ public:
virtual String name() const override { return MUST(String::formatted("{} {}", family(), variant())); }
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 MUST(String::formatted("{} {} {} {}", family(), presentation_size(), weight(), slope())); }
virtual NonnullRefPtr<ScaledFont> scaled_with_size(float point_size) const;
virtual NonnullRefPtr<Font> with_size(float point_size) const override;