9 #define TOFLOAT(x) (((x) >> 6) + ((x) & 63)/64.0)
13 struct GlftWalkState {
18 static struct GlftWalkState state;
20 int GlftMoveToFunc(FT_Vector *to, void *user)
22 state.x = TOFLOAT(to->x);
23 state.y = TOFLOAT(to->y);
27 glBegin(GL_LINE_STRIP);
28 glVertex2f(state.x, state.y);
33 int GlftLineToFunc(FT_Vector *to, void *user)
35 state.x = TOFLOAT(to->x);
36 state.y = TOFLOAT(to->y);
37 glVertex2f(state.x, state.y);
41 int GlftConicToFunc(FT_Vector *c, FT_Vector *to, void *user)
45 for (t = 0, u = 1; t < 1.0; t += 1.0/TPOINTS, u = 1.0-t) {
46 x = u*u*state.x + 2*t*u*TOFLOAT(c->x) + t*t*TOFLOAT(to->x);
47 y = u*u*state.y + 2*t*u*TOFLOAT(c->y) + t*t*TOFLOAT(to->y);
50 state.x = TOFLOAT(to->x);
51 state.y = TOFLOAT(to->y);
52 glVertex2f(state.x, state.y);
56 int GlftCubicToFunc(FT_Vector *c1, FT_Vector *c2, FT_Vector *to, void
59 GlftLineToFunc(to, user);
60 g_message("cubic not currently rendered properly\n");
64 FT_Outline_Funcs GlftFuncs = {
73 void GlftRenderGlyph(FT_Face face, unsigned int dlist)
76 FT_GlyphSlot slot = face->glyph;
82 glNewList(dlist, GL_COMPILE);
83 err = FT_Outline_Decompose(&slot->outline, &GlftFuncs, NULL);
90 void GlftRenderString(struct GlftFont *font, const char *str, int bytes,
96 if (!g_utf8_validate(str, bytes, NULL)) {
97 GlftDebug("Invalid UTF-8 in string\n");
104 while (c - str < bytes) {
105 g = GlftFontGlyph(font, c);
107 glCallList(g->dlist);
108 glTranslatef(g->width, 0.0, 0.0);
110 glTranslatef(font->max_advance_width, 0.0, 0.0);
111 c = g_utf8_next_char(c);
117 void GlftMeasureString(struct GlftFont *font,
126 if (!g_utf8_validate(str, bytes, NULL)) {
127 GlftDebug("Invalid UTF-8 in string\n");
135 while (c - str < bytes) {
136 g = GlftFontGlyph(font, c);
139 *h = MAX(g->height, *h);
141 *w += font->max_advance_width;
143 c = g_utf8_next_char(c);