summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-24 05:00:07 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-09-24 05:03:42 (GMT)
commit548cf5f33865f18ee72584c7619fb3f3807cdc2a (patch)
tree858fac4c7f9defb75aef9f2001feed521b29c3bc /gfx
parent18e6fee580526958cdc141884062e5502312da6a (diff)
downloadeeshow-548cf5f33865f18ee72584c7619fb3f3807cdc2a.zip
eeshow-548cf5f33865f18ee72584c7619fb3f3807cdc2a.tar.gz
eeshow-548cf5f33865f18ee72584c7619fb3f3807cdc2a.tar.bz2
gfx/cro.c (cr_text_cairo): ignore ~ when sizing; consider disable_overline
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 0be7cce..823ad4f 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -137,6 +137,20 @@ static void paint(struct cro_ctx *cc, int color, int fill_color)
}
+static char *remove_tildes(const char *s)
+{
+ char *t, *to;
+ const char *from;
+
+ t = stralloc(s);
+ for (from = to = t; *from; from++)
+ if (*from != '~')
+ *to++ = *from;
+ *to = 0;
+ return t;
+}
+
+
/* ----- General items ----------------------------------------------------- */
@@ -329,10 +343,17 @@ static void cr_text_cairo(void *ctx, int x, int y, const char *s, unsigned size,
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
cairo_matrix_t m;
+ char *t;
select_font(cc, style);
cairo_set_font_size(cc->cr, cd(cc, size) * TEXT_STRETCH);
- cairo_text_extents(cc->cr, s, &ext);
+ if (disable_overline) {
+ cairo_text_extents(cc->cr, s, &ext);
+ } else {
+ t = remove_tildes(s);
+ cairo_text_extents(cc->cr, t, &ext);
+ free(t);
+ }
set_color(cc, color);
@@ -441,19 +462,18 @@ static unsigned cr_text_width(void *ctx, const char *s, unsigned size,
{
struct cro_ctx *cc = ctx;
cairo_text_extents_t ext;
- char *t, *to;
- const char *from;
+ char *t;
- t = stralloc(s);
- for (from = to = t; *from; from++)
- if (*from != '~')
- *to++ = *from;
- *to = 0;
select_font(cc, style);
cairo_set_font_size(cc->cr, cd(cc, size) * TEXT_STRETCH);
- cairo_text_extents(cc->cr, t, &ext);
- free(t);
+ if (disable_overline) {
+ cairo_text_extents(cc->cr, s, &ext);
+ } else {
+ t = remove_tildes(s);
+ cairo_text_extents(cc->cr, t, &ext);
+ free(t);
+ }
return dc(cc, ext.width);
}