From b634beb39e0a4fef7167a8af646f6b2d8cafe69b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 20 May 2010 17:44:52 +0100 Subject: [PATCH] Fix delta scale, again... --- src/hb-ot-layout-common-private.hh | 8 ++++++++ src/hb-ot-layout-gdef-private.hh | 3 +-- src/hb-ot-layout-gpos-private.hh | 12 ++++++------ src/hb-ot-layout-private.hh | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index e054b5935..f96549143 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -566,6 +566,14 @@ struct ClassDef struct Device { + /* XXX speed up */ + + inline hb_position_t get_x_delta (hb_ot_layout_context_t *c) const + { return c->font->x_ppem ? get_delta (c->font->x_ppem) * (uint64_t) c->font->x_scale / c->font->x_ppem : 0; } + + inline hb_position_t get_y_delta (hb_ot_layout_context_t *c) const + { return c->font->y_ppem ? get_delta (c->font->y_ppem) * (uint64_t) c->font->y_scale / c->font->y_ppem : 0; } + inline int get_delta (unsigned int ppem_size) const { unsigned int f = deltaFormat; diff --git a/src/hb-ot-layout-gdef-private.hh b/src/hb-ot-layout-gdef-private.hh index 4989363a0..1adff6e48 100644 --- a/src/hb-ot-layout-gdef-private.hh +++ b/src/hb-ot-layout-gdef-private.hh @@ -144,8 +144,7 @@ struct CaretValueFormat3 inline int get_caret_value (hb_ot_layout_context_t *c, hb_codepoint_t glyph_id HB_UNUSED) const { /* TODO vertical */ - return c->scale_x (coordinate) + - ((this+deviceTable).get_delta (c->font->x_ppem) * c->font->x_scale); + return c->scale_x (coordinate) + ((this+deviceTable).get_x_delta (c)); } inline bool sanitize (hb_sanitize_context_t *c) { diff --git a/src/hb-ot-layout-gpos-private.hh b/src/hb-ot-layout-gpos-private.hh index 10e9df578..77cbbeba2 100644 --- a/src/hb-ot-layout-gpos-private.hh +++ b/src/hb-ot-layout-gpos-private.hh @@ -112,16 +112,16 @@ struct ValueFormat : USHORT /* pixel -> fractional pixel */ if (format & xPlaDevice) { - if (x_ppem) glyph_pos.x_offset += (base + get_device (values++)).get_delta (x_ppem) * layout->font->x_scale; else values++; + if (x_ppem) glyph_pos.x_offset += (base + get_device (values++)).get_x_delta (layout); else values++; } if (format & yPlaDevice) { - if (y_ppem) glyph_pos.y_offset += (base + get_device (values++)).get_delta (y_ppem) * layout->font->y_scale; else values++; + if (y_ppem) glyph_pos.y_offset += (base + get_device (values++)).get_y_delta (layout); else values++; } if (format & xAdvDevice) { - if (x_ppem) glyph_pos.x_advance += (base + get_device (values++)).get_delta (x_ppem) * layout->font->x_scale; else values++; + if (x_ppem) glyph_pos.x_advance += (base + get_device (values++)).get_x_delta (layout); else values++; } if (format & yAdvDevice) { - if (y_ppem) glyph_pos.y_advance += (base + get_device (values++)).get_delta (y_ppem) * layout->font->y_scale; else values++; + if (y_ppem) glyph_pos.y_advance += (base + get_device (values++)).get_y_delta (layout); else values++; } } @@ -268,9 +268,9 @@ struct AnchorFormat3 /* pixel -> fractional pixel */ if (layout->font->x_ppem) - *x += (this+xDeviceTable).get_delta (layout->font->x_ppem) * layout->font->x_scale; + *x += (this+xDeviceTable).get_x_delta (layout); if (layout->font->y_ppem) - *y += (this+yDeviceTable).get_delta (layout->font->y_ppem) * layout->font->y_scale; + *y += (this+yDeviceTable).get_x_delta (layout); } inline bool sanitize (hb_sanitize_context_t *c) { diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh index 723db4457..71d725382 100644 --- a/src/hb-ot-layout-private.hh +++ b/src/hb-ot-layout-private.hh @@ -76,7 +76,7 @@ struct hb_ot_layout_context_t } info; /* Convert from font-space to user-space */ - /* XXX div-by-zero */ + /* XXX div-by-zero / speed up */ inline hb_position_t scale_x (int16_t v) { return (int64_t) this->font->x_scale * v / this->face->head_table->unitsPerEm; } inline hb_position_t scale_y (int16_t v) { return (int64_t) this->font->y_scale * v / this->face->head_table->unitsPerEm; } };