[cairo-commit] 2 commits - src/cairo-font-face-twin.c src/cairo-font-face-twin-data.c

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Dec 24 00:48:26 PST 2008


 src/cairo-font-face-twin-data.c |   54 ++++++++++++++++++++++++----------------
 src/cairo-font-face-twin.c      |   30 +++++++++++++++++-----
 2 files changed, 56 insertions(+), 28 deletions(-)

New commits:
commit 6c1d21bf8947f5b11702626ddfd9bac18073188d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Dec 24 03:47:21 2008 -0500

    [twin] Implement monospace

diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index ade41e6..e06bf26 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -285,6 +285,8 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
     twin_face_properties_t *props;
     const int8_t *b;
     const int8_t *g;
+    int8_t w;
+    double lw;
 
     struct {
       cairo_bool_t snap;
@@ -297,12 +299,14 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
     b = _cairo_twin_outlines +
 	_cairo_twin_charmap[unlikely (glyph >= ARRAY_LENGTH (_cairo_twin_charmap)) ? 0 : glyph];
     g = twin_glyph_draw(b);
+    w = twin_glyph_right(b);
 
     props = cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
 					   &twin_face_properties_key);
     cairo_set_tolerance (cr, 0.01);
     /* The weight is tuned to match DejaVu Sans' */
-    cairo_set_line_width (cr, props->weight * (5.5 / 64 / TWIN_WEIGHT_NORMAL));
+    lw = props->weight * (5.5 / 64 / TWIN_WEIGHT_NORMAL);
+    cairo_set_line_width (cr, lw);
 
     cairo_set_miter_limit (cr, M_SQRT2);
     cairo_set_line_join (cr, props->serif ?
@@ -312,6 +316,23 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 			    CAIRO_LINE_CAP_SQUARE :
 			    CAIRO_LINE_CAP_ROUND);
 
+
+    cairo_translate (cr, lw, 0); /* for margin */
+
+    cairo_save (cr);
+    if (props->monospace) {
+	int8_t monow = 24;
+	cairo_scale (cr, (FX(monow)+lw) / (FX(w)+lw), 1.);
+	w = monow;
+    }
+
+    cairo_translate (cr, lw * .5, 0); /* for pen width */
+
+    metrics->x_advance = FX(w) + lw;
+    metrics->x_advance +=  2 * lw /* XXX 2*x.margin */;
+    if (info.snap)
+	metrics->x_advance = SNAPI (SNAPX (metrics->x_advance));
+
     for (;;) {
 	switch (*g++) {
 	case 'M':
@@ -365,6 +386,7 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 	    cairo_close_path (cr);
 	    /* fall through */
 	case 'e':
+	    cairo_restore (cr);
 	    cairo_stroke (cr);
 	    break;
 	case 'X':
@@ -374,12 +396,6 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 	break;
     }
 
-    metrics->x_advance = FX(twin_glyph_right(b)) + cairo_get_line_width (cr);
-    metrics->x_advance +=  2*cairo_get_line_width (cr)/* XXX 2*x.margin */;
-    if (info.snap)
-	metrics->x_advance = SNAPI (SNAPX (metrics->x_advance));
-
-
     return CAIRO_STATUS_SUCCESS;
 }
 
commit 5def8c587b2b897bfebc6d77a6a3e13355cae2f2
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Dec 24 03:45:06 2008 -0500

    [twin] Fix dots

diff --git a/src/cairo-font-face-twin-data.c b/src/cairo-font-face-twin-data.c
index cc43870..91fb40c 100644
--- a/src/cairo-font-face-twin-data.c
+++ b/src/cairo-font-face-twin-data.c
@@ -19,17 +19,19 @@ const int8_t _cairo_twin_outlines[] = {
     -21, -15, 0, /* snap_y */
     'e',
 /* 0x21 '!'  offset 40 */
-    0, 4, 42, 0, 3, 3,
-    0, 2, 4, /* snap_x */
+    0, 0, 42, 0, 1, 3,
+    0, /* snap_x */
     -21, -15, 0, /* snap_y */
-    'm', 2, -42,
-    'l', 2, -14,
-    'm', 2, -4,
-    'c', 1, -4, 0, -3, 0, -2,
-    'c', 0, -1, 1, 0, 2, 0,
-    'c', 3, 0, 4, -1, 4, -2,
-    'c', 4, -3, 3, -4, 2, -4,
+    'm', 0, -42,
+    'l', 0, -14,
+    'm', 0, -3,
+    'l', 0, -4,
     'e',
+    'X', 'X', 'X', 'X', 'X', 'X',
+    'X', 'X', 'X', 'X', 'X', 'X',
+    'X', 'X', 'X', 'X', 'X', 'X',
+    'X', 'X', 'X', 'X', 'X', 'X',
+    'X', 'X', 'X',
 /* 0x22 '"'  offset 90 */
     0, 16, 42, -28, 2, 3,
     0, 16, /* snap_x */
@@ -338,10 +340,13 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 24, -42, 24, -34, 24, -32,
     'c', 24, -29, 24, -24, 12, -20,
     'l', 12, -14,
-    'm', 12, -4,
-    'c', 9, -4, 9, 0, 12, 0,
-    'c', 15, 0, 15, -4, 12, -4,
+    'm', 12, -3,
+    'l', 12, -4,
     'e',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X',
 /* 0x40 '@'  offset 1288 */
     0, 42, 42, 0, 1, 6,
     30, /* snap_x */
@@ -780,26 +785,33 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 22, 0,
     'e',
 /* 0x69 'i'  offset 2790 */
-    0, 4, 44, 0, 3, 3,
-    0, 2, 4, /* snap_x */
+    0, 0, 44, 0, 1, 3,
+    0, /* snap_x */
     -21, -15, 0, /* snap_y */
     'm', 0, -42,
-    'c', 0, -39, 4, -39, 4, -42,
-    'c', 4, -45, 0, -45, 0, -42,
-    'm', 2, -28,
-    'l', 2, 0,
+    'l', 0, -41,
+    'm', 0, -28,
+    'l', 0, 0,
     'e',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X',
+    'X', 'X',
 /* 0x6a 'j'  offset 2826 */
     -8, 4, 44, 14, 3, 4,
     0, 2, 4, /* snap_x */
     -21, -15, 0, 14, /* snap_y */
-    'm', 0, -42,
-    'c', 0, -39, 4, -39, 4, -42,
-    'c', 4, -45, 0, -45, 0, -42,
+    'm', 2, -42,
+    'l', 2, -41,
     'm', 2, -28,
     'l', 2, 6,
     'c', 2, 13, -1, 14, -8, 14,
     'e',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X', 'X',
+    'X', 'X',
 /* 0x6b 'k'  offset 2870 */
     0, 22, 42, 0, 2, 3,
     0, 22, /* snap_x */


More information about the cairo-commit mailing list