summaryrefslogtreecommitdiff
path: root/src/cairo-user-font.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2008-10-22 15:43:56 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2008-10-22 16:38:12 +0100
commit954ebacb71071c53c4e4092b469417f01478bc2d (patch)
treece0e43ee87f713d85a8e93a9b5fb72d083ba3162 /src/cairo-user-font.c
parent5e4a1cb0b830f069d99c9512563c82ad628587e3 (diff)
Map toy font face to implementation.
Quartz fonts and user fonts use an indirect font face when creating a scaled font for the toy font face. This means that they insert a scaled font into the font map that has a different font face to the one that is initially searched upon. The result is that when we try to create an identical scaled font, we fail to find the existing scaled font and attempt to insert a duplicate into the hash table - which triggers an assert. In order to avoid creating duplicate fonts, we add a new method to the font backends that allows cairo_scaled_font_create() to peek at the font_face that will be used to actually implement the scaled font constructor - thus we are able to use the correct font_face as part of the hash key.
Diffstat (limited to 'src/cairo-user-font.c')
-rw-r--r--src/cairo-user-font.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 385b8414..ddcbc77c 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -337,17 +337,14 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
cairo_scaled_font_t **scaled_font);
static cairo_status_t
-_cairo_user_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
- const cairo_matrix_t *font_matrix,
- const cairo_matrix_t *ctm,
- const cairo_font_options_t *font_options,
- cairo_scaled_font_t **font)
+_cairo_user_scaled_font_get_implementation (cairo_toy_font_face_t *toy_face,
+ cairo_font_face_t **font_face_out)
{
- cairo_status_t status;
- cairo_font_face_t *face;
-
static cairo_user_data_key_t twin_font_face_key;
+ cairo_font_face_t *face;
+ cairo_status_t status;
+
face = cairo_font_face_get_user_data (&toy_face->base,
&twin_font_face_key);
if (!face) {
@@ -365,17 +362,38 @@ _cairo_user_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
}
}
+ *font_face_out = face;
+ return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_status_t
+_cairo_user_scaled_font_create_toy (cairo_toy_font_face_t *toy_face,
+ const cairo_matrix_t *font_matrix,
+ const cairo_matrix_t *ctm,
+ const cairo_font_options_t *font_options,
+ cairo_scaled_font_t **font)
+{
+ cairo_font_face_t *face;
+ cairo_status_t status;
+
+ status = _cairo_user_scaled_font_get_implementation (toy_face, &face);
+ if (status)
+ return status;
+
status = _cairo_user_font_face_scaled_font_create (face,
font_matrix,
ctm,
font_options,
font);
+ if (status)
+ return status;
- return status;
+ return CAIRO_STATUS_SUCCESS;
}
const cairo_scaled_font_backend_t _cairo_user_scaled_font_backend = {
CAIRO_FONT_TYPE_USER,
+ _cairo_user_scaled_font_get_implementation,
_cairo_user_scaled_font_create_toy, /* create_toy */
NULL, /* scaled_font_fini */
_cairo_user_scaled_glyph_init,
@@ -501,6 +519,7 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
static const cairo_font_face_backend_t _cairo_user_font_face_backend = {
CAIRO_FONT_TYPE_USER,
NULL, /* destroy */
+ NULL, /* direct implementation */
_cairo_user_font_face_scaled_font_create
};