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

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Dec 25 20:29:24 PST 2008


 src/cairo-font-face-twin-data.c |  206 ++++++++++++++++++++++------------------
 src/cairo-font-face-twin.c      |   94 +++++++-----------
 src/cairo-pattern.c             |    2 
 3 files changed, 157 insertions(+), 145 deletions(-)

New commits:
commit 730ed68ec1ac10dcb9c7c69759f72fcaa3ea82e5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Dec 25 23:29:02 2008 -0500

    [pattern] Fix comment typo

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 3a4a9c8..9f367b5 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1626,7 +1626,7 @@ _cairo_pattern_reset_solid_surface_cache (void)
 	solid_surface_cache.cache[solid_surface_cache.size].surface = NULL;
 
 	/* release the lock to avoid the possibility of a recursive
-	 * deadlock when the scaled font destroy closure gets called */
+	 * deadlock when the surface destroy closure gets called */
 	CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
 	cairo_surface_destroy (surface);
 	CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
commit a5f4a97aa4122d8c4b8f31053d421a52c356e270
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Dec 25 02:48:26 2008 -0500

    [twin] Don't hint pen if hint-style is SLIGHT

diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index 1819135..b61e79e 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -317,7 +317,7 @@ _twin_compute_snap (cairo_t             *cr,
     const signed char	*snap;
     double x, y;
 
-    info->snap = scaled_font->options.hint_style != CAIRO_HINT_STYLE_NONE;
+    info->snap = scaled_font->options.hint_style > CAIRO_HINT_STYLE_NONE;
     if (!info->snap)
 	return;
 
@@ -361,7 +361,7 @@ _twin_compute_pen (cairo_t             *cr,
     double scale, inv;
     cairo_bool_t hint;
 
-    hint = scaled_font->options.hint_style != CAIRO_HINT_STYLE_NONE;
+    hint = scaled_font->options.hint_style > CAIRO_HINT_STYLE_SLIGHT;
     if (!hint) {
 	*penx = *peny = width;
 	return;
commit 0c7eaf6e0a2c2f0db634f8120fcbc03f7e8fd751
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Dec 25 02:44:19 2008 -0500

    [twin] Improve glyph hints

diff --git a/src/cairo-font-face-twin-data.c b/src/cairo-font-face-twin-data.c
index 16d1e2c..ff09cb2 100644
--- a/src/cairo-font-face-twin-data.c
+++ b/src/cairo-font-face-twin-data.c
@@ -4,28 +4,31 @@
 
 const int8_t _cairo_twin_outlines[] = {
 /* 0x0 '\0'  offset 0 */
-    0, 24, 42, 0, 2, 4,
+    0, 24, 42, 0, 2, 2,
     0, 24, /* snap_x */
-    -42, -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 24, -42,
     'l', 24, 0,
     'l', 0, 0,
     'e',
+    'X', 'X',
 /* 0x20 ' '  offset 28 */
-    0, 4, 0, 0, 2, 3,
-    -128, 0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    0, 4, 0, 0, 0, 0,
+    /* snap_x */
+    /* snap_y */
     'e',
+    'X', 'X', 'X',
+    'X', 'X',
 /* 0x21 '!'  offset 40 */
     0, 0, 42, 0, 1, 3,
     0, /* snap_x */
-    -21, -15, -4, /* snap_y */
+    -42, -14, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, -14,
-    'm', 0, -4,
-    'l', 0, -4,
+    'm', 0, 0,
+    'l', 0, 0,
     'e',
     'X', 'X', 'X', 'X', 'X', 'X',
     'X', 'X', 'X', 'X', 'X', 'X',
@@ -33,14 +36,15 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X', 'X', 'X', 'X',
     'X', 'X', 'X',
 /* 0x22 '"'  offset 90 */
-    0, 16, 42, -28, 2, 3,
+    0, 16, 42, -28, 2, 2,
     0, 16, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -28, /* snap_y */
     'm', 0, -42,
     'l', 0, -28,
     'm', 16, -42,
     'l', 16, -28,
     'e',
+    'X',
 /* 0x23 '#'  offset 114 */
     0, 30, 50, 14, 2, 5,
     0, 30, /* snap_x */
@@ -104,27 +108,30 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 39, 0, 40, -1, 40, -4,
     'e',
 /* 0x27 '''  offset 390 */
-    0, 4, 42, -30, 2, 3,
+    0, 4, 42, -30, 2, 2,
     0, 4, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -28, /* snap_y */
     'm', 2, -38,
     'c', -1, -38, -1, -42, 2, -42,
     'c', 6, -42, 5, -33, 0, -30,
     'e',
+    'X',
 /* 0x28 '('  offset 419 */
-    0, 14, 50, 14, 2, 3,
+    0, 14, 50, 14, 2, 2,
     0, 14, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -50, 14, /* snap_y */
     'm', 14, -50,
     'c', -5, -32, -5, -5, 14, 14,
     'e',
+    'X',
 /* 0x29 ')'  offset 441 */
-    0, 14, 50, 14, 2, 3,
+    0, 14, 50, 14, 2, 2,
     0, 14, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -15, 14, /* snap_y */
     'm', 0, -50,
     'c', 19, -34, 19, -2, 0, 14,
     'e',
+    'X',
 /* 0x2a '*'  offset 463 */
     0, 20, 30, -6, 3, 3,
     0, 10, 20, /* snap_x */
@@ -189,7 +196,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x31 '1'  offset 666 */
     0, 28, 42, 0, 2, 3,
     0, 17, 28 /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -34, 0, /* snap_y */
     'm', 7, -34,
     'c', 11, -35, 15, -38, 17, -42,
     'l', 17, 0,
@@ -217,15 +224,16 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 8, 0, 3, -1, 0, -8,
     'e',
 /* 0x34 '4'  offset 780 */
-    0, 28, 42, 0, 3, 4,
+    0, 28, 42, 0, 3, 3,
     0, 20, 30, /* snap_x */
-    -21, -15, -14, 0, /* snap_y */
+    -42, -14, 0, /* snap_y */
     'm', 20, 0,
     'l', 20, -42,
     'l', 0, -14,
     'l', 30, -14,
     'e',
     'X', 'X', 'X',
+    'X',
 /* 0x35 '5'  offset 809 */
     0, 28, 42, 0, 2, 5,
     0, 28, /* snap_x */
@@ -309,24 +317,25 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x3c '<'  offset 1162 */
     0, 32, 36, 0, 2, 3,
     0, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -36, -18, 0, /* snap_y */
     'm', 32, -36,
     'l', 0, -18,
     'l', 32, 0,
     'e',
 /* 0x3d '='  offset 1183 */
-    0, 36, 24, -12, 2, 5,
+    0, 36, 24, -12, 2, 2,
     0, 36, /* snap_x */
-    -24, -21, -15, -12, 0, /* snap_y */
+    -24, -15, /* snap_y */
     'm', 0, -24,
     'l', 36, -24,
     'm', 0, -12,
     'l', 36, -12,
     'e',
+    'X', 'X', 'X',
 /* 0x3e '>'  offset 1209 */
     0, 32, 36, 0, 2, 3,
     0, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -36, -18, 0, /* snap_y */
     'm', 0, -36,
     'l', 32, -18,
     'l', 0, 0,
@@ -334,14 +343,14 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x3f '?'  offset 1230 */
     0, 24, 42, 0, 3, 4,
     0, 12, 24, /* snap_x */
-    -42, -21, -15, -4, /* snap_y */
+    -42, -21, -15, 0, /* snap_y */
     'm', 0, -32,
     'c', 0, -34, 0, -42, 12, -42,
     'c', 24, -42, 24, -34, 24, -32,
     'c', 24, -29, 24, -24, 12, -20,
     'l', 12, -14,
-    'm', 12, -4,
-    'l', 12, -4,
+    'm', 12, 0,
+    'l', 12, 0,
     'e',
     'X', 'X', 'X',
     'X', 'X', 'X',
@@ -364,9 +373,9 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 30, 0, 34, -3, 36, -6,
     'e',
 /* 0x41 'A'  offset 1375 */
-    0, 32, 42, 0, 2, 4,
+    0, 32, 42, 0, 2, 3,
     0, 32, /* snap_x */
-    -21, -15, -14, 0, /* snap_y */
+    -42, -14, 0, /* snap_y */
     'm', 0, 0,
     'l', 16, -42,
     'l', 32, 0,
@@ -374,10 +383,11 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 26, -14,
     'e',
     'X', 'X', 'X',
+    'X',
 /* 0x42 'B'  offset 1406 */
-    0, 28, 42, 0, 2, 5,
+    0, 28, 42, 0, 2, 3,
     0, 28, /* snap_x */
-    -42, -22, -21, -15, 0, /* snap_y */
+    -42, -22, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 18, -42,
@@ -388,6 +398,7 @@ const int8_t _cairo_twin_outlines[] = {
     'E',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X', 'X',
 /* 0x43 'C'  offset 1455 */
     0, 30, 42, 0, 2, 4,
     0, 30, /* snap_x */
@@ -399,9 +410,9 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 21, 0, 26, 0, 30, -10,
     'e',
 /* 0x44 'D'  offset 1499 */
-    0, 28, 42, 0, 2, 4,
+    0, 28, 42, 0, 2, 2,
     0, 28, /* snap_x */
-    -42, -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 14, -42,
@@ -409,10 +420,11 @@ const int8_t _cairo_twin_outlines[] = {
     'E',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X', 'X',
 /* 0x45 'E'  offset 1534 */
-    0, 26, 42, 0, 2, 5,
+    0, 26, 42, 0, 2, 3,
     0, 26, /* snap_x */
-    -42, -22, -21, -15, 0, /* snap_y */
+    -42, -22, 0, /* snap_y */
     'm', 26, -42,
     'l', 0, -42,
     'l', 0, 0,
@@ -422,10 +434,11 @@ const int8_t _cairo_twin_outlines[] = {
     'e',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X', 'X',
 /* 0x46 'F'  offset 1572 */
-    0, 26, 42, 0, 2, 5,
+    0, 26, 42, 0, 2, 3,
     0, 26, /* snap_x */
-    -42, -22, -21, -15, 0, /* snap_y */
+    -42, -22, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 26, -42,
@@ -433,6 +446,7 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 16, -22,
     'e',
     'X', 'X', 'X',
+    'X', 'X',
 /* 0x47 'G'  offset 1604 */
     0, 30, 42, 0, 2, 5,
     0, 30, /* snap_x */
@@ -446,9 +460,9 @@ const int8_t _cairo_twin_outlines[] = {
     'e',
     'X', 'X', 'X',
 /* 0x48 'H'  offset 1655 */
-    0, 28, 42, 0, 2, 4,
+    0, 28, 42, 0, 2, 3,
     0, 28, /* snap_x */
-    -22, -21, -15, 0, /* snap_y */
+    -42, -22, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'm', 28, -42,
@@ -456,17 +470,19 @@ const int8_t _cairo_twin_outlines[] = {
     'm', 0, -22,
     'l', 28, -22,
     'e',
+    'X',
 /* 0x49 'I'  offset 1686 */
-    0, 0, 42, 0, 1, 3,
+    0, 0, 42, 0, 1, 2,
     0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'e',
+    'X',
 /* 0x4a 'J'  offset 1703 */
     0, 20, 42, 0, 2, 3,
     0, 20, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -15, 0, /* snap_y */
     'm', 20, -42,
     'l', 20, -10,
     'c', 20, 3, 0, 3, 0, -10,
@@ -475,7 +491,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x4b 'K'  offset 1731 */
     0, 28, 42, 0, 2, 3,
     0, 28, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -15, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'm', 28, -42,
@@ -484,18 +500,19 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 28, 0,
     'e',
 /* 0x4c 'L'  offset 1761 */
-    0, 24, 42, 0, 2, 3,
+    0, 24, 42, 0, 2, 2,
     0, 24, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'l', 24, 0,
     'e',
     'X', 'X', 'X',
+    'X',
 /* 0x4d 'M'  offset 1785 */
-    0, 32, 42, 0, 2, 3,
+    0, 32, 42, 0, 2, 2,
     0, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 16, 0,
@@ -505,10 +522,11 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X',
 /* 0x4e 'N'  offset 1821 */
-    0, 28, 42, 0, 2, 3,
+    0, 28, 42, 0, 2, 2,
     0, 28, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, 0,
     'l', 0, -42,
     'l', 28, 0,
@@ -516,6 +534,7 @@ const int8_t _cairo_twin_outlines[] = {
     'e',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X',
 /* 0x4f 'O'  offset 1851 */
     0, 32, 42, 0, 2, 4,
     0, 32, /* snap_x */
@@ -583,27 +602,29 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 28, -42,
     'e',
 /* 0x55 'U'  offset 2100 */
-    0, 28, 42, 0, 2, 3,
+    0, 28, 42, 0, 2, 2,
     0, 28, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, -12,
     'c', 0, 4, 28, 4, 28, -12,
     'l', 28, -42,
     'e',
+    'X',
 /* 0x56 'V'  offset 2128 */
-    0, 32, 42, 0, 2, 3,
+    0, 32, 42, 0, 2, 2,
     0, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 16, 0,
     'l', 32, -42,
     'e',
     'X', 'X', 'X',
+    'X',
 /* 0x57 'W'  offset 2152 */
-    0, 40, 42, 0, 2, 3,
+    0, 40, 42, 0, 2, 2,
     0, 40, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 10, 0,
     'l', 20, -42,
@@ -613,19 +634,21 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X',
     'X', 'X', 'X',
     'X', 'X', 'X',
+    'X',
 /* 0x58 'X'  offset 2188 */
-    0, 28, 42, 0, 2, 3,
+    0, 28, 42, 0, 2, 2,
     0, 28, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 28, 0,
     'm', 28, -42,
     'l', 0, 0,
     'e',
+    'X',
 /* 0x59 'Y'  offset 2212 */
     0, 32, 42, 0, 3, 3,
     0, 16, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -21, 0, /* snap_y */
     'm', 0, -42,
     'l', 16, -22,
     'l', 16, 0,
@@ -678,21 +701,23 @@ const int8_t _cairo_twin_outlines[] = {
     'e',
     'X', 'X', 'X',
 /* 0x5f '_'  offset 2363 */
-    0, 36, 0, 0, 2, 3,
+    0, 36, 0, 0, 2, 1,
     0, 36, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    0, /* snap_y */
     'm', 0, 0,
     'l', 36, 0,
     'e',
+    'X', 'X',
 /* 0x60 '`'  offset 2381 */
-    0, 4, 42, -30, 2, 3,
+    0, 4, 42, -30, 2, 2,
     0, 4, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 4, -42,
     'c', 2, -40, 0, -39, 0, -32,
     'c', 0, -31, 1, -30, 2, -30,
     'c', 5, -30, 5, -34, 2, -34,
     'e',
+    'X',
 /* 0x61 'a'  offset 2417 */
     0, 24, 28, 0, 2, 4,
     0, 24, /* snap_x */
@@ -708,7 +733,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x62 'b'  offset 2467 */
     0, 24, 42, 0, 2, 4,
     0, 24, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -42, -28, -15, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'm', 0, -22,
@@ -730,7 +755,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x64 'd'  offset 2561 */
     0, 24, 42, 0, 2, 4,
     0, 24, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -42, -28, -15, 0, /* snap_y */
     'm', 24, -42,
     'l', 24, 0,
     'm', 24, -22,
@@ -777,7 +802,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x68 'h'  offset 2758 */
     0, 22, 42, 0, 2, 4,
     0, 22, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -42, -28, -15, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'm', 0, -20,
@@ -785,9 +810,9 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 22, 0,
     'e',
 /* 0x69 'i'  offset 2790 */
-    0, 0, 44, 0, 1, 4,
+    0, 0, 44, 0, 1, 3,
     0, /* snap_x */
-    -42, -21, -15, 0, /* snap_y */
+    -42, -28, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, -42,
     'm', 0, -28,
@@ -797,10 +822,10 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X',
     'X', 'X', 'X',
     'X', 'X',
-    'X',
+    'X', 'X',
 /* 0x6a 'j'  offset 2826 */
     -8, 4, 44, 14, 3, 5,
-    0, 2, 4, /* snap_x */
+    -8, 2, 4, /* snap_x */
     -42, -21, -15, 0, 14, /* snap_y */
     'm', 2, -42,
     'l', 2, -42,
@@ -815,7 +840,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x6b 'k'  offset 2870 */
     0, 22, 42, 0, 2, 3,
     0, 22, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -28, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'm', 20, -28,
@@ -824,16 +849,17 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 22, 0,
     'e',
 /* 0x6c 'l'  offset 2900 */
-    0, 0, 42, 0, 1, 3,
+    0, 0, 42, 0, 1, 2,
     0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, 0, /* snap_y */
     'm', 0, -42,
     'l', 0, 0,
     'e',
+    'X',
 /* 0x6d 'm'  offset 2917 */
-    0, 44, 28, 0, 3, 4,
+    0, 44, 28, 0, 3, 3,
     0, 22, 44, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -28, -21, 0, /* snap_y */
     'm', 0, -28,
     'l', 0, 0,
     'm', 0, -20,
@@ -843,16 +869,18 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 27, -29, 44, -33, 44, -20,
     'l', 44, 0,
     'e',
+    'X',
 /* 0x6e 'n'  offset 2963 */
-    0, 22, 28, 0, 2, 4,
+    0, 22, 28, 0, 2, 3,
     0, 22, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -28, -21, 0, /* snap_y */
     'm', 0, -28,
     'l', 0, 0,
     'm', 0, -20,
     'c', 4, -28, 22, -34, 22, -20,
     'l', 22, 0,
     'e',
+    'X',
 /* 0x6f 'o'  offset 2995 */
     0, 26, 28, 0, 2, 4,
     0, 26, /* snap_x */
@@ -866,7 +894,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x70 'p'  offset 3039 */
     0, 24, 28, 14, 2, 4,
     0, 24, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -28, -21, 0, 14, /* snap_y */
     'm', 0, -28,
     'l', 0, 14,
     'm', 0, -22,
@@ -878,7 +906,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x71 'q'  offset 3089 */
     0, 24, 28, 14, 2, 4,
     0, 24, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -28, -21, 0, 14, /* snap_y */
     'm', 24, -28,
     'l', 24, 14,
     'm', 24, -22,
@@ -910,7 +938,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x74 't'  offset 3219 */
     0, 16, 42, 0, 3, 4,
     0, 6, 16, /* snap_x */
-    -28, -21, -15, 0, /* snap_y */
+    -42, -28, -21, 0, /* snap_y */
     'm', 6, -42,
     'l', 6, -8,
     'c', 6, -2, 8, 0, 16, 0,
@@ -920,7 +948,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x75 'u'  offset 3252 */
     0, 22, 28, 0, 2, 3,
     0, 22, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -28, -15, 0, /* snap_y */
     'm', 0, -28,
     'l', 0, -8,
     'c', 0, 6, 18, 0, 22, -8,
@@ -930,7 +958,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x76 'v'  offset 3283 */
     0, 24, 28, 0, 2, 3,
     0, 24, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -28, -15, 0, /* snap_y */
     'm', 0, -28,
     'l', 12, 0,
     'l', 24, -28,
@@ -939,7 +967,7 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x77 'w'  offset 3307 */
     0, 32, 28, 0, 2, 3,
     0, 32, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -28, -15, 0, /* snap_y */
     'm', 0, -28,
     'l', 8, 0,
     'l', 16, -28,
@@ -950,18 +978,19 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X',
     'X', 'X', 'X',
 /* 0x78 'x'  offset 3343 */
-    0, 22, 28, 0, 2, 3,
+    0, 22, 28, 0, 2, 2,
     0, 22, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -28, 0, /* snap_y */
     'm', 0, -28,
     'l', 22, 0,
     'm', 22, -28,
     'l', 0, 0,
     'e',
+    'X',
 /* 0x79 'y'  offset 3367 */
     -2, 24, 28, 14, 2, 4,
     0, 24, /* snap_x */
-    -21, -15, 0, 14, /* snap_y */
+    -28, -15, 0, 14, /* snap_y */
     'm', 0, -28,
     'l', 12, 0,
     'm', 24, -28,
@@ -992,12 +1021,13 @@ const int8_t _cairo_twin_outlines[] = {
     'c', 6, -2, 10, 0, 16, 0,
     'e',
 /* 0x7c '|'  offset 3474 */
-    0, 0, 50, 14, 1, 3,
+    0, 0, 50, 14, 1, 2,
     0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -50, 14, /* snap_y */
     'm', 0, -50,
     'l', 0, 14,
     'e',
+    'X',
 /* 0x7d '}'  offset 3491 */
     0, 16, 44, 0, 3, 5,
     0, 10, 16, /* snap_x */
commit e6205ea5a38c9de4c08b313a1beb70d4a38b0676
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Dec 25 02:10:16 2008 -0500

    [twin] Improve hinting

diff --git a/src/cairo-font-face-twin.c b/src/cairo-font-face-twin.c
index 60ed81e..1819135 100644
--- a/src/cairo-font-face-twin.c
+++ b/src/cairo-font-face-twin.c
@@ -223,8 +223,7 @@ FREE_PROPS:
 #define twin_glyph_snap_y(g)    (twin_glyph_snap_x(g) + twin_glyph_n_snap_x(g))
 #define twin_glyph_draw(g)      (twin_glyph_snap_y(g) + twin_glyph_n_snap_y(g))
 
-#define FX(g)		((g) / 72.)
-#define FY(g)		((g) / 72.)
+#define F(g)		((g) / 72.)
 
 
 static cairo_status_t
@@ -232,7 +231,7 @@ twin_scaled_font_init (cairo_scaled_font_t  *scaled_font,
 		       cairo_t              *cr,
 		       cairo_font_extents_t *metrics)
 {
-  metrics->ascent  = FY (54);
+  metrics->ascent  = F (54);
   metrics->descent = 1 - metrics->ascent;
   return CAIRO_STATUS_SUCCESS;
 }
@@ -255,8 +254,8 @@ twin_scaled_font_unicode_to_glyph (cairo_scaled_font_t *scaled_font,
     return CAIRO_STATUS_SUCCESS;
 }
 
-#define SNAPX(p)	_twin_snap (p, info.snap_x, info.snapped_x, info.n_snap_x)
-#define SNAPY(p)	_twin_snap (p, info.snap_y, info.snapped_y, info.n_snap_y)
+#define SNAPX(p)	_twin_snap (p, info.snap, info.snap_x, info.snapped_x, info.n_snap_x)
+#define SNAPY(p)	_twin_snap (p, info.snap, info.snap_y, info.snapped_y, info.n_snap_y)
 
 #define TWIN_GLYPH_MAX_SNAP_X 4
 #define TWIN_GLYPH_MAX_SNAP_Y 7
@@ -265,28 +264,33 @@ twin_scaled_font_unicode_to_glyph (cairo_scaled_font_t *scaled_font,
 #define SNAPYI(p)	(round ((p) * info->y_scale) * info->y_scale_inv)
 
 static double
-_twin_snap (double v, double *snap, double *snapped, int n)
+_twin_snap (int8_t v, cairo_bool_t do_snap, int8_t *snap, double *snapped, int n)
 {
     int	s;
 
+    if (!do_snap)
+	return F(v);
+
+    if (snap[0] == v)
+	return snapped[0];
+
     for (s = 0; s < n - 1; s++)
     {
-	if (snap[s] == v)
-	    return snapped[s];
+	if (snap[s+1] == v)
+	    return snapped[s+1];
 
 	if (snap[s] <= v && v <= snap[s+1])
 	{
-	    double before = snap[s];
-	    double after = snap[s+1];
-	    double dist = after - before;
+	    int before = snap[s];
+	    int after = snap[s+1];
+	    int dist = after - before;
 	    double snap_before = snapped[s];
 	    double snap_after = snapped[s+1];
 	    double dist_before = v - before;
-	    v = snap_before + (snap_after - snap_before) * dist_before / dist;
-	    break;
+	    return snap_before + (snap_after - snap_before) * dist_before / dist;
 	}
     }
-    return v;
+    return F(v);
 }
 
 typedef struct {
@@ -296,10 +300,10 @@ typedef struct {
     double y_scale, y_scale_inv, y_off;
 
     int n_snap_x;
-    double snap_x[TWIN_GLYPH_MAX_SNAP_X];
+    int8_t snap_x[TWIN_GLYPH_MAX_SNAP_X];
     double snapped_x[TWIN_GLYPH_MAX_SNAP_X];
     int n_snap_y;
-    double snap_y[TWIN_GLYPH_MAX_SNAP_Y];
+    int8_t snap_y[TWIN_GLYPH_MAX_SNAP_Y];
     double snapped_y[TWIN_GLYPH_MAX_SNAP_Y];
 } twin_snap_info_t;
 
@@ -333,8 +337,8 @@ _twin_compute_snap (cairo_t             *cr,
     info->n_snap_x = n;
     assert (n <= TWIN_GLYPH_MAX_SNAP_X);
     for (s = 0; s < n; s++) {
-	info->snap_x[s] = FX(snap[s]);
-	info->snapped_x[s] = SNAPXI (info->snap_x[s]);
+	info->snap_x[s] = snap[s];
+	info->snapped_x[s] = SNAPXI (F (snap[s]));
     }
 
     snap = twin_glyph_snap_y (b);
@@ -342,8 +346,8 @@ _twin_compute_snap (cairo_t             *cr,
     info->n_snap_y = n;
     assert (n <= TWIN_GLYPH_MAX_SNAP_Y);
     for (s = 0; s < n; s++) {
-	info->snap_y[s] = FY(snap[s]);
-	info->snapped_y[s] = SNAPYI (info->snap_y[s]);
+	info->snap_y[s] = snap[s];
+	info->snapped_y[s] = SNAPYI (F (snap[s]));
     }
 }
 
@@ -435,11 +439,11 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 	_cairo_twin_charmap[unlikely (glyph >= ARRAY_LENGTH (_cairo_twin_charmap)) ? 0 : glyph];
     g = twin_glyph_draw(b);
     w = twin_glyph_right(b);
-    gw = FX(w);
+    gw = F(w);
 
     /* monospace */
     if (props->monospace) {
-	double monow = FX(24);
+	double monow = F(24);
 	cairo_scale (cr, (monow+penx) / (gw+penx), 1);
 	gw = monow;
     }
@@ -449,9 +453,6 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
     /* advance width */
     metrics->x_advance = gw + penx * 3; /* pen width + margin */
     metrics->x_advance *= stretch;
-    if (info.snap)
-	metrics->x_advance = SNAPX (metrics->x_advance);
-
 
     /* glyph shape */
     for (;;) {
@@ -460,47 +461,28 @@ twin_scaled_font_render_glyph (cairo_scaled_font_t  *scaled_font,
 	    cairo_close_path (cr);
 	    /* fall through */
 	case 'm':
-	    x1 = FX(*g++);
-	    y1 = FY(*g++);
-	    if (info.snap)
-	    {
-		x1 = SNAPX (x1);
-		y1 = SNAPY (y1);
-	    }
+	    x1 = SNAPX(*g++);
+	    y1 = SNAPY(*g++);
 	    cairo_move_to (cr, x1, y1);
 	    continue;
 	case 'L':
 	    cairo_close_path (cr);
 	    /* fall through */
 	case 'l':
-	    x1 = FX(*g++);
-	    y1 = FY(*g++);
-	    if (info.snap)
-	    {
-		x1 = SNAPX (x1);
-		y1 = SNAPY (y1);
-	    }
+	    x1 = SNAPX(*g++);
+	    y1 = SNAPY(*g++);
 	    cairo_line_to (cr, x1, y1);
 	    continue;
 	case 'C':
 	    cairo_close_path (cr);
 	    /* fall through */
 	case 'c':
-	    x1 = FX(*g++);
-	    y1 = FY(*g++);
-	    x2 = FX(*g++);
-	    y2 = FY(*g++);
-	    x3 = FX(*g++);
-	    y3 = FY(*g++);
-	    if (info.snap)
-	    {
-		x1 = SNAPX (x1);
-		y1 = SNAPY (y1);
-		x2 = SNAPX (x2);
-		y2 = SNAPY (y2);
-		x3 = SNAPX (x3);
-		y3 = SNAPY (y3);
-	    }
+	    x1 = SNAPX(*g++);
+	    y1 = SNAPY(*g++);
+	    x2 = SNAPX(*g++);
+	    y2 = SNAPY(*g++);
+	    x3 = SNAPX(*g++);
+	    y3 = SNAPY(*g++);
 	    cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
 	    continue;
 	case 'E':
commit da8658b67510daaefd542b80e6a997bbdfd82d44
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Dec 25 01:35:36 2008 -0500

    [twin] Hint dots

diff --git a/src/cairo-font-face-twin-data.c b/src/cairo-font-face-twin-data.c
index 91fb40c..16d1e2c 100644
--- a/src/cairo-font-face-twin-data.c
+++ b/src/cairo-font-face-twin-data.c
@@ -21,10 +21,10 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x21 '!'  offset 40 */
     0, 0, 42, 0, 1, 3,
     0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -21, -15, -4, /* snap_y */
     'm', 0, -42,
     'l', 0, -14,
-    'm', 0, -3,
+    'm', 0, -4,
     'l', 0, -4,
     'e',
     'X', 'X', 'X', 'X', 'X', 'X',
@@ -334,13 +334,13 @@ const int8_t _cairo_twin_outlines[] = {
 /* 0x3f '?'  offset 1230 */
     0, 24, 42, 0, 3, 4,
     0, 12, 24, /* snap_x */
-    -42, -21, -15, 0, /* snap_y */
+    -42, -21, -15, -4, /* snap_y */
     'm', 0, -32,
     'c', 0, -34, 0, -42, 12, -42,
     'c', 24, -42, 24, -34, 24, -32,
     'c', 24, -29, 24, -24, 12, -20,
     'l', 12, -14,
-    'm', 12, -3,
+    'm', 12, -4,
     'l', 12, -4,
     'e',
     'X', 'X', 'X',
@@ -785,11 +785,11 @@ const int8_t _cairo_twin_outlines[] = {
     'l', 22, 0,
     'e',
 /* 0x69 'i'  offset 2790 */
-    0, 0, 44, 0, 1, 3,
+    0, 0, 44, 0, 1, 4,
     0, /* snap_x */
-    -21, -15, 0, /* snap_y */
+    -42, -21, -15, 0, /* snap_y */
     'm', 0, -42,
-    'l', 0, -41,
+    'l', 0, -42,
     'm', 0, -28,
     'l', 0, 0,
     'e',
@@ -797,13 +797,13 @@ const int8_t _cairo_twin_outlines[] = {
     'X', 'X', 'X',
     'X', 'X', 'X',
     'X', 'X',
-    'X', 'X',
+    'X',
 /* 0x6a 'j'  offset 2826 */
-    -8, 4, 44, 14, 3, 4,
+    -8, 4, 44, 14, 3, 5,
     0, 2, 4, /* snap_x */
-    -21, -15, 0, 14, /* snap_y */
+    -42, -21, -15, 0, 14, /* snap_y */
     'm', 2, -42,
-    'l', 2, -41,
+    'l', 2, -42,
     'm', 2, -28,
     'l', 2, 6,
     'c', 2, 13, -1, 14, -8, 14,
@@ -811,7 +811,7 @@ const int8_t _cairo_twin_outlines[] = {
     'X', '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