pdf: Don't fail subsetting if unable to convert utf8 to utf16

If the unicode came from the font, don't fail if utf8_to_utf16 fails.
This commit is contained in:
Adrian Johnson 2016-07-17 21:19:37 +09:30
parent 190678f644
commit 16a8c13b6a
2 changed files with 24 additions and 14 deletions

View file

@ -4833,8 +4833,12 @@ _cairo_pdf_surface_emit_unicode_for_glyph (cairo_pdf_surface_t *surface,
if (utf8 && *utf8) {
status = _cairo_utf8_to_utf16 (utf8, -1, &utf16, &utf16_len);
if (unlikely (status))
if (unlikely (status == CAIRO_INT_STATUS_INVALID_STRING)) {
utf16 = NULL;
utf16_len = 0;
} else if (unlikely (status)) {
return status;
}
}
_cairo_output_stream_printf (surface->output, "<");
@ -5110,13 +5114,14 @@ _cairo_pdf_surface_emit_cff_font (cairo_pdf_surface_t *surface,
char *pdf_str;
status = _utf8_to_pdf_string (subset->family_name_utf8, &pdf_str);
if (unlikely (status))
if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
_cairo_output_stream_printf (surface->output,
" /FontFamily %s\n",
pdf_str);
free (pdf_str);
} else if (status != CAIRO_INT_STATUS_INVALID_STRING) {
return status;
_cairo_output_stream_printf (surface->output,
" /FontFamily %s\n",
pdf_str);
free (pdf_str);
}
}
_cairo_output_stream_printf (surface->output,
@ -5555,13 +5560,14 @@ _cairo_pdf_surface_emit_truetype_font_subset (cairo_pdf_surface_t *surface,
char *pdf_str;
status = _utf8_to_pdf_string (subset.family_name_utf8, &pdf_str);
if (unlikely (status))
if (likely (status == CAIRO_INT_STATUS_SUCCESS)) {
_cairo_output_stream_printf (surface->output,
" /FontFamily %s\n",
pdf_str);
free (pdf_str);
} else if (status != CAIRO_INT_STATUS_INVALID_STRING) {
return status;
_cairo_output_stream_printf (surface->output,
" /FontFamily %s\n",
pdf_str);
free (pdf_str);
}
}
_cairo_output_stream_printf (surface->output,

View file

@ -1281,8 +1281,12 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
utf16_len = 0;
if (utf8 && *utf8) {
status = _cairo_utf8_to_utf16 (utf8, -1, &utf16, &utf16_len);
if (unlikely (status))
if (status == CAIRO_STATUS_INVALID_STRING) {
utf16 = NULL;
utf16_len = 0;
} else if (unlikely (status)) {
goto CLEANUP_HASH;
}
}
if (utf16_len == 1) {