summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2016-07-17 21:19:37 +0930
committerAdrian Johnson <ajohnson@redneon.com>2016-07-17 21:19:37 +0930
commit16a8c13b6acad62c8844bf641c1296a9f4aac09d (patch)
tree9ab277ad90a3603a07b722c77d646ffee5d6e40e
parent190678f6444ad879847d603c3c9eaf8e9ab6887a (diff)
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.
-rw-r--r--src/cairo-pdf-surface.c32
-rw-r--r--src/cairo-scaled-font-subsets.c6
2 files changed, 24 insertions, 14 deletions
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 51a951415..436bff092 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -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,
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 74bfb9ea5..bf05fbd55 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -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) {