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

LibPDF: Use subpixel accurate text rendering

This just enables the new tricks from LibGfx with the same nice
improvements :^)
This commit is contained in:
MacDue 2023-01-05 01:34:07 +00:00 committed by Andreas Kling
parent 6632023498
commit 91db49f7b3
9 changed files with 24 additions and 18 deletions

View file

@ -94,15 +94,16 @@ PDFErrorOr<void> PS1FontProgram::create(ReadonlyBytes const& bytes, RefPtr<Encod
return parse_encrypted_portion(decrypted);
}
RefPtr<Gfx::Bitmap> PS1FontProgram::rasterize_glyph(u32 char_code, float width)
RefPtr<Gfx::Bitmap> PS1FontProgram::rasterize_glyph(u32 char_code, float width, Gfx::GlyphSubpixelOffset subpixel_offset)
{
auto path = build_char(char_code, width);
auto bounding_box = path.bounding_box().size();
u32 w = (u32)ceilf(bounding_box.width()) + 1;
u32 h = (u32)ceilf(bounding_box.height()) + 1;
u32 w = (u32)ceilf(bounding_box.width()) + 2;
u32 h = (u32)ceilf(bounding_box.height()) + 2;
Gfx::PathRasterizer rasterizer(Gfx::IntSize(w, h));
rasterizer.translate(subpixel_offset.to_float_point());
rasterizer.draw_path(path);
return rasterizer.accumulate();
}