summaryrefslogtreecommitdiff
path: root/src/cairo-font-face.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-09-25 04:27:11 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-09-25 19:25:11 -0400
commitd5a998387bcee6569d33375d592190f480f12712 (patch)
tree39bc97984de1e8448bb08a971739858429ad07dc /src/cairo-font-face.c
parentdd7e2461ce748403e121a5de5e4e4c8890e39236 (diff)
Add an internal font face
The font data and rendering is adapted from Keith Packard's Twin window system. The hinting stuff is not ported yet, but hey, it renders! The implementation uses user fonts, and the user font backend is modified to use this font face (which we call "twin" font face internally) when a toy font is needed. The font face layer is then modified to use this font if: - The toy font face "cairo" is asked for, or - No native font backend is available, or - The preferred native font backend fails to return a font with STATUS_UNSUPPORTED. No font backend does this right now but the idea is to change FreeType to return it if no fonts found on the system. We also allow building with no font backends now! The new doc/tutorial/src/twin.c file tests the twin face at various sizes.
Diffstat (limited to 'src/cairo-font-face.c')
-rw-r--r--src/cairo-font-face.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index 5af0c63f..02ad7c31 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -574,7 +574,6 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
cairo_scaled_font_t **scaled_font)
{
cairo_toy_font_face_t *font_face = abstract_font_face;
- const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
cairo_status_t status;
if (font_face->base.status)
@@ -584,12 +583,32 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
if (status)
return status;
- return _cairo_font_face_set_error (&font_face->base,
- backend->create_toy (font_face,
- font_matrix,
- ctm,
- options,
- scaled_font));
+ if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend &&
+ 0 != strcmp (font_face->family, CAIRO_USER_FONT_FAMILY_DEFAULT))
+ {
+ const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
+
+ *scaled_font = NULL;
+ status = backend->create_toy (font_face,
+ font_matrix,
+ ctm,
+ options,
+ scaled_font);
+
+ if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+ return _cairo_font_face_set_error (&font_face->base, status);
+
+ if (*scaled_font)
+ cairo_scaled_font_destroy (*scaled_font);
+ }
+
+ status = _cairo_user_scaled_font_backend.create_toy (font_face,
+ font_matrix,
+ ctm,
+ options,
+ scaled_font);
+
+ return _cairo_font_face_set_error (&font_face->base, status);
}
static cairo_bool_t