LibGfx: Remove single-code point Font::glyph_or_emoji_width API

All callers are now aware of multi-code point emoji (and must remain so
going forward).
This commit is contained in:
Timothy Flynn 2023-02-22 12:43:21 -05:00 committed by Linus Groh
parent 16ec116133
commit 34567bc145
Notes: sideshowbarker 2024-07-16 23:48:04 +09:00
6 changed files with 11 additions and 21 deletions

View file

@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Utf8View.h>
#include <LibGfx/Font/BitmapFont.h>
#include <LibGfx/Font/FontDatabase.h>
#include <LibTest/TestCase.h>
@ -125,7 +126,10 @@ TEST_CASE(test_glyph_or_emoji_width)
u8 glyph_width = 1;
auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256);
EXPECT(font->glyph_or_emoji_width(0));
Utf8View view { " "sv };
auto it = view.begin();
EXPECT(font->glyph_or_emoji_width(it));
}
TEST_CASE(test_load_from_file)

View file

@ -326,14 +326,6 @@ static float glyph_or_emoji_width_impl(BitmapFont const& font, CodePointIterator
return font.glyph_width(*it);
}
float BitmapFont::glyph_or_emoji_width(u32 code_point) const
{
Utf32View code_point_view { &code_point, 1 };
auto it = code_point_view.begin();
return glyph_or_emoji_width_impl(*this, it);
}
float BitmapFont::glyph_or_emoji_width(Utf8CodePointIterator& it) const
{
return glyph_or_emoji_width_impl(*this, it);

View file

@ -61,7 +61,6 @@ public:
bool contains_glyph(u32 code_point) const override;
bool contains_raw_glyph(u32 code_point) const { return m_glyph_widths[code_point] > 0; }
virtual float glyph_or_emoji_width(u32) const override;
virtual float glyph_or_emoji_width(Utf8CodePointIterator&) const override;
virtual float glyph_or_emoji_width(Utf32CodePointIterator&) const override;

View file

@ -167,7 +167,6 @@ public:
virtual float glyph_left_bearing(u32 code_point) const = 0;
virtual float glyph_width(u32 code_point) const = 0;
virtual float glyph_or_emoji_width(u32 code_point) const = 0;
virtual float glyph_or_emoji_width(Utf8CodePointIterator&) const = 0;
virtual float glyph_or_emoji_width(Utf32CodePointIterator&) const = 0;
virtual float glyphs_horizontal_kerning(u32 left_code_point, u32 right_code_point) const = 0;

View file

@ -98,23 +98,20 @@ float ScaledFont::glyph_width(u32 code_point) const
return metrics.advance_width;
}
float ScaledFont::glyph_or_emoji_width(u32 code_point) const
{
auto id = glyph_id_for_code_point(code_point);
auto metrics = glyph_metrics(id);
return metrics.advance_width;
}
float ScaledFont::glyph_or_emoji_width(Utf8CodePointIterator& it) const
{
// FIXME: Support multi-code point emoji with scaled fonts.
return glyph_or_emoji_width(*it);
auto id = glyph_id_for_code_point(*it);
auto metrics = glyph_metrics(id);
return metrics.advance_width;
}
float ScaledFont::glyph_or_emoji_width(Utf32CodePointIterator& it) const
{
// FIXME: Support multi-code point emoji with scaled fonts.
return glyph_or_emoji_width(*it);
auto id = glyph_id_for_code_point(*it);
auto metrics = glyph_metrics(id);
return metrics.advance_width;
}
float ScaledFont::glyphs_horizontal_kerning(u32 left_code_point, u32 right_code_point) const

View file

@ -46,7 +46,6 @@ public:
virtual Glyph glyph(u32 code_point, GlyphSubpixelOffset) const override;
virtual bool contains_glyph(u32 code_point) const override { return m_font->glyph_id_for_code_point(code_point) > 0; }
virtual float glyph_width(u32 code_point) const override;
virtual float glyph_or_emoji_width(u32 code_point) const override;
virtual float glyph_or_emoji_width(Utf8CodePointIterator&) const override;
virtual float glyph_or_emoji_width(Utf32CodePointIterator&) const override;
virtual float glyphs_horizontal_kerning(u32 left_code_point, u32 right_code_point) const override;