mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-06 16:40:19 +01:00
Don't add a notdef glyph to Type 3 font subsets
This allows user-fonts to use glyph 0 when embedding in PS/PDF. According to ISO32000 Type 3 fonts do not require a notdef glyph.
This commit is contained in:
parent
170686d4b0
commit
5e4a1cb0b8
5 changed files with 50 additions and 75 deletions
|
|
@ -3513,7 +3513,7 @@ _cairo_pdf_surface_analyze_user_font_subset (cairo_scaled_font_subset_t *font_su
|
|||
_cairo_pdf_surface_add_font,
|
||||
surface);
|
||||
|
||||
for (i = 1; i < font_subset->num_glyphs; i++) {
|
||||
for (i = 0; i < font_subset->num_glyphs; i++) {
|
||||
status = _cairo_type3_glyph_surface_analyze_glyph (type3_surface,
|
||||
font_subset->glyphs[i]);
|
||||
if (status)
|
||||
|
|
@ -3578,18 +3578,11 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface,
|
|||
break;
|
||||
|
||||
glyphs[i] = surface->pdf_stream.self;
|
||||
if (i == 0) {
|
||||
status = _cairo_type3_glyph_surface_emit_notdef_glyph (type3_surface,
|
||||
surface->output,
|
||||
&bbox,
|
||||
&widths[i]);
|
||||
} else {
|
||||
status = _cairo_type3_glyph_surface_emit_glyph (type3_surface,
|
||||
surface->output,
|
||||
font_subset->glyphs[i],
|
||||
&bbox,
|
||||
&widths[i]);
|
||||
}
|
||||
status = _cairo_type3_glyph_surface_emit_glyph (type3_surface,
|
||||
surface->output,
|
||||
font_subset->glyphs[i],
|
||||
&bbox,
|
||||
&widths[i]);
|
||||
if (status)
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ _cairo_ps_surface_analyze_user_font_subset (cairo_scaled_font_subset_t *font_sub
|
|||
_cairo_ps_emit_imagemask,
|
||||
surface->font_subsets);
|
||||
|
||||
for (i = 1; i < font_subset->num_glyphs; i++) {
|
||||
for (i = 0; i < font_subset->num_glyphs; i++) {
|
||||
status = _cairo_type3_glyph_surface_analyze_glyph (type3_surface,
|
||||
font_subset->glyphs[i]);
|
||||
if (status)
|
||||
|
|
@ -500,7 +500,7 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
|
|||
_cairo_ps_emit_imagemask,
|
||||
surface->font_subsets);
|
||||
|
||||
for (i = 1; i < font_subset->num_glyphs; i++) {
|
||||
for (i = 0; i < font_subset->num_glyphs; i++) {
|
||||
if (font_subset->glyph_names != NULL) {
|
||||
_cairo_output_stream_printf (surface->final_stream,
|
||||
"Encoding %d /%s put\n",
|
||||
|
|
@ -517,18 +517,11 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface,
|
|||
for (i = 0; i < font_subset->num_glyphs; i++) {
|
||||
_cairo_output_stream_printf (surface->final_stream,
|
||||
" { %% %d\n", i);
|
||||
if (i == 0) {
|
||||
status = _cairo_type3_glyph_surface_emit_notdef_glyph (type3_surface,
|
||||
surface->final_stream,
|
||||
&bbox,
|
||||
&width);
|
||||
} else {
|
||||
status = _cairo_type3_glyph_surface_emit_glyph (type3_surface,
|
||||
surface->final_stream,
|
||||
font_subset->glyphs[i],
|
||||
&bbox,
|
||||
&width);
|
||||
}
|
||||
status = _cairo_type3_glyph_surface_emit_glyph (type3_surface,
|
||||
surface->final_stream,
|
||||
font_subset->glyphs[i],
|
||||
&bbox,
|
||||
&width);
|
||||
if (status)
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -290,12 +290,15 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t *parent,
|
|||
}
|
||||
sub_font->next = NULL;
|
||||
|
||||
/* Reserve first glyph in subset for the .notdef glyph */
|
||||
status = _cairo_sub_font_map_glyph (sub_font, 0, NULL, -1, &subset_glyph);
|
||||
if (status) {
|
||||
_cairo_hash_table_destroy (sub_font->sub_font_glyphs);
|
||||
free (sub_font);
|
||||
return status;
|
||||
/* Reserve first glyph in subset for the .notdef glyph except for
|
||||
* Type 3 fonts */
|
||||
if (! _cairo_font_face_is_user (scaled_font->font_face)) {
|
||||
status = _cairo_sub_font_map_glyph (sub_font, 0, NULL, -1, &subset_glyph);
|
||||
if (status) {
|
||||
_cairo_hash_table_destroy (sub_font->sub_font_glyphs);
|
||||
free (sub_font);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
*sub_font_out = sub_font;
|
||||
|
|
@ -459,10 +462,13 @@ _cairo_sub_font_map_glyph (cairo_sub_font_t *sub_font,
|
|||
sub_font->current_subset++;
|
||||
sub_font->num_glyphs_in_current_subset = 0;
|
||||
|
||||
/* Reserve first glyph in subset for the .notdef glyph */
|
||||
status = _cairo_sub_font_map_glyph (sub_font, 0, NULL, -1, &tmp_subset_glyph);
|
||||
if (status)
|
||||
return status;
|
||||
/* Reserve first glyph in subset for the .notdef glyph
|
||||
* except for Type 3 fonts */
|
||||
if (! _cairo_font_face_is_user (sub_font->scaled_font->font_face)) {
|
||||
status = _cairo_sub_font_map_glyph (sub_font, 0, NULL, -1, &tmp_subset_glyph);
|
||||
if (status)
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
_cairo_scaled_font_freeze_cache (sub_font->scaled_font);
|
||||
|
|
@ -705,7 +711,8 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t *subsets,
|
|||
* _scaled_glyph_lookup(_GLYPH_INFO_PATH). Type1-fallback creates
|
||||
* empty glyphs in this case so we can put the glyph in a unscaled
|
||||
* subset. */
|
||||
if (scaled_font_glyph_index == 0) {
|
||||
if (scaled_font_glyph_index == 0 ||
|
||||
_cairo_font_face_is_user (scaled_font->font_face)) {
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
} else {
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
|
|
@ -980,23 +987,27 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
|
|||
goto CLEANUP_HASH;
|
||||
}
|
||||
|
||||
subset->glyph_names[0] = strdup (".notdef");
|
||||
if (subset->glyph_names[0] == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_HASH;
|
||||
i = 0;
|
||||
if (! _cairo_font_face_is_user (subset->scaled_font->font_face)) {
|
||||
subset->glyph_names[0] = strdup (".notdef");
|
||||
if (subset->glyph_names[0] == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_HASH;
|
||||
}
|
||||
|
||||
status = create_string_entry (subset->glyph_names[0], &entry);
|
||||
if (status)
|
||||
goto CLEANUP_HASH;
|
||||
|
||||
status = _cairo_hash_table_insert (names, &entry->base);
|
||||
if (status) {
|
||||
free (entry);
|
||||
goto CLEANUP_HASH;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
status = create_string_entry (subset->glyph_names[0], &entry);
|
||||
if (status)
|
||||
goto CLEANUP_HASH;
|
||||
|
||||
status = _cairo_hash_table_insert (names, &entry->base);
|
||||
if (status) {
|
||||
free (entry);
|
||||
goto CLEANUP_HASH;
|
||||
}
|
||||
|
||||
for (i = 1; i < subset->num_glyphs; i++) {
|
||||
for (; i < subset->num_glyphs; i++) {
|
||||
utf8 = subset->utf8[i];
|
||||
utf16 = NULL;
|
||||
utf16_len = 0;
|
||||
|
|
|
|||
|
|
@ -72,12 +72,6 @@ cairo_private cairo_status_t
|
|||
_cairo_type3_glyph_surface_analyze_glyph (void *abstract_surface,
|
||||
unsigned long glyph_index);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_type3_glyph_surface_emit_notdef_glyph (void *abstract_surface,
|
||||
cairo_output_stream_t *stream,
|
||||
cairo_box_t *bbox,
|
||||
double *width);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_type3_glyph_surface_emit_glyph (void *abstract_surface,
|
||||
cairo_output_stream_t *stream,
|
||||
|
|
|
|||
|
|
@ -434,22 +434,6 @@ cleanup:
|
|||
return status;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_type3_glyph_surface_emit_notdef_glyph (void *abstract_surface,
|
||||
cairo_output_stream_t *stream,
|
||||
cairo_box_t *bbox,
|
||||
double *width)
|
||||
{
|
||||
bbox->p1.x = 0;
|
||||
bbox->p1.y = 0;
|
||||
bbox->p2.x = 0;
|
||||
bbox->p2.y = 0;
|
||||
*width = 0.0;
|
||||
_cairo_output_stream_printf (stream, "0 0 0 0 0 0 d1\n");
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_type3_glyph_surface_emit_glyph (void *abstract_surface,
|
||||
cairo_output_stream_t *stream,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue