Fix delta scale, again...

This commit is contained in:
Behdad Esfahbod 2010-05-20 17:44:52 +01:00
parent 40335d4533
commit b634beb39e
4 changed files with 16 additions and 9 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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) {

View File

@ -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; }
};