From d4588204e52eece7dab04f45e37d2986b1545cb7 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 13 Feb 2022 23:49:41 +0330 Subject: [PATCH] [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. --- src/hb-ot-glyf-table.hh | 6 ++++++ test/api/test-draw.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index dee465a6b..2c26a8df1 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -1251,6 +1251,12 @@ struct glyf font->em_fscalef_x (first_oncurve.x), font->em_fscalef_y (first_oncurve.y)); else if (first_oncurve.has_data) 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 */ first_oncurve = first_offcurve = last_offcurve = optional_point_t (); diff --git a/test/api/test-draw.c b/test/api/test-draw.c index 72b1aadfb..023e82188 100644 --- a/test/api/test-draw.c +++ b/test/api/test-draw.c @@ -369,7 +369,7 @@ test_hb_draw_ttf_parser_tests (void) { draw_data.consumed = 0; 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); } { @@ -378,7 +378,8 @@ test_hb_draw_ttf_parser_tests (void) char expected[] = "M346,468L211,468L211,0L123,0L123,468L29,468L29,509L123,539" "L123,570Q123,674 169,720Q215,765 297,765Q329,765 356,760" "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); }