LibPDF: Fix order of parameter, text, and current transform matrix

PDF spec 1.7 5.3.3 Text Space Details gives the correct multiplication
order: parameters * textmatrix * ctm.

We used to do text * ctm * parameters
(AffineTransform::multiply() does left-multiplication).

This only matters if `text_state().rise` is non-zero. In practice,
it's almost always zero, in which case the paramter matrix is a
diagonal matrix that commutes.

Fixes the horizontal offset of "super" in Tests/LibPDF/text.pdf.
This commit is contained in:
Nico Weber 2024-01-16 17:14:56 -05:00 committed by Andreas Kling
parent 6c65c18c40
commit 470d1d8dcf
Notes: sideshowbarker 2024-07-17 04:32:07 +09:00

View File

@ -1308,15 +1308,17 @@ Gfx::AffineTransform const& Renderer::calculate_text_rendering_matrix() const
{
if (m_text_rendering_matrix_is_dirty) {
// PDF 1.7, 5.3.3. Text Space Details
m_text_rendering_matrix = Gfx::AffineTransform(
Gfx::AffineTransform parameter_matrix {
text_state().horizontal_scaling,
0.0f,
0.0f,
1.0f,
0.0f,
text_state().rise);
m_text_rendering_matrix.multiply(state().ctm);
text_state().rise
};
m_text_rendering_matrix = state().ctm;
m_text_rendering_matrix.multiply(m_text_matrix);
m_text_rendering_matrix.multiply(parameter_matrix);
m_text_rendering_matrix_is_dirty = false;
}
return m_text_rendering_matrix;