mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibPDF: Apply all offsets of TJ operator
TJ acts on a list of either strings or numbers. The strings are drawn, and the numbers are treated as offsets. Previously, we'd only apply the last-seen number as offset when we saw a string. That had the effect of us ignoring all but the last number in front of a string, and ignoring numbers at the end of the list. Now, we apply all numbers as offsets. Our rendering of Tests/LibPDF/text.pdf now matches other PDF viewers.
This commit is contained in:
parent
4f51ff456e
commit
9b022239c3
1 changed files with 5 additions and 6 deletions
|
@ -518,16 +518,15 @@ RENDERER_HANDLER(text_next_line_show_string_set_spacing)
|
||||||
RENDERER_HANDLER(text_show_string_array)
|
RENDERER_HANDLER(text_show_string_array)
|
||||||
{
|
{
|
||||||
auto elements = MUST(m_document->resolve_to<ArrayObject>(args[0]))->elements();
|
auto elements = MUST(m_document->resolve_to<ArrayObject>(args[0]))->elements();
|
||||||
float next_shift = 0.0f;
|
|
||||||
|
|
||||||
for (auto& element : elements) {
|
for (auto& element : elements) {
|
||||||
if (element.has<int>()) {
|
if (element.has<int>()) {
|
||||||
next_shift = element.get<int>();
|
float shift = (float)element.get<int>() / 1000.0f;
|
||||||
} else if (element.has<float>()) {
|
|
||||||
next_shift = element.get<float>();
|
|
||||||
} else {
|
|
||||||
auto shift = next_shift / 1000.0f;
|
|
||||||
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
m_text_matrix.translate(-shift * text_state().font_size * text_state().horizontal_scaling, 0.0f);
|
||||||
|
} 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);
|
||||||
|
} else {
|
||||||
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
|
auto str = element.get<NonnullRefPtr<Object>>()->cast<StringObject>()->string();
|
||||||
TRY(show_text(str));
|
TRY(show_text(str));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue