summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-26 01:29:12 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-26 01:40:30 -0300
commit910608ba17c7ad3cba78d274d0bbc4037042e145 (patch)
treeecd35fbe8403eaddccd4282bd63d35e628f59db5
parent975bcea4f1735372eb8d25dba32b61c3670af0d8 (diff)
downloadeeshow-910608ba17c7ad3cba78d274d0bbc4037042e145.tar.gz
eeshow-910608ba17c7ad3cba78d274d0bbc4037042e145.tar.bz2
eeshow-910608ba17c7ad3cba78d274d0bbc4037042e145.zip
pass text style to gfx_text{,_width} and related functions
-rw-r--r--gfx/cro.c18
-rw-r--r--gfx/diff.c10
-rw-r--r--gfx/fig.c6
-rw-r--r--gfx/gfx.c11
-rw-r--r--gfx/gfx.h12
-rw-r--r--gfx/record.c9
-rw-r--r--gfx/record.h4
-rw-r--r--gfx/text.c6
8 files changed, 49 insertions, 27 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 689d126..aac444a 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -291,7 +291,8 @@ static void overlined(cairo_t *cr, const char *s, double h)
static void cr_text_cairo(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
@@ -329,7 +330,8 @@ static void cr_text_cairo(void *ctx, int x, int y, const char *s, unsigned size,
static void cr_text_pango(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
struct cro_ctx *cc = ctx;
PangoRectangle ink;
@@ -379,16 +381,20 @@ static void cr_text_pango(void *ctx, int x, int y, const char *s, unsigned size,
static void cr_text(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
if (use_pango)
- cr_text_pango(ctx, x, y, s, size, align, rot, color, layer);
+ cr_text_pango(ctx, x, y, s, size, align, rot, style,
+ color, layer);
else
- cr_text_cairo(ctx, x, y, s, size, align, rot, color, layer);
+ cr_text_cairo(ctx, x, y, s, size, align, rot, style,
+ color, layer);
}
-static unsigned cr_text_width(void *ctx, const char *s, unsigned size)
+static unsigned cr_text_width(void *ctx, const char *s, unsigned size,
+ enum text_style style)
{
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
diff --git a/gfx/diff.c b/gfx/diff.c
index e61eade..59c37af 100644
--- a/gfx/diff.c
+++ b/gfx/diff.c
@@ -103,19 +103,21 @@ static void diff_arc(void *ctx, int x, int y, int r, int sa, int ea,
static void diff_text(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
const struct diff *diff = ctx;
- gfx_text(diff->gfx, x, y, s, size, align, rot, color, layer);
+ gfx_text(diff->gfx, x, y, s, size, align, rot, style, color, layer);
}
-static unsigned diff_text_width(void *ctx, const char *s, unsigned size)
+static unsigned diff_text_width(void *ctx, const char *s, unsigned size,
+ enum text_style style)
{
const struct diff *diff = ctx;
- return gfx_text_width(diff->gfx, s, size);
+ return gfx_text_width(diff->gfx, s, size, style);
}
diff --git a/gfx/fig.c b/gfx/fig.c
index d469a28..fbb3a8f 100644
--- a/gfx/fig.c
+++ b/gfx/fig.c
@@ -163,7 +163,8 @@ static void fig_tag(void *ctx, const char *s,
static void fig_text(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
// Type Depth FontSiz Height
// Just Pen Angle Length
@@ -174,7 +175,8 @@ static void fig_text(void *ctx, int x, int y, const char *s, unsigned size,
}
-static unsigned fig_text_width(void *ctx, const char *s, unsigned size)
+static unsigned fig_text_width(void *ctx, const char *s, unsigned size,
+ enum text_style style)
{
/*
* Note that we stretch the text size, so the ratio is larger than
diff --git a/gfx/gfx.c b/gfx/gfx.c
index 0b407ba..a0f055f 100644
--- a/gfx/gfx.c
+++ b/gfx/gfx.c
@@ -81,9 +81,11 @@ void gfx_arc(struct gfx *gfx, int x, int y, int r, int sa, int ea,
void gfx_text(struct gfx *gfx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
- gfx->ops->text(gfx->user, x, y, s, size, align, rot, color, layer);
+ gfx->ops->text(gfx->user, x, y, s, size, align, rot, style,
+ color, layer);
}
@@ -95,9 +97,10 @@ void gfx_tag(struct gfx *gfx, const char *s,
}
-unsigned gfx_text_width(struct gfx *gfx, const char *s, unsigned size)
+unsigned gfx_text_width(struct gfx *gfx, const char *s, unsigned size,
+ enum text_style style)
{
- return gfx->ops->text_width(gfx->user, s, size);
+ return gfx->ops->text_width(gfx->user, s, size, style);
}
diff --git a/gfx/gfx.h b/gfx/gfx.h
index 330a2fb..85fdc32 100644
--- a/gfx/gfx.h
+++ b/gfx/gfx.h
@@ -35,10 +35,12 @@ struct gfx_ops {
void (*arc)(void *ctx, int x, int y, int r, int sa, int ea,
int color, int fill_color, unsigned layer);
void (*text)(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer);
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer);
void (*tag)(void *ctx, const char *s,
int points, const int x[points], const int y[points]);
- unsigned (*text_width)(void *ctx, const char *s, unsigned size);
+ unsigned (*text_width)(void *ctx, const char *s, unsigned size,
+ enum text_style style);
void *(*init)(void);
bool (*args)(void *ctx, int argc, char *const *argv);
void (*sheet_name)(void *ctx, const char *name);
@@ -61,10 +63,12 @@ void gfx_circ(struct gfx *gfx,
void gfx_arc(struct gfx *gfx, int x, int y, int r, int sa, int ea,
int color, int fill_color, unsigned layer);
void gfx_text(struct gfx *gfx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer);
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer);
void gfx_tag(struct gfx *gfx, const char *s,
unsigned points, const int x[points], int const y[points]);
-unsigned gfx_text_width(struct gfx *gfx, const char *s, unsigned size);
+unsigned gfx_text_width(struct gfx *gfx, const char *s, unsigned size,
+ enum text_style style);
/* inititalization and termination */
diff --git a/gfx/record.c b/gfx/record.c
index 0add67f..5adc5c3 100644
--- a/gfx/record.c
+++ b/gfx/record.c
@@ -58,6 +58,7 @@ struct record_obj {
unsigned size;
enum text_align align;
int rot;
+ enum text_style style;
} text;
} u;
struct record_obj *next;
@@ -213,12 +214,13 @@ void record_arc(void *ctx, int x, int y, int r, int sa, int ea,
void record_text(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer)
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer)
{
struct record *rec = ctx;
struct record_obj *obj =
new_obj(ctx, ro_text, color, COLOR_NONE, layer);
- unsigned width = rec->ops->text_width(rec->user, s, size);
+ unsigned width = rec->ops->text_width(rec->user, s, size, style);
bb_rot(rec, x, y - size, rot);
bb_rot(rec, x + width, y, rot);
@@ -229,6 +231,7 @@ void record_text(void *ctx, int x, int y, const char *s, unsigned size,
obj->u.text.size = size;
obj->u.text.align = align;
obj->u.text.rot = rot;
+ obj->u.text.style = style;
}
@@ -286,7 +289,7 @@ void record_replay(const struct record *rec)
case ro_text:
ops->text(ctx, obj->x, obj->y, obj->u.text.s,
obj->u.text.size, obj->u.text.align,
- obj->u.text.rot,
+ obj->u.text.rot, obj->u.text.style,
obj->color, layer->layer);
break;
default:
diff --git a/gfx/record.h b/gfx/record.h
index 85e44b2..b492ed7 100644
--- a/gfx/record.h
+++ b/gfx/record.h
@@ -14,6 +14,7 @@
#ifndef GFX_RECORD_H
#define GFX_RECORD_H
+#include "gfx/text.h"
#include "gfx/gfx.h"
@@ -47,7 +48,8 @@ void record_circ(void *ctx, int x, int y, int r,
void record_arc(void *ctx, int x, int y, int r, int sa, int ea,
int color, int fill_color, unsigned layer);
void record_text(void *ctx, int x, int y, const char *s, unsigned size,
- enum text_align align, int rot, unsigned color, unsigned layer);
+ enum text_align align, int rot, enum text_style style,
+ unsigned color, unsigned layer);
void record_init(struct record *rec, const struct gfx_ops *ops, void *user);
void record_wipe(struct record *rec);
diff --git a/gfx/text.c b/gfx/text.c
index df3e5cc..ad345ad 100644
--- a/gfx/text.c
+++ b/gfx/text.c
@@ -115,8 +115,8 @@ void text_show(const struct text *txt, struct gfx *gfx,
if (!s)
break;
tmp = NULL;
- gfx_text(gfx, x, y, s, txt->size, txt->hor, txt->rot, color,
- layer);
+ gfx_text(gfx, x, y, s, txt->size, txt->hor, txt->rot,
+ txt->style, color, layer);
x += rx(0, NEWLINE_SKIP * txt->size, txt->rot);
y += ry(0, NEWLINE_SKIP * txt->size, txt->rot);
}
@@ -128,7 +128,7 @@ void text_rel(const struct text *txt, struct gfx *gfx,
enum text_align xr, enum text_align yr,
int dx, int dy, int *res_x, int *res_y)
{
- int width = gfx_text_width(gfx, txt->s, txt->size);
+ int width = gfx_text_width(gfx, txt->s, txt->size, txt->style);
dx -= align(width, txt->hor);
dy += align(txt->size, txt->vert);