mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibGfx: Remove unused font code dealing with left-side bearing
This commit is contained in:
parent
d4d7feffca
commit
3ed0381a2a
Notes:
github-actions[bot]
2024-08-20 07:37:16 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/3ed0381a2a7 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1024
7 changed files with 4 additions and 28 deletions
|
@ -76,7 +76,6 @@ public:
|
|||
virtual bool contains_glyph(u32 code_point) const = 0;
|
||||
|
||||
virtual u32 glyph_id_for_code_point(u32 code_point) const = 0;
|
||||
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(Utf8CodePointIterator&) const = 0;
|
||||
virtual float glyphs_horizontal_kerning(u32 left_code_point, u32 right_code_point) const = 0;
|
||||
|
|
|
@ -63,12 +63,6 @@ ALWAYS_INLINE float ScaledFont::unicode_view_width(T const& view) const
|
|||
return longest_width;
|
||||
}
|
||||
|
||||
float ScaledFont::glyph_left_bearing(u32 code_point) const
|
||||
{
|
||||
auto id = glyph_id_for_code_point(code_point);
|
||||
return glyph_metrics(id).left_side_bearing;
|
||||
}
|
||||
|
||||
float ScaledFont::glyph_width(u32 code_point) const
|
||||
{
|
||||
auto id = glyph_id_for_code_point(code_point);
|
||||
|
|
|
@ -29,7 +29,6 @@ public:
|
|||
virtual Gfx::FontPixelMetrics pixel_metrics() const override;
|
||||
virtual u8 slope() const override { return m_typeface->slope(); }
|
||||
virtual u16 weight() const override { return m_typeface->weight(); }
|
||||
virtual float glyph_left_bearing(u32 code_point) const override;
|
||||
virtual bool contains_glyph(u32 code_point) const override { return m_typeface->glyph_id_for_code_point(code_point) > 0; }
|
||||
virtual float glyph_width(u32 code_point) const override;
|
||||
virtual float glyph_or_emoji_width(Utf8CodePointIterator&) const override;
|
||||
|
|
|
@ -22,7 +22,7 @@ static DrawGlyphOrEmoji construct_glyph_or_emoji(size_t index, FloatPoint const&
|
|||
};
|
||||
}
|
||||
|
||||
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, Gfx::Font const& font, Function<void(DrawGlyphOrEmoji const&)> callback, IncludeLeftBearing include_left_bearing, Optional<float&> width)
|
||||
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, Gfx::Font const& font, Function<void(DrawGlyphOrEmoji const&)> callback, Optional<float&> width)
|
||||
{
|
||||
hb_buffer_t* buffer = hb_buffer_create();
|
||||
ScopeGuard destroy_buffer = [&]() { hb_buffer_destroy(buffer); };
|
||||
|
@ -46,12 +46,6 @@ void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, Gfx::Fo
|
|||
auto position = point
|
||||
- FloatPoint { 0, font.pixel_metrics().ascent }
|
||||
+ FloatPoint { positions[i].x_offset, positions[i].y_offset } / text_shaping_resolution;
|
||||
if (include_left_bearing == IncludeLeftBearing::Yes) {
|
||||
VERIFY(is<Gfx::ScaledFont>(font));
|
||||
auto bearing = static_cast<Gfx::ScaledFont const&>(font).glyph_metrics(glyph_info[i].codepoint).left_side_bearing;
|
||||
position += FloatPoint { bearing, 0 };
|
||||
}
|
||||
|
||||
callback(construct_glyph_or_emoji(i, position, font, { glyph_info, glyph_count }, input_glyph_info.span()));
|
||||
point += FloatPoint { positions[i].x_advance, positions[i].y_advance } / text_shaping_resolution;
|
||||
}
|
||||
|
|
|
@ -20,16 +20,6 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
inline bool should_paint_as_space(u32 code_point)
|
||||
{
|
||||
return is_ascii_space(code_point) || code_point == 0xa0;
|
||||
}
|
||||
|
||||
enum class IncludeLeftBearing {
|
||||
Yes,
|
||||
No
|
||||
};
|
||||
|
||||
struct DrawGlyph {
|
||||
FloatPoint position;
|
||||
u32 glyph_id;
|
||||
|
@ -72,6 +62,6 @@ private:
|
|||
NonnullRefPtr<Font> m_font;
|
||||
};
|
||||
|
||||
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, Gfx::Font const& font, Function<void(DrawGlyphOrEmoji const&)> callback, IncludeLeftBearing include_left_bearing = IncludeLeftBearing::No, Optional<float&> width = {});
|
||||
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, Gfx::Font const& font, Function<void(DrawGlyphOrEmoji const&)> callback, Optional<float&> width = {});
|
||||
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
|
|||
{ 0, 0 }, chunk.view, chunk.font, [&](Gfx::DrawGlyphOrEmoji const& glyph_or_emoji) {
|
||||
glyph_run.append(glyph_or_emoji);
|
||||
},
|
||||
Gfx::IncludeLeftBearing::No, glyph_run_width);
|
||||
glyph_run_width);
|
||||
|
||||
CSSPixels chunk_width = CSSPixels::nearest_value_for(glyph_run_width);
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ void DisplayListRecorder::draw_text(Gfx::IntRect const& rect, String raw_text, G
|
|||
{ 0, 0 }, raw_text.code_points(), font, [&](Gfx::DrawGlyphOrEmoji const& glyph_or_emoji) {
|
||||
glyph_run->append(glyph_or_emoji);
|
||||
},
|
||||
Gfx::IncludeLeftBearing::No, glyph_run_width);
|
||||
glyph_run_width);
|
||||
|
||||
float baseline_x = 0;
|
||||
if (alignment == Gfx::TextAlignment::CenterLeft) {
|
||||
|
|
Loading…
Reference in a new issue