Fix offset drift in graphite integration
This commit is contained in:
parent
8a25868e6a
commit
731b13e4e9
|
@ -225,7 +225,7 @@ struct hb_graphite2_cluster_t {
|
|||
unsigned int base_glyph;
|
||||
unsigned int num_glyphs;
|
||||
unsigned int cluster;
|
||||
float advance;
|
||||
unsigned int advance;
|
||||
};
|
||||
|
||||
hb_bool_t
|
||||
|
@ -253,7 +253,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
gr_segment *seg = nullptr;
|
||||
const gr_slot *is;
|
||||
unsigned int ci = 0, ic = 0;
|
||||
float curradvx = 0., curradvy = 0.;
|
||||
unsigned int curradvx = 0, curradvy = 0;
|
||||
|
||||
unsigned int scratch_size;
|
||||
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
|
||||
|
@ -324,11 +324,15 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
|
||||
hb_codepoint_t *pg = gids;
|
||||
clusters[0].cluster = buffer->info[0].cluster;
|
||||
float curradv = 0.;
|
||||
unsigned int upem = hb_face_get_upem (face);
|
||||
float xscale = (float) font->x_scale / upem;
|
||||
float yscale = (float) font->y_scale / upem;
|
||||
yscale *= yscale / xscale;
|
||||
unsigned int curradv = 0;
|
||||
if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
{
|
||||
curradv = gr_slot_origin_X(gr_seg_first_slot(seg));
|
||||
clusters[0].advance = gr_seg_advance_X(seg) - curradv;
|
||||
curradv = gr_slot_origin_X(gr_seg_first_slot(seg)) * xscale;
|
||||
clusters[0].advance = gr_seg_advance_X(seg) * xscale - curradv;
|
||||
}
|
||||
else
|
||||
clusters[0].advance = 0;
|
||||
|
@ -355,14 +359,17 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
c->base_glyph = ic;
|
||||
c->num_glyphs = 0;
|
||||
if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
c->advance = curradv - gr_slot_origin_X(is);
|
||||
{
|
||||
c->advance = curradv - gr_slot_origin_X(is) * xscale;
|
||||
curradv -= c->advance;
|
||||
}
|
||||
else
|
||||
{
|
||||
c->advance = 0;
|
||||
clusters[ci].advance += gr_slot_origin_X(is) - curradv;
|
||||
clusters[ci].advance += gr_slot_origin_X(is) * xscale - curradv;
|
||||
curradv += clusters[ci].advance;
|
||||
}
|
||||
ci++;
|
||||
curradv = gr_slot_origin_X(is);
|
||||
}
|
||||
clusters[ci].num_glyphs++;
|
||||
|
||||
|
@ -373,7 +380,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
if (HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
|
||||
clusters[ci].advance += curradv;
|
||||
else
|
||||
clusters[ci].advance += gr_seg_advance_X(seg) - curradv;
|
||||
clusters[ci].advance += gr_seg_advance_X(seg) * xscale - curradv;
|
||||
ci++;
|
||||
|
||||
for (unsigned int i = 0; i < ci; ++i)
|
||||
|
@ -388,10 +395,6 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
}
|
||||
buffer->len = glyph_count;
|
||||
|
||||
unsigned int upem = hb_face_get_upem (face);
|
||||
float xscale = (float) font->x_scale / upem;
|
||||
float yscale = (float) font->y_scale / upem;
|
||||
yscale *= yscale / xscale;
|
||||
/* Positioning. */
|
||||
unsigned int currclus = (unsigned int) -1;
|
||||
const hb_glyph_info_t *info = buffer->info;
|
||||
|
@ -404,7 +407,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
pPos->x_offset = gr_slot_origin_X (is) * xscale - curradvx;
|
||||
pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
|
||||
if (info->cluster != currclus) {
|
||||
pPos->x_advance = info->var1.i32 * xscale;
|
||||
pPos->x_advance = info->var1.i32;
|
||||
curradvx += pPos->x_advance;
|
||||
currclus = info->cluster;
|
||||
} else
|
||||
|
@ -421,7 +424,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
{
|
||||
if (info->cluster != currclus)
|
||||
{
|
||||
pPos->x_advance = info->var1.i32 * xscale;
|
||||
pPos->x_advance = info->var1.i32;
|
||||
curradvx -= pPos->x_advance;
|
||||
currclus = info->cluster;
|
||||
} else
|
||||
|
@ -429,7 +432,7 @@ _hb_graphite2_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|||
|
||||
pPos->y_advance = gr_slot_advance_Y (is, grface, nullptr) * yscale;
|
||||
curradvy -= pPos->y_advance;
|
||||
pPos->x_offset = (gr_slot_origin_X (is) - info->var1.i32) * xscale - curradvx + pPos->x_advance;
|
||||
pPos->x_offset = gr_slot_origin_X (is) * xscale - info->var1.i32 - curradvx + pPos->x_advance;
|
||||
pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
|
||||
}
|
||||
hb_buffer_reverse_clusters (buffer);
|
||||
|
|
Loading…
Reference in New Issue