From 7f0029c31e15dfd34f57bdeca18f27e9e7b8f9aa Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Mon, 22 Nov 2010 22:46:54 +1030 Subject: [PATCH] Use fallback font for synthetic fonts If the font has been synthesized we can't use the native subsetters as the outlines won't be the same. Instead force the use of the fallback subsetters so the synthesized outlines will used to generate the font. --- src/cairo-cff-subset.c | 4 ++++ src/cairo-ft-font.c | 14 +++++++++++++- src/cairo-truetype-subset.c | 4 ++++ src/cairo-type1-subset.c | 5 +++++ src/cairoint.h | 3 +++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c index f2ec37426..a01d55eb5 100644 --- a/src/cairo-cff-subset.c +++ b/src/cairo-cff-subset.c @@ -1906,6 +1906,10 @@ _cairo_cff_font_create (cairo_scaled_font_subset_t *scaled_font_subset, if (!backend->load_truetype_table) return CAIRO_INT_STATUS_UNSUPPORTED; + /* We need to use a fallback font generated from the synthesized outlines. */ + if (backend->is_synthetic (scaled_font_subset->scaled_font)) + return CAIRO_INT_STATUS_UNSUPPORTED; + data_length = 0; status = backend->load_truetype_table( scaled_font_subset->scaled_font, TT_TAG_CFF, 0, NULL, &data_length); diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 67eb2758e..054da2523 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -2418,6 +2418,17 @@ _cairo_ft_index_to_ucs4(void *abstract_font, return CAIRO_STATUS_SUCCESS; } +static cairo_bool_t +_cairo_ft_is_synthetic (void *abstract_font) +{ + cairo_ft_scaled_font_t *scaled_font = abstract_font; + + if (scaled_font->ft_options.extra_flags & CAIRO_FT_OPTIONS_EMBOLDEN) + return TRUE; + else + return FALSE; +} + static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend = { CAIRO_FONT_TYPE_FT, _cairo_ft_scaled_font_fini, @@ -2426,7 +2437,8 @@ static const cairo_scaled_font_backend_t _cairo_ft_scaled_font_backend = { _cairo_ft_ucs4_to_index, NULL, /* show_glyphs */ _cairo_ft_load_truetype_table, - _cairo_ft_index_to_ucs4 + _cairo_ft_index_to_ucs4, + _cairo_ft_is_synthetic }; /* #cairo_ft_font_face_t */ diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c index 55f97b004..7777996a8 100644 --- a/src/cairo-truetype-subset.c +++ b/src/cairo-truetype-subset.c @@ -156,6 +156,10 @@ _cairo_truetype_font_create (cairo_scaled_font_subset_t *scaled_font_subset, * return CAIRO_INT_STATUS_UNSUPPORTED; */ + /* We need to use a fallback font generated from the synthesized outlines. */ + if (backend->is_synthetic (scaled_font_subset->scaled_font)) + return CAIRO_INT_STATUS_UNSUPPORTED; + size = sizeof (tt_head_t); status = backend->load_truetype_table (scaled_font_subset->scaled_font, TT_TAG_head, 0, diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c index f619d7401..e0b1bf8a2 100644 --- a/src/cairo-type1-subset.c +++ b/src/cairo-type1-subset.c @@ -1151,6 +1151,11 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type1_subset, if (_cairo_ft_scaled_font_is_vertical (scaled_font_subset->scaled_font)) return CAIRO_INT_STATUS_UNSUPPORTED; + /* We need to use a fallback font generated from the synthesized outlines. */ + if (scaled_font_subset->scaled_font->backend->is_synthetic && + scaled_font_subset->scaled_font->backend->is_synthetic (scaled_font_subset->scaled_font)) + return CAIRO_INT_STATUS_UNSUPPORTED; + unscaled_font = _cairo_ft_scaled_font_get_unscaled_font (scaled_font_subset->scaled_font); status = _cairo_type1_font_subset_init (&font, unscaled_font, scaled_font_subset, hex_encode); diff --git a/src/cairoint.h b/src/cairoint.h index e2946cf84..5a435618f 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -515,6 +515,9 @@ struct _cairo_scaled_font_backend { (*index_to_ucs4)(void *scaled_font, unsigned long index, uint32_t *ucs4); + + cairo_warn cairo_bool_t + (*is_synthetic)(void *scaled_font); }; struct _cairo_font_face_backend {