Index: trunk/src_plugins/import_ttf/drv_approx.c =================================================================== --- trunk/src_plugins/import_ttf/drv_approx.c (revision 20258) +++ trunk/src_plugins/import_ttf/drv_approx.c (nonexistent) @@ -1,67 +0,0 @@ -/* - * COPYRIGHT - * - * pcb-rnd, interactive printed circuit board design - * - * ttf stroker - * pcb-rnd Copyright (C) 2018 Tibor 'Igor2' Palinkas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact: - * Project page: http://repo.hu/projects/pcb-rnd - * lead developer: email to pcb-rnd (at) igor2.repo.hu - * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") - */ - -/* Dummy stroker that approximates curves with line segments */ - -#include "ttf_load.h" -#include "drv_approx.h" - -char *drv_approx_comment = "!!"; - -static double sqr(double a) -{ - return a*a; -} - -int stroke_approx_conic_to(const FT_Vector *control, const FT_Vector *to, void *s_) -{ - pcb_ttf_stroke_t *s = (pcb_ttf_stroke_t *)s_; - double t; - double nodes = 10, td = 1.0 / nodes; - FT_Vector v; - - if (drv_approx_comment != NULL) printf("%s conic to {\n", drv_approx_comment); - 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); - } - if (drv_approx_comment != NULL) printf("%s }\n", drv_approx_comment); - - s->x = to->x; - s->y = to->y; - return 0; -} - -int stroke_approx_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *s_) -{ - pcb_ttf_stroke_t *s = (pcb_ttf_stroke_t *)s_; - if (drv_approx_comment != NULL) printf("%s cubic to {\n", drv_approx_comment); - if (drv_approx_comment != NULL) printf("%s }\n", drv_approx_comment); - return 0; -} Index: trunk/src_plugins/import_ttf/drv_approx.h =================================================================== --- trunk/src_plugins/import_ttf/drv_approx.h (revision 20258) +++ trunk/src_plugins/import_ttf/drv_approx.h (nonexistent) @@ -1,4 +0,0 @@ -extern char *drv_approx_comment; - -int stroke_approx_conic_to(const FT_Vector *control, const FT_Vector *to, void *s_); -int stroke_approx_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *s_); Index: trunk/src_plugins/import_ttf/str_approx.c =================================================================== --- trunk/src_plugins/import_ttf/str_approx.c (nonexistent) +++ trunk/src_plugins/import_ttf/str_approx.c (revision 20259) @@ -0,0 +1,67 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * ttf stroker + * pcb-rnd Copyright (C) 2018 Tibor 'Igor2' Palinkas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: email to pcb-rnd (at) igor2.repo.hu + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +/* Dummy stroker that approximates curves with line segments */ + +#include "ttf_load.h" +#include "str_approx.h" + +char *str_approx_comment = "!!"; + +static double sqr(double a) +{ + return a*a; +} + +int stroke_approx_conic_to(const FT_Vector *control, const FT_Vector *to, void *s_) +{ + pcb_ttf_stroke_t *s = (pcb_ttf_stroke_t *)s_; + double t; + double nodes = 10, td = 1.0 / nodes; + FT_Vector v; + + if (str_approx_comment != NULL) printf("%s conic to {\n", str_approx_comment); + 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); + } + if (str_approx_comment != NULL) printf("%s }\n", str_approx_comment); + + s->x = to->x; + s->y = to->y; + return 0; +} + +int stroke_approx_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *s_) +{ + pcb_ttf_stroke_t *s = (pcb_ttf_stroke_t *)s_; + if (str_approx_comment != NULL) printf("%s cubic to {\n", str_approx_comment); + if (str_approx_comment != NULL) printf("%s }\n", str_approx_comment); + return 0; +} Index: trunk/src_plugins/import_ttf/str_approx.h =================================================================== --- trunk/src_plugins/import_ttf/str_approx.h (nonexistent) +++ trunk/src_plugins/import_ttf/str_approx.h (revision 20259) @@ -0,0 +1,4 @@ +extern char *str_approx_comment; + +int stroke_approx_conic_to(const FT_Vector *control, const FT_Vector *to, void *s_); +int stroke_approx_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, void *s_); Index: work/util/ttf2lht/Makefile =================================================================== --- work/util/ttf2lht/Makefile (revision 20258) +++ work/util/ttf2lht/Makefile (revision 20259) @@ -4,7 +4,7 @@ PLUGIN=$(TRUNK)/src_plugins/import_ttf/ RNDLIB=$(RND)/polygon1.o $(RND)/heap.o $(RND)/rtree.o \ $(RND3)/genvector/gds_char.o $(RND3)/genvector/vtp0.o \ - $(PLUGIN)/ttf_load.o $(PLUGIN)/drv_approx.o + $(PLUGIN)/ttf_load.o $(PLUGIN)/str_approx.o CFLAGS = -Wall -g -I/usr/include/freetype2 -I$(TRUNK) -I$(RND3) LDFLAGS = -lfreetype -lm @@ -13,7 +13,7 @@ $(PLUGIN)/ttf_load.o: $(PLUGIN)/ttf_load.c $(PLUGIN)/ttf_load.h -$(PLUGIN)/drv_approx.o: $(PLUGIN)/drv_approx.c $(PLUGIN)/drv_approx.h $(PLUGIN)/ttf_load.h +$(PLUGIN)/str_approx.o: $(PLUGIN)/str_approx.c $(PLUGIN)/str_approx.h $(PLUGIN)/ttf_load.h $(RND): cd $(RNDLIB) && make Index: work/util/ttf2lht/drv_anim.c =================================================================== --- work/util/ttf2lht/drv_anim.c (revision 20258) +++ work/util/ttf2lht/drv_anim.c (revision 20259) @@ -1,6 +1,6 @@ #include "ttf2lht.h" #include "drv_anim.h" -#include "drv_approx.h" +#include "../../../trunk/src_plugins/import_ttf/str_approx.h" static int stroke_anim_move_to(const FT_Vector *to, void *s_) { Index: work/util/ttf2lht/drv_poly.c =================================================================== --- work/util/ttf2lht/drv_poly.c (revision 20258) +++ work/util/ttf2lht/drv_poly.c (revision 20259) @@ -1,6 +1,6 @@ #include "ttf2lht.h" #include "drv_poly.h" -#include "drv_approx.h" +#include "../../../trunk/src_plugins/import_ttf/str_approx.h" #include "temp_copy.c" #define APPEND(list, pl) \ @@ -63,7 +63,7 @@ { poly_pcb_ttf_stroke_t *s = (poly_pcb_ttf_stroke_t *)s_; - drv_approx_comment = NULL; + str_approx_comment = NULL; printf("li:pcb-rnd-font-v1 {\n"); printf(" ha:geda_pcb {\n"); printf(" id = 0\n");