summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-22 04:52:18 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-22 04:52:18 -0300
commit4026b0a2da4de5595056246a673993a995237a33 (patch)
tree27fc04fad240f8ee55f1711e3848a4845f39a808 /kicad
parentf4e780e0101b81d373a6fec3fc41bd8e382f9c21 (diff)
downloadeeshow-4026b0a2da4de5595056246a673993a995237a33.tar.gz
eeshow-4026b0a2da4de5595056246a673993a995237a33.tar.bz2
eeshow-4026b0a2da4de5595056246a673993a995237a33.zip
eeshow/kicad/: support text justification in page layout
Diffstat (limited to 'kicad')
-rw-r--r--kicad/pl-common.h3
-rw-r--r--kicad/pl-parse.c34
-rw-r--r--kicad/pl-render.c19
3 files changed, 53 insertions, 3 deletions
diff --git a/kicad/pl-common.h b/kicad/pl-common.h
index 72ce0f3..4680efd 100644
--- a/kicad/pl-common.h
+++ b/kicad/pl-common.h
@@ -14,6 +14,7 @@
#ifndef KICAD_PL_COMMON_H
#define KICAD_PL_COMMON_H
+#include "gfx/text.h"
#include "kicad/sexpr.h"
@@ -39,6 +40,8 @@ struct pl_obj {
float incrx, incry;
int incrlabel; /* tbtext */
int font; /* tbtext (flags) */
+ enum text_align hor; /* tbtext */
+ enum text_align vert; /* tbtext */
struct pl_obj *next;
};
diff --git a/kicad/pl-parse.c b/kicad/pl-parse.c
index 5b75f64..467ceca 100644
--- a/kicad/pl-parse.c
+++ b/kicad/pl-parse.c
@@ -17,6 +17,7 @@
#include "misc/util.h"
#include "misc/diag.h"
+#include "gfx/text.h"
#include "file/file.h"
#include "kicad/sexpr.h"
#include "kicad/pl-common.h"
@@ -170,8 +171,34 @@ static bool process_font(struct pl_obj *obj, const struct expr *e)
if (!get_coord(next, &obj->ex, &obj->ey,
&obj->edx, &obj->edy))
return 0;
- } else
+ } else {
warning("ignoring \"%s\"\n", s);
+ }
+ }
+ return 1;
+}
+
+
+static bool process_justify(struct pl_obj *obj, const struct expr *e)
+{
+ for (; e; e = e->next) {
+ if (e->e) {
+ warning("ignoring list\n");
+ continue;
+ }
+
+ if (!strcmp(e->s, "center"))
+ obj->hor = obj->vert = text_mid;
+ else if (!strcmp(e->s, "left"))
+ obj->hor = text_min;
+ else if (!strcmp(e->s, "right"))
+ obj->hor = text_max;
+ else if (!strcmp(e->s, "top"))
+ obj->vert = text_max;
+ else if (!strcmp(e->s, "bottom"))
+ obj->vert = text_min;
+ else
+ warning("ignoring \"%s\"\n", e->s);
}
return 1;
}
@@ -194,6 +221,8 @@ static bool process_obj(struct pl_ctx *pl, const struct expr *e,
obj->incry = 0;
obj->incrlabel = 0;
obj->font = 0;
+ obj->hor = text_min;
+ obj->vert = text_mid;
for (; e; e = e->next) {
if (e->s) {
@@ -242,6 +271,9 @@ static bool process_obj(struct pl_ctx *pl, const struct expr *e,
} else if (!strcmp(s, "font")) {
if (!process_font(obj, next))
return 0;
+ } else if (!strcmp(s, "justify")) {
+ if (!process_justify(obj, next))
+ return 0;
} else
warning("ignoring \"%s\"\n", s);
}
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index b682a82..6be02e4 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -42,6 +42,22 @@ static int coord(int v, int d, int o, int e)
}
+static void render_text(const struct pl_obj *obj, int x, int y)
+{
+ struct text txt = {
+ .s = obj->s,
+ .size = mil(obj->ey),
+ .x = x,
+ .y = y,
+ .rot = 0,
+ .hor = obj->hor,
+ .vert = obj->vert,
+ };
+
+ text_fig(&txt, COLOR_COMP_DWG, LAYER_COMP_DWG);
+}
+
+
static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
unsigned i, int w, int h)
{
@@ -80,8 +96,7 @@ static void render_obj(const struct pl_ctx *pl, const struct pl_obj *obj,
}
break;
case pl_obj_text:
- gfx_text(x, y, obj->s, mil(obj->ey), text_min, 0,
- COLOR_COMP_DWG, LAYER_COMP_DWG);
+ render_text(obj, x, y);
break;
default:
break;