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

LibPDF: Stop calculating code points for glyphs

When rendering text, a sequence of bytes corresponds to a glyph, but not
necessarily to a character. This misunderstanding permeated through the
Encoding through to the Font classes, which were all trying to calculate
such values. Moreover, this was done only to identify "space"
characters/glyphs, which were getting a special treatment (e.g., avoid
rendering). Spaces are not special though -- there might be fonts that
render something for them -- and thus should not be skipped
This commit is contained in:
Rodrigo Tobar 2023-01-23 22:07:04 +08:00 committed by Andreas Kling
parent 7c42d6c737
commit fb0c3a9e18
8 changed files with 1 additions and 43 deletions

View file

@ -742,21 +742,12 @@ void Renderer::show_text(DeprecatedString const& string)
auto original_position = glyph_position;
for (auto char_code : string.bytes()) {
auto code_point = text_state().font->char_code_to_code_point(char_code);
auto char_width = text_state().font->get_char_width(char_code);
auto glyph_width = char_width * font_size;
if (code_point != 0x20)
text_state().font->draw_glyph(m_painter, glyph_position, glyph_width, char_code, state().paint_color);
text_state().font->draw_glyph(m_painter, glyph_position, glyph_width, char_code, state().paint_color);
auto tx = glyph_width;
tx += text_state().character_spacing;
if (code_point == ' ')
tx += text_state().word_spacing;
tx *= text_state().horizontal_scaling;
glyph_position += { tx, 0.0f };
}