summaryrefslogtreecommitdiff
path: root/src/cairo-toy-font-face.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-06-07 18:59:36 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-06-07 19:49:00 +0100
commit6d693f6bd7c629372cfb6c284ca98dc04619bfe9 (patch)
treebe31e681e3dc904c1cb7fa15fd077a656a1d9f69 /src/cairo-toy-font-face.c
parenta29426f4bffc0a3f5bb349a2ba44203394339ae8 (diff)
downloadcairo-6d693f6bd7c629372cfb6c284ca98dc04619bfe9.tar.gz
[ft] Support font_face->get_implementation
The lazy resolution of patterns was defeating the scaled_font cache as ft-fonts that resolved to the same unscaled font were being given different font-faces upon creation. We can keep the lazy resolution by simply asking the ft backend to create a fully resolved ft-font-face when we need to create a scaled-font. This font is then keyed by the resolved font-face and so will match all future lazily resolved identical patterns.
Diffstat (limited to 'src/cairo-toy-font-face.c')
-rw-r--r--src/cairo-toy-font-face.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index b2d41af30..a9b600a5c 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -387,26 +387,34 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
return _cairo_font_face_set_error (&font_face->base, CAIRO_STATUS_FONT_TYPE_MISMATCH);
}
-static cairo_bool_t
-_cairo_font_face_is_toy (cairo_font_face_t *font_face)
+static cairo_font_face_t *
+_cairo_toy_font_face_get_implementation (void *abstract_font_face,
+ const cairo_matrix_t *font_matrix,
+ const cairo_matrix_t *ctm,
+ const cairo_font_options_t *options)
{
- return font_face->backend == &_cairo_toy_font_face_backend;
-}
+ cairo_toy_font_face_t *font_face = abstract_font_face;
-cairo_font_face_t *
-_cairo_toy_font_face_get_implementation (cairo_font_face_t *font_face)
-{
- cairo_toy_font_face_t *toy_font_face;
+ if (font_face->impl_face) {
+ cairo_font_face_t *impl = font_face->impl_face;
- if (font_face->status)
- return NULL;
+ if (impl->backend->get_implementation != NULL) {
+ return impl->backend->get_implementation (impl,
+ font_matrix,
+ ctm,
+ options);
+ }
- toy_font_face = (cairo_toy_font_face_t *) font_face;
- if (! _cairo_font_face_is_toy (font_face)) {
- if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH))
- return NULL;
+ return cairo_font_face_reference (impl);
}
- return toy_font_face->impl_face ? toy_font_face->impl_face : font_face;
+
+ return abstract_font_face;
+}
+
+static cairo_bool_t
+_cairo_font_face_is_toy (cairo_font_face_t *font_face)
+{
+ return font_face->backend == &_cairo_toy_font_face_backend;
}
/**
@@ -495,7 +503,8 @@ static const cairo_font_face_backend_t _cairo_toy_font_face_backend = {
CAIRO_FONT_TYPE_TOY,
NULL, /* create_for_toy */
_cairo_toy_font_face_destroy,
- _cairo_toy_font_face_scaled_font_create
+ _cairo_toy_font_face_scaled_font_create,
+ _cairo_toy_font_face_get_implementation
};
void