summaryrefslogtreecommitdiff
path: root/src/cairo-font-face-twin.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-09-25 19:08:24 -0400
committerBehdad Esfahbod <behdad@behdad.org>2008-09-25 19:25:11 -0400
commitf8542dc9dd4dd0685f68381f21fa72dbddd8d682 (patch)
tree4d83b39d7b74709a6a1f21a7339b74ba90691e7b /src/cairo-font-face-twin.c
parentd5a998387bcee6569d33375d592190f480f12712 (diff)
[twin-font] Clean up font data by joining lines and closing paths
Two changes here: * Replace move_to;line_to;move_to;line_to sequences with move_to;line_to;line_to when feasible. * Close paths for round glyphs. Both improve the stroke rendering of the joint. The first change also saves 3 bytes per joint (33 such joints). Which we have just left unused for now. To reclaim them one need to update the charset table. Something for a lazy Sunday afternoon scripting task. In the saving department, we can save further by: - Getting rid of the left/ascent/descent values as we compute glyph bounding box automatically. Then we can liberally use the right value to adjust glyph advance width. Saves three bytes per glyph (there's 96 glyphs in the font). - First operation is always a move_to. So we can remove the 'm' for that. Ugly though. And the charset has zeros for the first 32 entries. Can get rid of that too at the expense of handling it in the code... In total, combining the above we can save some 500 bytes. The font currently takes about 3.7kb.
Diffstat (limited to 'src/cairo-font-face-twin.c')
-rw-r--r--src/cairo-font-face-twin.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index 86e083df..75669a54 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -125,6 +125,9 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
for (;;) {
switch (*g++) {
+ case 'M':
+ cairo_close_path (cr);
+ /* fall through */
case 'm':
x1 = FX(*g++);
y1 = FY(*g++);
@@ -135,6 +138,9 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
}
cairo_move_to (cr, x1, y1);
continue;
+ case 'L':
+ cairo_close_path (cr);
+ /* fall through */
case 'l':
x1 = FX(*g++);
y1 = FY(*g++);
@@ -145,6 +151,9 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
}
cairo_line_to (cr, x1, y1);
continue;
+ case 'C':
+ cairo_close_path (cr);
+ /* fall through */
case 'c':
x1 = FX(*g++);
y1 = FY(*g++);
@@ -163,18 +172,19 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
}
cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
continue;
- case 'o':
+ case 'E':
cairo_close_path (cr);
- break;
+ /* fall through */
case 'e':
cairo_stroke (cr);
break;
+ case 'X':
+ /* filler */
+ continue;
}
break;
}
- cairo_stroke (cr);
-
metrics->x_advance = FX(twin_glyph_right(b)) + cairo_get_line_width (cr);
metrics->x_advance += cairo_get_line_width (cr)/* XXX 2*x.margin */;
if (info.snap)