Index: ttf2lht/drv_anim.c =================================================================== --- ttf2lht/drv_anim.c (revision 18929) +++ ttf2lht/drv_anim.c (revision 18930) @@ -4,26 +4,41 @@ static int stroke_anim_move_to(const FT_Vector *to, void *s_) { - stroke_t *s = (stroke_t *)s_; - s->x = to->x; - s->y = to->y; + anim_stroke_t *s = (anim_stroke_t *)s_; + s->s.x = to->x; + s->s.y = to->y; return 0; } static int stroke_anim_line_to(const FT_Vector *to, void *s_) { - stroke_t *s = (stroke_t *)s_; - printf("line %f %f %ld %ld\n", s->x, s->y, to->x, to->y); - s->x = to->x; - s->y = to->y; + anim_stroke_t *s = (anim_stroke_t *)s_; + printf("line %f %f %ld %ld\n", s->s.x, s->s.y, to->x, to->y); + s->s.x = to->x; + s->s.y = to->y; return 0; } -FT_Outline_Funcs drv_anim_funcs = { - stroke_anim_move_to, - stroke_anim_line_to, - stroke_approx_conic_to, - stroke_approx_cubic_to, - 0, - 0 +void stroke_anim_init(stroke_t *s) +{ + printf("frame\n"); +} + +void stroke_anim_uninit(stroke_t *s) +{ + printf("flush\n"); +} + +anim_stroke_t anim_stroke = { + { + { + stroke_anim_move_to, + stroke_anim_line_to, + stroke_approx_conic_to, + stroke_approx_cubic_to, + 0, 0 + }, + stroke_anim_init, + stroke_anim_uninit, + } }; Index: ttf2lht/drv_anim.h =================================================================== --- ttf2lht/drv_anim.h (revision 18929) +++ ttf2lht/drv_anim.h (revision 18930) @@ -1 +1,7 @@ -extern FT_Outline_Funcs drv_anim_funcs; +typedef struct { + stroke_t s; +} anim_stroke_t; + +extern anim_stroke_t anim_stroke; + + Index: ttf2lht/drv_approx.c =================================================================== --- ttf2lht/drv_approx.c (revision 18929) +++ ttf2lht/drv_approx.c (revision 18930) @@ -18,7 +18,7 @@ for(t = 0.0; t <= 1.0; t += td) { v.x = sqr(1.0-t) * s->x + 2*t*(1.0-t)*control->x + t*t*to->x; v.y = sqr(1.0-t) * s->y + 2*t*(1.0-t)*control->y + t*t*to->y; - s->funcs->line_to(&v, s); + s->funcs.line_to(&v, s); } if (drv_approx_comment != NULL) printf("%s }\n", drv_approx_comment); Index: ttf2lht/ttf2lht.c =================================================================== --- ttf2lht/ttf2lht.c (revision 18929) +++ ttf2lht/ttf2lht.c (revision 18930) @@ -15,13 +15,14 @@ "Need an outline font" }; -FT_Error dump(FT_ULong chr) +FT_Error dump(FT_ULong chr, stroke_t *str) { FT_Error err; FT_Glyph gly; FT_OutlineGlyph ol; - stroke_t str; + str->init(str); + // load glyph err = FT_Load_Glyph(face, FT_Get_Char_Index(face, chr), FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE); if (err != 0) @@ -32,8 +33,10 @@ if (face->glyph->format != ft_glyph_format_outline) return -1; - str.funcs = &drv_anim_funcs; - err = FT_Outline_Decompose(&(ol->outline), str.funcs, &str); + err = FT_Outline_Decompose(&(ol->outline), &str->funcs, str); + + str->uninit(str); + if (err != 0) return err; @@ -72,7 +75,7 @@ fprintf(stderr, "Family: %s\n", face->family_name); fprintf(stderr, "Height=%d ascender=%d descender=%d\n", face->height, face->ascender, face->descender); - errnum = dump('a'); + errnum = dump('a', (stroke_t *)&anim_stroke); if (errnum != 0) { if (errnum > 0) fprintf(stderr, "dump: %s\n", ft_errtab[errnum].errstr);