mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-04-18 13:10:47 +02:00
Switch to using Tm for text positioning and scale type3 fonts to unit size.
This change changes the text output code to use the Tm operator for positioning the glyphs. This allows us to set the scale matrix from the cairo_scaled_font_t so truetype glyphs get transformed correctly. However, we now need to scale type3 glyph to unity to compensate. Longer term we should just only output one unit sized type3 subset for a cairo_font_face_t and use that for all cairo_scaled_font_t's coming from that font face. Also, this fixes a num_glyphs initialization bug.
This commit is contained in:
parent
e846dca44e
commit
2c6e799ee6
2 changed files with 23 additions and 4 deletions
|
|
@ -168,7 +168,7 @@ _cairo_pdf_ft_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
|
|||
if (font->parent_to_subset == NULL)
|
||||
goto fail3;
|
||||
|
||||
font->base.num_glyphs = 1;
|
||||
font->base.num_glyphs = 0;
|
||||
font->base.x_min = face->bbox.xMin;
|
||||
font->base.y_min = face->bbox.yMin;
|
||||
font->base.x_max = face->bbox.xMax;
|
||||
|
|
|
|||
|
|
@ -1830,6 +1830,7 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface,
|
|||
{
|
||||
cairo_pdf_resource_t *glyphs, encoding, char_procs, subset_resource;
|
||||
cairo_pdf_font_t font;
|
||||
cairo_matrix_t matrix;
|
||||
int i;
|
||||
|
||||
glyphs = malloc (font_subset->num_glyphs * sizeof (cairo_pdf_resource_t));
|
||||
|
|
@ -1871,17 +1872,23 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface,
|
|||
"endobj\r\n");
|
||||
|
||||
subset_resource = _cairo_pdf_surface_new_object (surface);
|
||||
matrix = font_subset->scaled_font->scale;
|
||||
cairo_matrix_invert (&matrix);
|
||||
_cairo_output_stream_printf (surface->output,
|
||||
"%d 0 obj\r\n"
|
||||
"<< /Type /Font\r\n"
|
||||
" /Subtype /Type3\r\n"
|
||||
" /FontBBox [0 0 0 0]\r\n"
|
||||
" /FontMatrix\t[1 0 0 1 0 0]\r\n"
|
||||
" /FontMatrix [ %f %f %f %f 0 0 ]\r\n"
|
||||
" /Encoding %d 0 R\r\n"
|
||||
" /CharProcs %d 0 R\r\n"
|
||||
" /FirstChar 0\r\n"
|
||||
" /LastChar %d\r\n",
|
||||
subset_resource.id,
|
||||
matrix.xx,
|
||||
matrix.yx,
|
||||
-matrix.xy,
|
||||
-matrix.yy,
|
||||
encoding.id,
|
||||
char_procs.id,
|
||||
font_subset->num_glyphs - 1);
|
||||
|
|
@ -2465,6 +2472,9 @@ _cairo_pdf_surface_show_glyphs (void *abstract_surface,
|
|||
if (status)
|
||||
return status;
|
||||
|
||||
_cairo_output_stream_printf (surface->output,
|
||||
"BT\r\n");
|
||||
|
||||
for (i = 0; i < num_glyphs; i++) {
|
||||
status = _cairo_scaled_font_subsets_map_glyph (surface->font_subsets,
|
||||
scaled_font, glyphs[i].index,
|
||||
|
|
@ -2478,13 +2488,22 @@ _cairo_pdf_surface_show_glyphs (void *abstract_surface,
|
|||
font_id, subset_id);
|
||||
current_subset_id = subset_id;
|
||||
}
|
||||
|
||||
_cairo_output_stream_printf (surface->output,
|
||||
"BT %f %f Td <%c%c> Tj ET\r\n",
|
||||
glyphs[i].x, glyphs[i].y,
|
||||
"%f %f %f %f %f %f Tm <%c%c> Tj\r\n",
|
||||
scaled_font->scale.xx,
|
||||
scaled_font->scale.yx,
|
||||
-scaled_font->scale.xy,
|
||||
-scaled_font->scale.yy,
|
||||
glyphs[i].x,
|
||||
glyphs[i].y,
|
||||
hex_digit (subset_glyph_index >> 4),
|
||||
hex_digit (subset_glyph_index));
|
||||
}
|
||||
|
||||
_cairo_output_stream_printf (surface->output,
|
||||
"ET\r\n");
|
||||
|
||||
return _cairo_output_stream_get_status (surface->output);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue