mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 09:40:19 +01:00
PDF: Limit precision of Td operands
As the translation is in text space, the full precision of a double for numbers close to zero is not required. Limit the precision to the same as for numbers > 1.
This commit is contained in:
parent
d5c7b87ca9
commit
0c05aa60f5
1 changed files with 6 additions and 0 deletions
|
|
@ -985,6 +985,8 @@ _cairo_pdf_operators_set_text_matrix (cairo_pdf_operators_t *pdf_operators,
|
|||
return _cairo_output_stream_get_status (pdf_operators->stream);
|
||||
}
|
||||
|
||||
#define TEXT_MATRIX_TOLERANCE 1e-6
|
||||
|
||||
/* Set the translation components of the PDF text matrix to x, y. The
|
||||
* 'Td' operator is used to transform the text matrix.
|
||||
*/
|
||||
|
|
@ -1009,6 +1011,10 @@ _cairo_pdf_operators_set_text_position (cairo_pdf_operators_t *pdf_operators,
|
|||
pdf_operators->text_matrix.x0 = x;
|
||||
pdf_operators->text_matrix.y0 = y;
|
||||
cairo_matrix_multiply (&translate, &pdf_operators->text_matrix, &inverse);
|
||||
if (fabs(translate.x0) < TEXT_MATRIX_TOLERANCE)
|
||||
translate.x0 = 0.0;
|
||||
if (fabs(translate.y0) < TEXT_MATRIX_TOLERANCE)
|
||||
translate.y0 = 0.0;
|
||||
_cairo_output_stream_printf (pdf_operators->stream,
|
||||
"%f %f Td\n",
|
||||
translate.x0,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue