#include <glib.h>
#include <GL/glx.h>
+#define TPOINTS 15.0
+
+#define TOFLOAT(x) (((x) >> 6) + ((x) & 63)/64.0)
+
#include FT_OUTLINE_H
struct GlftWalkState {
int GlftMoveToFunc(FT_Vector *to, void *user)
{
- state.x = (to->x >> 6) + (to->x & 63)/64;
- state.y = (to->y >> 6) + (to->y & 63)/64;
+ state.x = TOFLOAT(to->x);
+ state.y = TOFLOAT(to->y);
printf("move to %f:%f\n", state.x, state.y);
if (state.drawing) {
glEnd();
state.drawing = 1;
} else
glVertex2f(state.x, state.y);
- state.x = (to->x >> 6) + (to->x & 63)/64;
- state.y = (to->y >> 6) + (to->y & 63)/64;
+ state.x = TOFLOAT(to->x);
+ state.y = TOFLOAT(to->y);
printf("line to %f:%f\n", state.x, state.y);
glVertex2f(state.x, state.y);
return 0;
int GlftConicToFunc(FT_Vector *c, FT_Vector *to, void *user)
{
- GlftLineToFunc(to, user);
+ float t, u, x, y;
+
+ for (t = 0, u = 1; t < 1.0; t += 1.0/TPOINTS, u = 1.0-t) {
+ x = u*u*state.x + 2*t*u*TOFLOAT(c->x) + t*t*TOFLOAT(to->x);
+ y = u*u*state.y + 2*t*u*TOFLOAT(c->y) + t*t*TOFLOAT(to->y);
+/*printf("cone to %f, %f (%f, %f)\n", x, y, t, u);*/
+ glVertex2f(x, y);
+ }
+ state.x = TOFLOAT(to->x);
+ state.y = TOFLOAT(to->y);
printf("conic the hedgehog!\n");
return 0;
}
int x, int y)
{
const char *c;
- struct GlftGlyph *g, *n;
+ struct GlftGlyph *g;
if (!g_utf8_validate(str, bytes, NULL)) {
GlftDebug("Invalid UTF-8 in string\n");
c = str;
while (c - str < bytes) {
g = GlftFontGlyph(font, c);
- n = (c - str < bytes - 1) ? GlftFontGlyph(font, c+1) : 0;
if (g) {
glCallList(g->dlist);
- if (n) glTranslatef(GlftFontAdvance(font, g, n), 0.0, 0.0);
+ glTranslatef(g->width, 0.0, 0.0);
} else
glTranslatef(font->max_advance_width, 0.0, 0.0);
c = g_utf8_next_char(c);
int *h)
{
const char *c;
- struct GlftGlyph *g, *n;
+ struct GlftGlyph *g;
if (!g_utf8_validate(str, bytes, NULL)) {
GlftDebug("Invalid UTF-8 in string\n");
c = str;
while (c - str < bytes) {
g = GlftFontGlyph(font, c);
- n = (c - str < bytes - 1) ? GlftFontGlyph(font, c+1) : 0;
if (g) {
- *w += GlftFontAdvance(font, g, n);
+ *w += g->width;
*h = MAX(g->height, *h);
} else {
*w += font->max_advance_width;