mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
LibPDF: Mark text rendering matrix as dirty after TJ numbers
Mostly because I audited all places that assigned to `m_text_matrix` after #22760. This one is very difficult to trigger in practice. `show_text()` marks the text rendering matrix dirty already, so this only has an effect if the `TJ` array starts with a number, and the matrix isn't marked dirty going in. `Tm` caches the text rendering matrix, so I changed text.pdf to contain: ``` 1 0 0 1 45 130 Tm [ 200 (Hello) -2000 (World) ] TJ T* ``` This first sets an x offset of 5 (on top of the normal 40), and then undoes it (`200` is multiplied by font size (25) / -1000, and `200 * 25 / -1000` is -5). Before this change, the topmost "Hello World" ended up slightly indented. Likely no behavior change in practice, but makes the code easier to understand, and maybe it helps in the wild somewhere.
This commit is contained in:
parent
f23f5dcd62
commit
9a93f677f4
2 changed files with 16 additions and 40 deletions
|
@ -572,9 +572,11 @@ RENDERER_HANDLER(text_show_string_array)
|
|||
if (element.has<int>()) {
|
||||
float shift = (float)element.get<int>() / 1000.0f;
|
||||
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
||||
m_text_rendering_matrix_is_dirty = true;
|
||||
} else if (element.has<float>()) {
|
||||
float shift = element.get<float>() / 1000.0f;
|
||||
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
||||
m_text_rendering_matrix_is_dirty = true;
|
||||
} else {
|
||||
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
|
||||
TRY(show_text(str));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue