diff --git a/sch2fig/dwg.c b/sch2fig/dwg.c index af37b7c..2298a96 100644 --- a/sch2fig/dwg.c +++ b/sch2fig/dwg.c @@ -365,6 +365,43 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim, } +/* ----- Text -------------------------------------------------------------- */ + + +void dwg_text(int x, int y, const char *s, int dir, int dim, + enum dwg_shape shape) +{ + struct text txt = { + .s = s, + .size = dim, + .x = x, + .y = y, + .rot = 0, + .hor = text_min, + .vert = text_min, + }; + + switch (dir) { + case 0: /* right */ + break; + case 1: /* up */ + text_rot(&txt, 90); + break; + case 2: /* left */ + txt.hor = text_max; + break; + case 3: /* down */ + text_rot(&txt, 90); + txt.hor = text_max; + break; + default: + assert(2 + 2 == 5); + } + + text_fig(&txt, COLOR_TEXT, LAYER_TEXT); +} + + /* ----- Connections ------------------------------------------------------- */ diff --git a/sch2fig/dwg.h b/sch2fig/dwg.h index ea683c6..697f524 100644 --- a/sch2fig/dwg.h +++ b/sch2fig/dwg.h @@ -32,6 +32,8 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim, enum dwg_shape shape); void dwg_glabel(int x, int y, const char *s, int dir, int dim, enum dwg_shape shape); +void dwg_text(int x, int y, const char *s, int dir, int dim, + enum dwg_shape shape); void dwg_junction(int x, int y); void dwg_noconn(int x, int y); diff --git a/sch2fig/sch.c b/sch2fig/sch.c index 201e461..2b2c163 100644 --- a/sch2fig/sch.c +++ b/sch2fig/sch.c @@ -209,43 +209,6 @@ static enum dwg_shape decode_shape(const char *s) } -/* ----- Text -------------------------------------------------------------- */ - - -static void draw_text(int x, int y, const char *s, int dir, int dim, - enum dwg_shape shape) -{ - struct text txt = { - .s = s, - .size = dim, - .x = x, - .y = y, - .rot = 0, - .hor = text_min, - .vert = text_min, - }; - - switch (dir) { - case 0: /* right */ - break; - case 1: /* up */ - text_rot(&txt, 90); - break; - case 2: /* left */ - txt.hor = text_max; - break; - case 3: /* down */ - text_rot(&txt, 90); - txt.hor = text_max; - break; - default: - assert(2 + 2 == 5); - } - - text_fig(&txt, COLOR_TEXT, LAYER_TEXT); -} - - /* ----- Component fields -------------------------------------------------- */ @@ -494,7 +457,7 @@ bool sch_parse(struct sch_ctx *ctx, const char *line) if (sscanf(line, "Text Notes %d %d %d %d", &obj->x, &obj->y, &text->dir, &text->dim) == 4) { ctx->state = sch_text; - obj->u.text.fn = draw_text; + obj->u.text.fn = dwg_text; return 1; } if (sscanf(line, "Text GLabel %d %d %d %d %ms",