diff options
Diffstat (limited to 'src/cairo-truetype-subset.c')
-rw-r--r--[-rwxr-xr-x] | src/cairo-truetype-subset.c | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 44d7f60f5..fa33d63e4 100755..100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -1572,40 +1572,11 @@ _cairo_truetype_read_font_name (cairo_scaled_font_t *scaled_font, goto fail; } - free (name); + status = _cairo_escape_ps_name (&ps_name); + if (unlikely(status)) + goto fail; - /* Ensure PS name is a valid PDF/PS name object. In PDF names are - * treated as UTF8 and non ASCII bytes, ' ', and '#' are encoded - * as '#' followed by 2 hex digits that encode the byte. By also - * encoding the characters in the reserved string we ensure the - * name is also PS compatible. */ - if (ps_name) { - static const char *reserved = "()<>[]{}/%#\\"; - char buf[128]; /* max name length is 127 bytes */ - char *src = ps_name; - char *dst = buf; - - while (*src && dst < buf + 127) { - unsigned char c = *src; - if (c < 0x21 || c > 0x7e || strchr (reserved, c)) { - if (dst + 4 > buf + 127) - break; - - snprintf (dst, 4, "#%02X", c); - src++; - dst += 3; - } else { - *dst++ = *src++; - } - } - *dst = 0; - free (ps_name); - ps_name = strdup (buf); - if (ps_name == NULL) { - status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto fail; - } - } + free (name); *ps_name_out = ps_name; *font_name_out = family_name; |