14 static struct GlftWalkState state;
16 int GlftMoveToFunc(FT_Vector *to, void *user)
18 state.x = (to->x >> 6) + (to->x & 63)/64;
19 state.y = (to->y >> 6) + (to->y & 63)/64;
20 printf("move to %f:%f\n", state.x, state.y);
28 int GlftLineToFunc(FT_Vector *to, void *user)
32 glVertex2f(state.x, state.y);
35 glVertex2f(state.x, state.y);
36 state.x = (to->x >> 6) + (to->x & 63)/64;
37 state.y = (to->y >> 6) + (to->y & 63)/64;
38 printf("line to %f:%f\n", state.x, state.y);
39 glVertex2f(state.x, state.y);
43 int GlftConicToFunc(FT_Vector *c, FT_Vector *to, void *user)
45 GlftLineToFunc(to, user);
46 printf("conic the hedgehog!\n");
50 int GlftCubicToFunc(FT_Vector *c1, FT_Vector *c2, FT_Vector *to, void
53 GlftLineToFunc(to, user);
58 FT_Outline_Funcs GlftFuncs = {
67 void GlftRenderGlyph(FT_Face face, unsigned int dlist)
70 FT_GlyphSlot slot = face->glyph;
76 glNewList(dlist, GL_COMPILE);
77 err = FT_Outline_Decompose(&slot->outline, &GlftFuncs, NULL);
84 void GlftRenderString(struct GlftFont *font, const char *str, int bytes,
88 struct GlftGlyph *g, *n;
90 if (!g_utf8_validate(str, bytes, NULL)) {
91 GlftDebug("Invalid UTF-8 in string\n");
98 while (c - str < bytes) {
99 g = GlftFontGlyph(font, c);
100 n = (c - str < bytes - 1) ? GlftFontGlyph(font, c+1) : 0;
102 glCallList(g->dlist);
103 if (n) glTranslatef(GlftFontAdvance(font, g, n), 0.0, 0.0);
105 glTranslatef(font->max_advance_width, 0.0, 0.0);
106 c = g_utf8_next_char(c);
112 void GlftMeasureString(struct GlftFont *font,
119 struct GlftGlyph *g, *n;
121 if (!g_utf8_validate(str, bytes, NULL)) {
122 GlftDebug("Invalid UTF-8 in string\n");
130 while (c - str < bytes) {
131 g = GlftFontGlyph(font, c);
132 n = (c - str < bytes - 1) ? GlftFontGlyph(font, c+1) : 0;
134 *w += GlftFontAdvance(font, g, n);
135 *h = MAX(g->height, *h);
137 *w += font->max_advance_width;
139 c = g_utf8_next_char(c);