mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:37:34 +00:00
LibGfx+LibPDF: Apply subpixel offset in affine transformation
This commit is contained in:
parent
6c85088952
commit
eeb6072f15
6 changed files with 15 additions and 15 deletions
|
@ -351,8 +351,10 @@ RefPtr<Gfx::Bitmap> Glyf::Glyph::rasterize_simple(i16 font_ascender, i16 font_de
|
|||
u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 2;
|
||||
u32 height = (u32)(ceilf((font_ascender - font_descender) * y_scale)) + 2;
|
||||
Gfx::PathRasterizer rasterizer(Gfx::IntSize(width, height));
|
||||
rasterizer.translate(subpixel_offset.to_float_point());
|
||||
auto affine = Gfx::AffineTransform().scale(x_scale, -y_scale).translate(-m_xmin, -font_ascender);
|
||||
auto affine = Gfx::AffineTransform()
|
||||
.translate(subpixel_offset.to_float_point())
|
||||
.scale(x_scale, -y_scale)
|
||||
.translate(-m_xmin, -font_ascender);
|
||||
rasterize_impl(rasterizer, affine);
|
||||
return rasterizer.accumulate();
|
||||
}
|
||||
|
|
|
@ -126,8 +126,10 @@ public:
|
|||
u32 width = (u32)(ceilf((m_xmax - m_xmin) * x_scale)) + 1;
|
||||
u32 height = (u32)(ceilf((font_ascender - font_descender) * y_scale)) + 1;
|
||||
Gfx::PathRasterizer rasterizer(Gfx::IntSize(width, height));
|
||||
rasterizer.translate(subpixel_offset.to_float_point());
|
||||
auto affine = Gfx::AffineTransform().scale(x_scale, -y_scale).translate(-m_xmin, -font_ascender);
|
||||
auto affine = Gfx::AffineTransform()
|
||||
.translate(subpixel_offset.to_float_point())
|
||||
.scale(x_scale, -y_scale)
|
||||
.translate(-m_xmin, -font_ascender);
|
||||
|
||||
rasterize_composite_loop(rasterizer, affine, glyph_callback);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ PathRasterizer::PathRasterizer(Gfx::IntSize size)
|
|||
void PathRasterizer::draw_path(Gfx::Path& path)
|
||||
{
|
||||
for (auto& line : path.split_lines())
|
||||
draw_line(line.from.translated(translation()), line.to.translated(translation()));
|
||||
draw_line(line.from, line.to);
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> PathRasterizer::accumulate()
|
||||
|
|
|
@ -18,15 +18,10 @@ public:
|
|||
void draw_path(Gfx::Path&);
|
||||
RefPtr<Gfx::Bitmap> accumulate();
|
||||
|
||||
void translate(Gfx::FloatPoint delta) { m_translation.translate_by(delta); }
|
||||
Gfx::FloatPoint translation() const { return m_translation; }
|
||||
|
||||
private:
|
||||
void draw_line(Gfx::FloatPoint, Gfx::FloatPoint);
|
||||
|
||||
Gfx::IntSize m_size;
|
||||
Gfx::FloatPoint m_translation;
|
||||
|
||||
Vector<float> m_data;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue