[draw/glyf] Emit empty contours

This makes it actually match freetype behaviour even though rasterizer
should filter such contours specially for stroking.

See https://github.com/harfbuzz/harfbuzz/pull/3411#discussion_r802283827 for the context.
This commit is contained in:
Ebrahim Byagowi 2022-02-13 23:49:41 +03:30
parent f942874fac
commit d4588204e5
2 changed files with 9 additions and 2 deletions

View File

@ -1251,6 +1251,12 @@ struct glyf
font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y));
else if (first_oncurve.has_data) else if (first_oncurve.has_data)
draw_session->line_to (font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); draw_session->line_to (font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y));
else if (first_offcurve.has_data)
{
float x = font->em_fscalef_x (first_offcurve.x), y = font->em_fscalef_x (first_offcurve.y);
draw_session->move_to (x, y);
draw_session->quadratic_to (x, y, x, y);
}
/* Getting ready for the next contour */ /* Getting ready for the next contour */
first_oncurve = first_offcurve = last_offcurve = optional_point_t (); first_oncurve = first_offcurve = last_offcurve = optional_point_t ();

View File

@ -369,7 +369,7 @@ test_hb_draw_ttf_parser_tests (void)
{ {
draw_data.consumed = 0; draw_data.consumed = 0;
hb_font_get_glyph_shape (font, 5, funcs, &draw_data); hb_font_get_glyph_shape (font, 5, funcs, &draw_data);
char expected[] = ""; char expected[] = "M15,0Q15,0 15,0Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
} }
{ {
@ -378,7 +378,8 @@ test_hb_draw_ttf_parser_tests (void)
char expected[] = "M346,468L211,468L211,0L123,0L123,468L29,468L29,509L123,539" char expected[] = "M346,468L211,468L211,0L123,0L123,468L29,468L29,509L123,539"
"L123,570Q123,674 169,720Q215,765 297,765Q329,765 356,760" "L123,570Q123,674 169,720Q215,765 297,765Q329,765 356,760"
"Q382,754 401,747L378,678Q362,683 341,688Q320,693 298,693" "Q382,754 401,747L378,678Q362,683 341,688Q320,693 298,693"
"Q254,693 233,664Q211,634 211,571L211,536L346,536L346,468Z"; "Q254,693 233,664Q211,634 211,571L211,536L346,536L346,468Z"
"M15,0Q15,0 15,0Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1); g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
} }