summaryrefslogtreecommitdiff
path: root/src/cairo-user-font.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-12-17 06:25:50 -0500
committerBehdad Esfahbod <behdad@behdad.org>2008-12-17 15:13:35 -0500
commitf7ab65e9b0c0f08be8d294e90131baa2decf1f1d (patch)
treecd4fb0bd7e9144ad2f8f173663d31b0a6317e1c4 /src/cairo-user-font.c
parent43edb4dd7b8d0614a6c2be15dfa72f980dd55f1d (diff)
downloadcairo-f7ab65e9b0c0f08be8d294e90131baa2decf1f1d.tar.gz
Clean up toy font face handling
This commit moves the toy-to-real mapping from the scaled font creation time to font face creation. A toy font face will keep an internal ref to an implementation face. Then cairo_scaled_font_create() will simply substitute the implementation face before creating anything. This also modifies the cairo-ft toy creation in that we now create a non-resolved pattern and store it in a cairo-ft font-face. We then do the resolving and unscaled font creation at scaled-font creation time. This also means that cairo_ft_font_face_create_for_pattern() now accepts non-resolved patterns too, and does the right thing about them. As much as that can be called right. Some testing of toy font creation performance is in order, as is testing win32 and quartz font backends.
Diffstat (limited to 'src/cairo-user-font.c')
-rw-r--r--src/cairo-user-font.c62
1 files changed, 7 insertions, 55 deletions
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 6670b5361..9bfdedc2a 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -336,64 +336,16 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
cairo_scaled_font_t **scaled_font);
static cairo_status_t
-_cairo_user_scaled_font_get_implementation (cairo_toy_font_face_t *toy_face,
- cairo_font_face_t **font_face_out)
+_cairo_user_font_face_create_for_toy (cairo_toy_font_face_t *toy_face,
+ cairo_font_face_t **font_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) {
- face = _cairo_font_face_twin_create (cairo_toy_font_face_get_slant (&toy_face->base),
- cairo_toy_font_face_get_weight (&toy_face->base));
-
- status = cairo_font_face_set_user_data (&toy_face->base,
- &twin_font_face_key,
- face,
- (cairo_destroy_func_t) cairo_font_face_destroy);
-
- if (unlikely (status)) {
- cairo_font_face_destroy (face);
- return status;
- }
- }
-
- *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 (unlikely (status))
- return status;
-
- status = _cairo_user_font_face_scaled_font_create (face,
- font_matrix,
- ctm,
- font_options,
- font);
- if (unlikely (status))
- return status;
-
+ *font_face = _cairo_font_face_twin_create (cairo_toy_font_face_get_slant (&toy_face->base),
+ cairo_toy_font_face_get_weight (&toy_face->base));
return CAIRO_STATUS_SUCCESS;
}
-const cairo_scaled_font_backend_t _cairo_user_scaled_font_backend = {
+static 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,
_cairo_user_text_to_glyphs,
@@ -515,10 +467,10 @@ _cairo_user_font_face_scaled_font_create (void *abstract_
return status;
}
-static const cairo_font_face_backend_t _cairo_user_font_face_backend = {
+const cairo_font_face_backend_t _cairo_user_font_face_backend = {
CAIRO_FONT_TYPE_USER,
+ _cairo_user_font_face_create_for_toy,
NULL, /* destroy */
- NULL, /* direct implementation */
_cairo_user_font_face_scaled_font_create
};