summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-11 21:40:37 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 08:08:34 +0100
commitbb919584c0054bb3e3c547f65c91cfe48302ac86 (patch)
treee83db3010d2d44524fcaefdae8dffcc4beba2efe /util
parentcbee97f0e3e784b4482429790fc3f42c81908557 (diff)
[script] Use a compact representation for horizontal offsets between glyphs
Kerning is quite frequent, that is to apply a horizontal but no vertical offset to a glyph. For instance by discarding the vertical coordinate where it remains the same and only encoding the horizontal offset we reduce the file size by ~12.5% when tracing poppler.
Diffstat (limited to 'util')
-rw-r--r--util/cairo-script/cairo-script-operators.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 5247682f..6a6279dd 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -2351,7 +2351,7 @@ _glyph_string (csi_t *ctx,
cairo_scaled_font_t *scaled_font,
cairo_glyph_t *glyphs)
{
- double x,y;
+ double x,y, dx;
csi_integer_t nglyphs, i, j;
struct glyph_advance_cache *cache;
cairo_status_t status;
@@ -2448,12 +2448,22 @@ _glyph_string (csi_t *ctx,
}
case CSI_OBJECT_TYPE_INTEGER:
- case CSI_OBJECT_TYPE_REAL: /* dx */
- x = csi_number_get_value (obj);
- if (++i == array->stack.len)
+ case CSI_OBJECT_TYPE_REAL: /* dx or x*/
+ dx = csi_number_get_value (obj);
+ if (i+1 == array->stack.len)
break;
- y = csi_number_get_value (&array->stack.objects[i]);
- break;
+
+ switch ((int) csi_object_get_type (&array->stack.objects[i+1])) {
+ case CSI_OBJECT_TYPE_INTEGER:
+ case CSI_OBJECT_TYPE_REAL: /* y */
+ y = csi_number_get_value (&array->stack.objects[i+1]);
+ x = dx;
+ i++;
+ break;
+
+ default:
+ x += dx;
+ }
}
}