[coretext] Round position info

Test:

Before:
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=coretext
[gid781=0@-78,0+841]
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=ot
[gid781=0@-78,0+842]

After:
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=coretext
[gid781=0@-78,0+842]
$ ./hb-shape /System/Library/Fonts/ヒラギノ丸ゴ\ ProN\ W4.ttc 1 --features="+palt" --shaper=ot
[gid781=0@-78,0+842]

I've verified in the font that 842 is correct.
This commit is contained in:
Behdad Esfahbod 2021-06-14 12:31:02 -06:00
parent 2b0ced28b6
commit d3dd936309
1 changed files with 6 additions and 6 deletions

View File

@ -1061,7 +1061,7 @@ resize_and_retry:
hb_glyph_info_t *info = run_info; hb_glyph_info_t *info = run_info;
if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
{ {
hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult; hb_position_t x_offset = round ((positions[0].x - advances_so_far) * x_mult);
for (unsigned int j = 0; j < num_glyphs; j++) for (unsigned int j = 0; j < num_glyphs; j++)
{ {
CGFloat advance; CGFloat advance;
@ -1069,15 +1069,15 @@ resize_and_retry:
advance = positions[j + 1].x - positions[j].x; advance = positions[j + 1].x - positions[j].x;
else /* last glyph */ else /* last glyph */
advance = run_advance - (positions[j].x - positions[0].x); advance = run_advance - (positions[j].x - positions[0].x);
info->mask = advance * x_mult; info->mask = round (advance * x_mult);
info->var1.i32 = x_offset; info->var1.i32 = x_offset;
info->var2.i32 = positions[j].y * y_mult; info->var2.i32 = round (positions[j].y * y_mult);
info++; info++;
} }
} }
else else
{ {
hb_position_t y_offset = (positions[0].y - advances_so_far) * y_mult; hb_position_t y_offset = round ((positions[0].y - advances_so_far) * y_mult);
for (unsigned int j = 0; j < num_glyphs; j++) for (unsigned int j = 0; j < num_glyphs; j++)
{ {
CGFloat advance; CGFloat advance;
@ -1085,8 +1085,8 @@ resize_and_retry:
advance = positions[j + 1].y - positions[j].y; advance = positions[j + 1].y - positions[j].y;
else /* last glyph */ else /* last glyph */
advance = run_advance - (positions[j].y - positions[0].y); advance = run_advance - (positions[j].y - positions[0].y);
info->mask = advance * y_mult; info->mask = round (advance * y_mult);
info->var1.i32 = positions[j].x * x_mult; info->var1.i32 = round (positions[j].x * x_mult);
info->var2.i32 = y_offset; info->var2.i32 = y_offset;
info++; info++;
} }