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

LibPDF: Move all font handling to Type1Font and TrueTypeFont classes

It was previously the job of the renderer to create fonts, load
replacements for the standard 14 fonts and to pass the font size back
to the PDFFont when asking for glyph widths.

Now, the renderer tells the font its size at creation, as it doesn't
change throughout the life of the font. The PDFFont itself is now
responsible to decide whether or not it needs to use a replacement
font, which still is Liberation Serif for now.

This means that we can now render embedded TrueType fonts as well :^)

It also makes the renderer's job much more simple and leads to a much
cleaner API design.
This commit is contained in:
Julian Offenhäuser 2022-11-22 19:46:29 +01:00 committed by Andreas Kling
parent e748a94f80
commit 9cb3b23377
10 changed files with 119 additions and 171 deletions

View file

@ -57,8 +57,6 @@ struct TextState {
float word_spacing { 0.0f };
float horizontal_scaling { 1.0f };
float leading { 0.0f };
FlyString font_family { "Liberation Serif" };
String font_variant { "Regular" };
float font_size { 12.0f };
RefPtr<PDFFont> font;
TextRenderingMode rendering_mode { TextRenderingMode::Fill };
@ -221,8 +219,6 @@ struct Formatter<PDF::TextState> : Formatter<StringView> {
builder.appendff(" word_spacing={}\n", state.word_spacing);
builder.appendff(" horizontal_scaling={}\n", state.horizontal_scaling);
builder.appendff(" leading={}\n", state.leading);
builder.appendff(" font_family={}\n", state.font_family);
builder.appendff(" font_variant={}\n", state.font_variant);
builder.appendff(" font_size={}\n", state.font_size);
builder.appendff(" rendering_mode={}\n", state.rendering_mode);
builder.appendff(" rise={}\n", state.rise);