LibGfx: Return family names by reference to avoid unnecessairy cloning

This commit is contained in:
Jonne Ransijn 2024-10-26 23:27:21 +02:00 committed by Andreas Kling
parent b3c253e50f
commit ec5ea0d686
Notes: github-actions[bot] 2024-11-20 14:39:14 +00:00
6 changed files with 6 additions and 6 deletions

View file

@ -85,7 +85,7 @@ public:
virtual float width(StringView) const = 0;
virtual float width(Utf8View const&) const = 0;
virtual FlyString family() const = 0;
virtual FlyString const& family() const = 0;
virtual NonnullRefPtr<Font> with_size(float point_size) const = 0;

View file

@ -37,7 +37,7 @@ public:
virtual u8 baseline() const override { return m_point_height; } // FIXME: Read from font
virtual float width(StringView) const override;
virtual float width(Utf8View const&) const override;
virtual FlyString family() const override { return m_typeface->family(); }
virtual FlyString const& family() const override { return m_typeface->family(); }
virtual NonnullRefPtr<ScaledFont> scaled_with_size(float point_size) const;
virtual NonnullRefPtr<Font> with_size(float point_size) const override;

View file

@ -47,7 +47,7 @@ public:
virtual u32 glyph_count() const = 0;
virtual u16 units_per_em() const = 0;
virtual u32 glyph_id_for_code_point(u32 code_point) const = 0;
virtual FlyString family() const = 0;
virtual FlyString const& family() const = 0;
virtual u16 weight() const = 0;
virtual u16 width() const = 0;
virtual u8 slope() const = 0;

View file

@ -114,7 +114,7 @@ void TypefaceSkia::populate_glyph_page(GlyphPage& glyph_page, size_t page_index)
}
}
FlyString TypefaceSkia::family() const
FlyString const& TypefaceSkia::family() const
{
if (!m_family.has_value()) {
SkString family_name;

View file

@ -19,7 +19,7 @@ public:
virtual u32 glyph_count() const override;
virtual u16 units_per_em() const override;
virtual u32 glyph_id_for_code_point(u32 code_point) const override;
virtual FlyString family() const override;
virtual FlyString const& family() const override;
virtual u16 weight() const override;
virtual u16 width() const override;
virtual u8 slope() const override;

View file

@ -30,7 +30,7 @@ public:
Optional<Percentage> ascent_override() const { return m_ascent_override; }
Optional<Percentage> descent_override() const { return m_descent_override; }
FontDisplay font_display() const { return m_font_display; }
FlyString font_family() const { return m_font_family; }
FlyString const& font_family() const { return m_font_family; }
Optional<OrderedHashMap<FlyString, i64>> font_feature_settings() const { return m_font_feature_settings; }
Optional<FlyString> font_language_override() const { return m_font_language_override; }
Optional<FlyString> font_named_instance() const { return m_font_named_instance; }