Skip to content

Commit

Permalink
[twin-font] Clean up font data by joining lines and closing paths
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Behdad Esfahbod committed Sep 25, 2008
1 parent d5a9983 commit f8542dc
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 81 deletions.
154 changes: 77 additions & 77 deletions src/cairo-font-face-twin-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,22 @@ const int8_t _cairo_twin_outlines[] = {
0, 36, 42, 0, 4, 7,
0, 14, 22, 36, /* snap_x */
-42, -38, -28, -21, -15, -14, 0, /* snap_y */
'm', 36, -42,
'l', 0, 0,
'm', 10, -42,
'c', 12, -41, 14, -40, 14, -36,
'c', 14, -30, 11, -28, 6, -28,
'c', 2, -28, 0, -30, 0, -34,
'c', 0, -39, 3, -42, 8, -42,
'l', 10, -42,
'c', 18, -37, 28, -37, 36, -42,
'l', 0, 0,
'm', 28, -14,
'c', 24, -14, 22, -11, 22, -6,
'c', 22, -2, 24, 0, 28, 0,
'c', 33, 0, 36, -2, 36, -8,
'c', 36, -12, 34, -14, 30, -14,
'l', 28, -14,
'e',
'X', 'X', 'X',
/* 0x26 '&' offset 323 */
0, 40, 42, 0, 4, 4,
0, 10, 22, 40, /* snap_x */
Expand Down Expand Up @@ -183,7 +183,7 @@ const int8_t _cairo_twin_outlines[] = {
'c', 0, 0, 9, 0, 14, 0,
'c', 19, 0, 28, 0, 28, -21,
'c', 28, -42, 19, -42, 14, -42,
'e',
'E',
/* 0x31 '1' offset 666 */
0, 28, 42, 0, 2, 3,
0, 17, 28 /* snap_x */
Expand Down Expand Up @@ -218,12 +218,12 @@ const int8_t _cairo_twin_outlines[] = {
0, 28, 42, 0, 3, 4,
0, 20, 30, /* snap_x */
-21, -15, -14, 0, /* snap_y */
'm', 20, -42,
'm', 20, 0,
'l', 20, -42,
'l', 0, -14,
'l', 30, -14,
'm', 20, -42,
'l', 20, 0,
'e',
'X', 'X', 'X',
/* 0x35 '5' offset 809 */
0, 28, 42, 0, 2, 5,
0, 28, /* snap_x */
Expand Down Expand Up @@ -252,11 +252,11 @@ const int8_t _cairo_twin_outlines[] = {
0, 28, 42, 0, 2, 4,
0, 28, /* snap_x */
-42, -21, -15, 0, /* snap_y */
'm', 28, -42,
'l', 8, 0,
'm', 0, -42,
'l', 28, -42,
'l', 8, 0,
'e',
'X', 'X', 'X',
/* 0x38 '8' offset 944 */
0, 28, 42, 0, 4, 4,
0, 2, 26, 28, /* snap_x */
Expand All @@ -268,7 +268,7 @@ const int8_t _cairo_twin_outlines[] = {
'c', 10, 0, 0, 0, 0, -11,
'c', 0, -32, 26, -18, 26, -34,
'c', 26, -40, 23, -42, 14, -42,
'e',
'E',
/* 0x39 '9' offset 1004 */
0, 28, 42, 0, 2, 5,
0, 26, /* snap_x */
Expand Down Expand Up @@ -362,27 +362,27 @@ const int8_t _cairo_twin_outlines[] = {
0, 32, 42, 0, 2, 4,
0, 32, /* snap_x */
-21, -15, -14, 0, /* snap_y */
'm', 16, -42,
'l', 0, 0,
'm', 16, -42,
'm', 0, 0,
'l', 16, -42,
'l', 32, 0,
'm', 6, -14,
'l', 26, -14,
'e',
'X', 'X', 'X',
/* 0x42 'B' offset 1406 */
0, 28, 42, 0, 2, 5,
0, 28, /* snap_x */
-42, -22, -21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'm', 0, 0,
'l', 0, -42,
'l', 18, -42,
'c', 32, -42, 32, -22, 18, -22,
'm', 0, -22,
'l', 0, -22,
'l', 18, -22,
'c', 32, -22, 32, 0, 18, 0,
'l', 0, 0,
'e',
'E',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x43 'C' offset 1455 */
0, 30, 42, 0, 2, 4,
0, 30, /* snap_x */
Expand All @@ -397,37 +397,37 @@ const int8_t _cairo_twin_outlines[] = {
0, 28, 42, 0, 2, 4,
0, 28, /* snap_x */
-42, -21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'm', 0, 0,
'l', 0, -42,
'l', 14, -42,
'c', 33, -42, 33, 0, 14, 0,
'l', 0, 0,
'e',
'E',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x45 'E' offset 1534 */
0, 26, 42, 0, 2, 5,
0, 26, /* snap_x */
-42, -22, -21, -15, 0, /* snap_y */
'm', 0, -42,
'm', 26, -42,
'l', 0, -42,
'l', 0, 0,
'm', 0, -42,
'l', 26, -42,
'l', 26, 0,
'm', 0, -22,
'l', 16, -22,
'm', 0, 0,
'l', 26, 0,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x46 'F' offset 1572 */
0, 26, 42, 0, 2, 5,
0, 26, /* snap_x */
-42, -22, -21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'm', 0, 0,
'l', 0, -42,
'l', 26, -42,
'm', 0, -22,
'l', 16, -22,
'e',
'X', 'X', 'X',
/* 0x47 'G' offset 1604 */
0, 30, 42, 0, 2, 5,
0, 30, /* snap_x */
Expand All @@ -437,9 +437,9 @@ const int8_t _cairo_twin_outlines[] = {
'c', 2, -42, 0, -29, 0, -21,
'c', 0, -13, 2, 0, 16, 0,
'c', 28, 0, 30, -7, 30, -16,
'm', 20, -16,
'l', 30, -16,
'l', 20, -16,
'e',
'X', 'X', 'X',
/* 0x48 'H' offset 1655 */
0, 28, 42, 0, 2, 4,
0, 28, /* snap_x */
Expand Down Expand Up @@ -484,33 +484,33 @@ const int8_t _cairo_twin_outlines[] = {
-21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, 0,
'l', 24, 0,
'e',
'X', 'X', 'X',
/* 0x4d 'M' offset 1785 */
0, 32, 42, 0, 2, 3,
0, 32, /* snap_x */
-21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'l', 16, 0,
'm', 32, -42,
'm', 0, 0,
'l', 0, -42,
'l', 16, 0,
'm', 32, -42,
'l', 32, -42,
'l', 32, 0,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x4e 'N' offset 1821 */
0, 28, 42, 0, 2, 3,
0, 28, /* snap_x */
-21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'l', 28, 0,
'm', 28, -42,
'm', 0, 0,
'l', 0, -42,
'l', 28, 0,
'l', 28, -42,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x4f 'O' offset 1851 */
0, 32, 42, 0, 2, 4,
0, 32, /* snap_x */
Expand All @@ -520,18 +520,18 @@ const int8_t _cairo_twin_outlines[] = {
'c', 0, -13, 2, 0, 16, 0,
'c', 30, 0, 32, -13, 32, -21,
'c', 32, -29, 30, -42, 16, -42,
'e',
'E',
/* 0x50 'P' offset 1895 */
0, 28, 42, 0, 2, 5,
0, 28, /* snap_x */
-42, -21, -20, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'm', 0, 0,
'l', 0, -42,
'l', 18, -42,
'c', 32, -42, 32, -20, 18, -20,
'l', 0, -20,
'e',
'X', 'X', 'X',
/* 0x51 'Q' offset 1931 */
0, 32, 42, 4, 2, 4,
0, 32, /* snap_x */
Expand All @@ -548,15 +548,15 @@ const int8_t _cairo_twin_outlines[] = {
0, 28, 42, 0, 2, 5,
0, 28, /* snap_x */
-42, -22, -21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 0, 0,
'm', 0, -42,
'm', 0, 0,
'l', 0, -42,
'l', 18, -42,
'c', 32, -42, 31, -22, 18, -22,
'l', 0, -22,
'm', 14, -22,
'l', 28, 0,
'e',
'X', 'X', 'X',
/* 0x53 'S' offset 2023 */
0, 28, 42, 0, 2, 4,
0, 28, /* snap_x */
Expand Down Expand Up @@ -592,22 +592,22 @@ const int8_t _cairo_twin_outlines[] = {
-21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 16, 0,
'm', 32, -42,
'l', 16, 0,
'l', 32, -42,
'e',
'X', 'X', 'X',
/* 0x57 'W' offset 2152 */
0, 40, 42, 0, 2, 3,
0, 40, /* snap_x */
-21, -15, 0, /* snap_y */
'm', 0, -42,
'l', 10, 0,
'm', 20, -42,
'l', 10, 0,
'm', 20, -42,
'l', 30, 0,
'm', 40, -42,
'l', 20, -42,
'l', 30, 0,
'l', 40, -42,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x58 'X' offset 2188 */
0, 28, 42, 0, 2, 3,
0, 28, /* snap_x */
Expand All @@ -631,13 +631,13 @@ const int8_t _cairo_twin_outlines[] = {
0, 28, 42, 0, 2, 4,
0, 28, /* snap_x */
-42, -21, -15, 0, /* snap_y */
'm', 28, -42,
'm', 28, 0,
'l', 0, 0,
'm', 0, -42,
'l', 28, -42,
'm', 0, 0,
'l', 28, 0,
'l', 0, -42,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x5b '[' offset 2271 */
0, 14, 44, 0, 2, 4,
0, 14, /* snap_x */
Expand Down Expand Up @@ -667,11 +667,11 @@ const int8_t _cairo_twin_outlines[] = {
0, 32, 46, -18, 2, 3,
0, 32, /* snap_x */
-21, -15, 0, /* snap_y */
'm', 16, -46,
'l', 0, -18,
'm', 16, -46,
'm', 0, -18,
'l', 16, -46,
'l', 32, -18,
'e',
'X', 'X', 'X',
/* 0x5f '_' offset 2363 */
0, 36, 0, 0, 2, 3,
0, 36, /* snap_x */
Expand Down Expand Up @@ -921,22 +921,22 @@ const int8_t _cairo_twin_outlines[] = {
-21, -15, 0, /* snap_y */
'm', 0, -28,
'l', 12, 0,
'm', 24, -28,
'l', 12, 0,
'l', 24, -28,
'e',
'X', 'X', 'X',
/* 0x77 'w' offset 3307 */
0, 32, 28, 0, 2, 3,
0, 32, /* snap_x */
-21, -15, 0, /* snap_y */
'm', 0, -28,
'l', 8, 0,
'm', 16, -28,
'l', 8, 0,
'm', 16, -28,
'l', 24, 0,
'm', 32, -28,
'l', 16, -28,
'l', 24, 0,
'l', 32, -28,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x78 'x' offset 3343 */
0, 22, 28, 0, 2, 3,
0, 22, /* snap_x */
Expand All @@ -960,13 +960,13 @@ const int8_t _cairo_twin_outlines[] = {
0, 22, 28, 0, 2, 4,
0, 22, /* snap_x */
-28, -21, -15, 0, /* snap_y */
'm', 22, -28,
'm', 22, 0,
'l', 0, 0,
'm', 0, -28,
'l', 22, -28,
'm', 0, 0,
'l', 22, 0,
'l', 0, -28,
'e',
'X', 'X', 'X',
'X', 'X', 'X',
/* 0x7b '{' offset 3430 */
0, 16, 44, 0, 3, 5,
0, 6, 16, /* snap_x */
Expand Down
Loading

0 comments on commit f8542dc

Please sign in to comment.