type1-subset: if font name is prefixed with a subset tag, strip it off

This commit is contained in:
Adrian Johnson 2012-04-06 09:43:53 +09:30
parent a6d955fcc4
commit 8886220b50

View file

@ -381,6 +381,7 @@ cairo_type1_font_subset_get_fontname (cairo_type1_font_subset_t *font)
{
const char *start, *end, *segment_end;
char *s;
int i;
segment_end = font->header_segment + font->header_segment_size;
start = find_token (font->header_segment, segment_end, "/FontName");
@ -406,6 +407,16 @@ cairo_type1_font_subset_get_fontname (cairo_type1_font_subset_t *font)
return CAIRO_INT_STATUS_UNSUPPORTED;
}
/* If font name is prefixed with a subset tag, strip it off. */
if (strlen(start) > 7 && start[6] == '+') {
for (i = 0; i < 6; i++) {
if (start[i] < 'A' || start[i] > 'Z')
break;
}
if (i == 6)
start += 7;
}
font->base.base_font = strdup (start);
free (s);
if (unlikely (font->base.base_font == NULL))