diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2008-01-11 22:05:13 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2008-01-11 22:05:13 +1030 |
commit | b703199525ca02274ef5a8474cdae0cb70705964 (patch) | |
tree | c471ad663788ed2bc663af22a7981caa7ecd0a99 /src/cairo-type1-subset.c | |
parent | 6418a8be8719c9a969d9ec1f8624c841db9d2b90 (diff) |
Type1-subset: Font name may be NULL
If the FreeType face->family_name is NULL use a CairoFont-x-y name.
Diffstat (limited to 'src/cairo-type1-subset.c')
-rw-r--r-- | src/cairo-type1-subset.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c index 019e63b3..2d57368d 100644 --- a/src/cairo-type1-subset.c +++ b/src/cairo-type1-subset.c @@ -147,18 +147,20 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font, font->base.y_max = face->bbox.yMax; font->base.ascent = face->ascender; font->base.descent = face->descender; - font->base.base_font = strdup (face->family_name); - if (font->base.base_font == NULL) { - status = _cairo_error (CAIRO_STATUS_NO_MEMORY); - goto fail2; - } - for (i = 0, j = 0; font->base.base_font[j]; j++) { - if (font->base.base_font[j] == ' ') - continue; - font->base.base_font[i++] = font->base.base_font[j]; + if (face->family_name) { + font->base.base_font = strdup (face->family_name); + if (font->base.base_font == NULL) { + status = _cairo_error (CAIRO_STATUS_NO_MEMORY); + goto fail2; + } + for (i = 0, j = 0; font->base.base_font[j]; j++) { + if (font->base.base_font[j] == ' ') + continue; + font->base.base_font[i++] = font->base.base_font[j]; + } + font->base.base_font[i] = '\0'; } - font->base.base_font[i] = '\0'; font->glyphs = calloc (face->num_glyphs, sizeof font->glyphs[0]); if (font->glyphs == NULL) { @@ -180,7 +182,8 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t *unscaled_font, return CAIRO_STATUS_SUCCESS; fail3: - free (font->base.base_font); + if (font->base.base_font) + free (font->base.base_font); fail2: _cairo_unscaled_font_destroy (unscaled_font); free (font); @@ -1158,7 +1161,8 @@ cairo_type1_font_subset_destroy (void *abstract_font) _cairo_unscaled_font_destroy (font->base.unscaled_font); - free (font->base.base_font); + if (font->base.base_font) + free (font->base.base_font); free (font->glyphs); free (font); } @@ -1175,6 +1179,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset, unsigned long parent_glyph, length; unsigned int i; cairo_unscaled_font_t *unscaled_font; + char buf[30]; /* XXX: Need to fix this to work with a general cairo_unscaled_font_t. */ if (!_cairo_scaled_font_is_ft (scaled_font_subset->scaled_font)) @@ -1198,7 +1203,13 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset, if (status) goto fail1; - type1_subset->base_font = strdup (font->base.base_font); + if (font->base.base_font) { + type1_subset->base_font = strdup (font->base.base_font); + } else { + snprintf(buf, sizeof (buf), "CairoFont-%u-%u", + scaled_font_subset->font_id, scaled_font_subset->subset_id); + type1_subset->base_font = strdup (buf); + } if (type1_subset->base_font == NULL) goto fail1; |