[gvar] fix infinite loop introduced by 11f3fca
The attempt on removing end_points had made the code unreadable and has intrdouced infinite, fixed by making the code clear what it tries to achieve.
This commit is contained in:
parent
f00eb4ebfa
commit
1f5a54c768
@ -625,17 +625,27 @@ struct gvar
|
||||
deltas[pt_index].y += y_deltas[i] * scalar;
|
||||
}
|
||||
|
||||
/* find point before phantoms start which is an end point */
|
||||
unsigned all_contours_end = points.length ? points.length - 1 : 0;
|
||||
while (all_contours_end > 0)
|
||||
{
|
||||
if (points[all_contours_end].is_end_point) break;
|
||||
--all_contours_end;
|
||||
}
|
||||
|
||||
/* infer deltas for unreferenced points */
|
||||
for (unsigned start_point = 0; start_point + 4 < points.length; ++start_point)
|
||||
for (unsigned start_point = 0; start_point < all_contours_end; ++start_point)
|
||||
{
|
||||
/* Check the number of unreferenced points in a contour. If no unref points or no ref points, nothing to do. */
|
||||
unsigned unref_count = 0;
|
||||
unsigned end_point = start_point;
|
||||
do
|
||||
unsigned unref_count = 0;
|
||||
for (; end_point <= all_contours_end; ++end_point)
|
||||
{
|
||||
if (!deltas[end_point].flag) unref_count++;
|
||||
end_point++;
|
||||
} while (!points[end_point].is_end_point && end_point + 4 < points.length);
|
||||
if (!deltas[end_point].flag)
|
||||
unref_count++;
|
||||
if (points[end_point].is_end_point)
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned j = start_point;
|
||||
if (unref_count == 0 || unref_count > end_point - start_point)
|
||||
|
BIN
test/api/fonts/TestGVAREight.ttf
Normal file
BIN
test/api/fonts/TestGVAREight.ttf
Normal file
Binary file not shown.
@ -234,6 +234,23 @@ test_advance_tt_var_comp_v (void)
|
||||
hb_font_destroy (font);
|
||||
}
|
||||
|
||||
static void
|
||||
test_advance_tt_var_gvar_infer (void)
|
||||
{
|
||||
hb_face_t *face = hb_test_open_font_file ("fonts/TestGVAREight.ttf");
|
||||
hb_font_t *font = hb_font_create (face);
|
||||
hb_ot_font_set_funcs (font);
|
||||
hb_face_destroy (face);
|
||||
|
||||
int coords[6] = {100};
|
||||
hb_font_set_var_coords_normalized (font, coords, 6);
|
||||
|
||||
hb_glyph_extents_t extents = {0};
|
||||
g_assert (hb_font_get_glyph_extents (font, 4, &extents));
|
||||
|
||||
hb_font_destroy (font);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@ -245,6 +262,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_advance_tt_var_anchor);
|
||||
hb_test_add (test_extents_tt_var_comp);
|
||||
hb_test_add (test_advance_tt_var_comp_v);
|
||||
hb_test_add (test_advance_tt_var_gvar_infer);
|
||||
|
||||
return hb_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user