diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2008-09-25 04:27:11 -0400 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2008-09-25 19:25:11 -0400 |
commit | d5a998387bcee6569d33375d592190f480f12712 (patch) | |
tree | 39bc97984de1e8448bb08a971739858429ad07dc /doc | |
parent | dd7e2461ce748403e121a5de5e4e4c8890e39236 (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 'doc')
-rw-r--r-- | doc/tutorial/src/twin.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/doc/tutorial/src/twin.c b/doc/tutorial/src/twin.c new file mode 100644 index 000000000..fe0e90e72 --- /dev/null +++ b/doc/tutorial/src/twin.c @@ -0,0 +1,39 @@ +/** + * Put this file in cairo/doc/tutorial/src and type "make" + */ + +#define WIDTH 1350 +#define HEIGHT 900 + +#include "cairo-tutorial.h" + + +static void +draw (cairo_t *cr, int width, int height) +{ + int i, j, h; + unsigned char s[2] = {0, 0}; + + /* clear background */ + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_select_font_face (cr, + "cairo", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + + h = 2; + for (i = 8; i < 48; i >= 24 ? i+=3 : i++) { + cairo_set_font_size (cr, i); + for (j = 33; j < 128; j++) { + if (j == 33 || (j == 80 && i > 24)) { + h += i + 2; + cairo_move_to (cr, 10, h); + } + s[0] = j; + cairo_show_text (cr, (const char *) s); + } + } +} |