1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

LibTTF: Rename "raster" => "rasterize"

This commit is contained in:
Andreas Kling 2021-07-19 20:46:30 +02:00
parent 8070bbd442
commit 7b3a4f8281
4 changed files with 17 additions and 17 deletions

View file

@ -410,14 +410,14 @@ ScaledGlyphMetrics Font::glyph_metrics(u32 glyph_id, float x_scale, float y_scal
} }
// FIXME: "loca" and "glyf" are not available for CFF fonts. // FIXME: "loca" and "glyf" are not available for CFF fonts.
RefPtr<Gfx::Bitmap> Font::raster_glyph(u32 glyph_id, float x_scale, float y_scale) const RefPtr<Gfx::Bitmap> Font::rasterize_glyph(u32 glyph_id, float x_scale, float y_scale) const
{ {
if (glyph_id >= glyph_count()) { if (glyph_id >= glyph_count()) {
glyph_id = 0; glyph_id = 0;
} }
auto glyph_offset = m_loca.get_glyph_offset(glyph_id); auto glyph_offset = m_loca.get_glyph_offset(glyph_id);
auto glyph = m_glyf.glyph(glyph_offset); auto glyph = m_glyf.glyph(glyph_offset);
return glyph.raster(x_scale, y_scale, [&](u16 glyph_id) { return glyph.rasterize(x_scale, y_scale, [&](u16 glyph_id) {
if (glyph_id >= glyph_count()) { if (glyph_id >= glyph_count()) {
glyph_id = 0; glyph_id = 0;
} }
@ -513,13 +513,13 @@ ALWAYS_INLINE int ScaledFont::unicode_view_width(T const& view) const
return longest_width; return longest_width;
} }
RefPtr<Gfx::Bitmap> ScaledFont::raster_glyph(u32 glyph_id) const RefPtr<Gfx::Bitmap> ScaledFont::rasterize_glyph(u32 glyph_id) const
{ {
auto glyph_iterator = m_cached_glyph_bitmaps.find(glyph_id); auto glyph_iterator = m_cached_glyph_bitmaps.find(glyph_id);
if (glyph_iterator != m_cached_glyph_bitmaps.end()) if (glyph_iterator != m_cached_glyph_bitmaps.end())
return glyph_iterator->value; return glyph_iterator->value;
auto glyph_bitmap = m_font->raster_glyph(glyph_id, m_x_scale, m_y_scale); auto glyph_bitmap = m_font->rasterize_glyph(glyph_id, m_x_scale, m_y_scale);
m_cached_glyph_bitmaps.set(glyph_id, glyph_bitmap); m_cached_glyph_bitmaps.set(glyph_id, glyph_bitmap);
return glyph_bitmap; return glyph_bitmap;
} }
@ -527,7 +527,7 @@ RefPtr<Gfx::Bitmap> ScaledFont::raster_glyph(u32 glyph_id) const
Gfx::Glyph ScaledFont::glyph(u32 code_point) const Gfx::Glyph ScaledFont::glyph(u32 code_point) const
{ {
auto id = glyph_id_for_code_point(code_point); auto id = glyph_id_for_code_point(code_point);
auto bitmap = raster_glyph(id); auto bitmap = rasterize_glyph(id);
auto metrics = glyph_metrics(id); auto metrics = glyph_metrics(id);
return Gfx::Glyph(bitmap, metrics.left_side_bearing, metrics.advance_width, metrics.ascender); return Gfx::Glyph(bitmap, metrics.left_side_bearing, metrics.advance_width, metrics.ascender);
} }

View file

@ -50,7 +50,7 @@ public:
ScaledFontMetrics metrics(float x_scale, float y_scale) const; ScaledFontMetrics metrics(float x_scale, float y_scale) const;
ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale) const; ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale) const;
RefPtr<Gfx::Bitmap> raster_glyph(u32 glyph_id, float x_scale, float y_scale) const; RefPtr<Gfx::Bitmap> rasterize_glyph(u32 glyph_id, float x_scale, float y_scale) const;
u32 glyph_count() const; u32 glyph_count() const;
u16 units_per_em() const; u16 units_per_em() const;
u32 glyph_id_for_code_point(u32 code_point) const { return m_cmap.glyph_id_for_code_point(code_point); } u32 glyph_id_for_code_point(u32 code_point) const { return m_cmap.glyph_id_for_code_point(code_point); }
@ -115,7 +115,7 @@ public:
u32 glyph_id_for_code_point(u32 code_point) const { return m_font->glyph_id_for_code_point(code_point); } u32 glyph_id_for_code_point(u32 code_point) const { return m_font->glyph_id_for_code_point(code_point); }
ScaledFontMetrics metrics() const { return m_font->metrics(m_x_scale, m_y_scale); } ScaledFontMetrics metrics() const { return m_font->metrics(m_x_scale, m_y_scale); }
ScaledGlyphMetrics glyph_metrics(u32 glyph_id) const { return m_font->glyph_metrics(glyph_id, m_x_scale, m_y_scale); } ScaledGlyphMetrics glyph_metrics(u32 glyph_id) const { return m_font->glyph_metrics(glyph_id, m_x_scale, m_y_scale); }
RefPtr<Gfx::Bitmap> raster_glyph(u32 glyph_id) const; RefPtr<Gfx::Bitmap> rasterize_glyph(u32 glyph_id) const;
// Gfx::Font implementation // Gfx::Font implementation
virtual NonnullRefPtr<Font> clone() const override { return *this; } // FIXME: clone() should not need to be implemented virtual NonnullRefPtr<Font> clone() const override { return *this; } // FIXME: clone() should not need to be implemented

View file

@ -380,7 +380,7 @@ static void get_ttglyph_offsets(ReadonlyBytes const& slice, u32 num_points, u32
*y_offset = *x_offset + x_size; *y_offset = *x_offset + x_size;
} }
void Glyf::Glyph::raster_inner(Rasterizer& rasterizer, Gfx::AffineTransform& affine) const void Glyf::Glyph::rasterize_impl(Rasterizer& rasterizer, Gfx::AffineTransform& affine) const
{ {
// Get offset for flags, x, and y. // Get offset for flags, x, and y.
u16 num_points = be_u16(m_slice.offset_pointer((m_num_contours - 1) * 2)) + 1; u16 num_points = be_u16(m_slice.offset_pointer((m_num_contours - 1) * 2)) + 1;
@ -476,13 +476,13 @@ void Glyf::Glyph::raster_inner(Rasterizer& rasterizer, Gfx::AffineTransform& aff
rasterizer.draw_path(path); rasterizer.draw_path(path);
} }
RefPtr<Gfx::Bitmap> Glyf::Glyph::raster_simple(float x_scale, float y_scale) const RefPtr<Gfx::Bitmap> Glyf::Glyph::rasterize_simple(float x_scale, float y_scale) const
{ {
u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 2; u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 2;
u32 height = (u32)(ceilf((m_ymax - m_ymin) * y_scale)) + 2; u32 height = (u32)(ceilf((m_ymax - m_ymin) * y_scale)) + 2;
Rasterizer rasterizer(Gfx::IntSize(width, height)); Rasterizer rasterizer(Gfx::IntSize(width, height));
auto affine = Gfx::AffineTransform().scale(x_scale, -y_scale).translate(-m_xmin, -m_ymax); auto affine = Gfx::AffineTransform().scale(x_scale, -y_scale).translate(-m_xmin, -m_ymax);
raster_inner(rasterizer, affine); rasterize_impl(rasterizer, affine);
return rasterizer.accumulate(); return rasterizer.accumulate();
} }

View file

@ -63,13 +63,13 @@ public:
} }
} }
template<typename GlyphCb> template<typename GlyphCb>
RefPtr<Gfx::Bitmap> raster(float x_scale, float y_scale, GlyphCb glyph_callback) const RefPtr<Gfx::Bitmap> rasterize(float x_scale, float y_scale, GlyphCb glyph_callback) const
{ {
switch (m_type) { switch (m_type) {
case Type::Simple: case Type::Simple:
return raster_simple(x_scale, y_scale); return rasterize_simple(x_scale, y_scale);
case Type::Composite: case Type::Composite:
return raster_composite(x_scale, y_scale, glyph_callback); return rasterize_composite(x_scale, y_scale, glyph_callback);
} }
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }
@ -101,10 +101,10 @@ public:
u32 m_offset { 0 }; u32 m_offset { 0 };
}; };
void raster_inner(Rasterizer&, Gfx::AffineTransform&) const; void rasterize_impl(Rasterizer& rasterizer, Gfx::AffineTransform& affine) const;
RefPtr<Gfx::Bitmap> raster_simple(float x_scale, float y_scale) const; RefPtr<Gfx::Bitmap> rasterize_simple(float x_scale, float y_scale) const;
template<typename GlyphCb> template<typename GlyphCb>
RefPtr<Gfx::Bitmap> raster_composite(float x_scale, float y_scale, GlyphCb glyph_callback) const RefPtr<Gfx::Bitmap> rasterize_composite(float x_scale, float y_scale, GlyphCb glyph_callback) const
{ {
u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 1; u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 1;
u32 height = (u32)(ceilf((m_ymax - m_ymin) * y_scale)) + 1; u32 height = (u32)(ceilf((m_ymax - m_ymin) * y_scale)) + 1;
@ -119,7 +119,7 @@ public:
auto item = opt_item.value(); auto item = opt_item.value();
auto affine_here = affine.multiply(item.affine); auto affine_here = affine.multiply(item.affine);
auto glyph = glyph_callback(item.glyph_id); auto glyph = glyph_callback(item.glyph_id);
glyph.raster_inner(rasterizer, affine_here); glyph.rasterize_impl(rasterizer, affine_here);
} }
return rasterizer.accumulate(); return rasterizer.accumulate();
} }