[draw] Virtualize hb_font_draw_glyph() into hb_font_get_glyph_shape()

To be implemented in hb-ft.
This commit is contained in:
Behdad Esfahbod 2022-02-03 01:14:47 -06:00
parent 92e6e53b30
commit 8b4f429000
12 changed files with 150 additions and 110 deletions

View File

@ -38,7 +38,6 @@ HB_BASE_sources = \
hb-config.hh \
hb-debug.hh \
hb-dispatch.hh \
hb-draw-glyph.cc \
hb-draw.cc \
hb-draw.hh \
hb-face.cc \

View File

@ -5,7 +5,6 @@
#include "hb-buffer-verify.cc"
#include "hb-buffer.cc"
#include "hb-common.cc"
#include "hb-draw-glyph.cc"
#include "hb-draw.cc"
#include "hb-face.cc"
#include "hb-fallback-shape.cc"

View File

@ -1,63 +0,0 @@
/*
* Copyright © 2019-2020 Ebrahim Byagowi
*
* This is part of HarfBuzz, a text shaping library.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and its documentation for any purpose, provided that the
* above copyright notice and the following two paragraphs appear in
* all copies of this software.
*
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
#include "hb.hh"
#ifndef HB_NO_DRAW
#include "hb-ot-glyf-table.hh"
#include "hb-ot-cff1-table.hh"
#include "hb-ot-cff2-table.hh"
/**
* hb_font_draw_glyph:
* @font: a font object
* @glyph: a glyph id
* @funcs: draw callbacks object
* @draw_data: parameter you like be passed to the callbacks when are called
*
* Draw a glyph.
*
* Returns: Whether the font had the glyph and the operation completed successfully.
* Since: REPLACEME
**/
void
hb_font_draw_glyph (hb_font_t *font,
hb_codepoint_t glyph,
hb_draw_funcs_t *funcs,
void *draw_data)
{
if (unlikely (funcs == &Null (hb_draw_funcs_t) ||
glyph >= font->face->get_num_glyphs ()))
return;
draw_helper_t draw_helper (funcs, draw_data);
if (font->face->table.glyf->get_path (font, glyph, draw_helper)) return;
#ifndef HB_NO_CFF
if (font->face->table.cff1->get_path (font, glyph, draw_helper)) return;
if (font->face->table.cff2->get_path (font, glyph, draw_helper)) return;
#endif
}
#endif

View File

@ -501,6 +501,26 @@ hb_font_get_glyph_from_name_default (hb_font_t *font,
return font->parent->get_glyph_from_name (name, len, glyph);
}
static void
hb_font_get_glyph_shape_nil (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_draw_funcs_t *draw_funcs,
void *draw_data,
void *user_data HB_UNUSED)
{
}
static void
hb_font_get_glyph_shape_default (hb_font_t *font HB_UNUSED,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_draw_funcs_t *draw_funcs,
void *draw_data,
void *user_data HB_UNUSED)
{
}
DEFINE_NULL_INSTANCE (hb_font_funcs_t) =
{
HB_OBJECT_HEADER_STATIC,
@ -1168,6 +1188,24 @@ hb_font_get_glyph_from_name (hb_font_t *font,
return font->get_glyph_from_name (name, len, glyph);
}
/**
* hb_font_get_glyph_shape:
* @font: #hb_font_t to work upon
* @glyph: : The glyph ID
* @dfuncs:
* @draw_data:
*
* Fetches the glyph shape that corresponds to a glyph in the specified @font.
*
* Since: REPLACE
**/
void
hb_font_get_glyph_shape (hb_font_t *font,
hb_codepoint_t glyph,
hb_draw_funcs_t *dfuncs, void *draw_data)
{
font->get_glyph_shape (glyph, dfuncs, draw_data);
}
/* A bit higher-level, and with fallback */

View File

@ -511,6 +511,27 @@ typedef hb_bool_t (*hb_font_get_glyph_from_name_func_t) (hb_font_t *font, void *
hb_codepoint_t *glyph,
void *user_data);
/**
* hb_font_get_glyph_shape_func_t:
* @font: #hb_font_t to work upon
* @font_data: @font user data pointer
* @glyph: The glyph ID to query
* @draw_funcs: The draw functions to send the shape data to
* @draw_data The data accompnaying the draw functions
* @user_data: User data pointer passed by the caller
*
* A virtual method for the #hb_font_funcs_t of an #hb_font_t object.
*
*
*
* Return value: %true if data found, %false otherwise
*
**/
typedef void (*hb_font_get_glyph_shape_func_t) (hb_font_t *font, void *font_data,
hb_codepoint_t glyph,
hb_draw_funcs_t *draw_funcs, void *draw_data,
void *user_data);
/* func setters */
@ -770,6 +791,22 @@ hb_font_funcs_set_glyph_from_name_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_from_name_func_t func,
void *user_data, hb_destroy_func_t destroy);
/**
* hb_font_funcs_set_glyph_shape_func:
* @ffuncs: A font-function structure
* @func: (closure user_data) (destroy destroy) (scope notified): The callback function to assign
* @user_data: Data to pass to @func
* @destroy: (nullable): The function to call when @user_data is not needed anymore
*
* Sets the implementation function for #hb_font_get_glyph_shape_func_t.
*
* Since: REPLACEME
**/
HB_EXTERN void
hb_font_funcs_set_glyph_shape_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_shape_func_t func,
void *user_data, hb_destroy_func_t destroy);
/* func dispatch */
HB_EXTERN hb_bool_t
@ -850,6 +887,11 @@ hb_font_get_glyph_from_name (hb_font_t *font,
const char *name, int len, /* -1 means nul-terminated */
hb_codepoint_t *glyph);
HB_EXTERN void
hb_font_get_glyph_shape (hb_font_t *font,
hb_codepoint_t glyph,
hb_draw_funcs_t *dfuncs, void *draw_data);
/* high-level funcs, with fallback */
@ -1056,11 +1098,6 @@ HB_EXTERN void
hb_font_set_var_named_instance (hb_font_t *font,
unsigned instance_index);
HB_EXTERN void
hb_font_draw_glyph (hb_font_t *font,
hb_codepoint_t glyph,
hb_draw_funcs_t *funcs,
void *user_data);
HB_END_DECLS

View File

@ -57,6 +57,7 @@
HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
HB_FONT_FUNC_IMPLEMENT (glyph_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \
HB_FONT_FUNC_IMPLEMENT (glyph_shape) \
/* ^--- Add new callbacks here */
struct hb_font_funcs_t
@ -375,6 +376,15 @@ struct hb_font_t
klass->user_data.glyph_from_name);
}
void get_glyph_shape (hb_codepoint_t glyph,
hb_draw_funcs_t *draw_funcs, void *draw_data)
{
klass->get.f.glyph_shape (this, user_data,
glyph,
draw_funcs, draw_data,
klass->user_data.glyph_shape);
}
/* A bit higher-level, and with fallback */

View File

@ -257,6 +257,23 @@ hb_ot_get_font_v_extents (hb_font_t *font,
}
#endif
#ifndef HB_NO_DRAW
static void
hb_ot_get_glyph_shape (hb_font_t *font,
void *font_data HB_UNUSED,
hb_codepoint_t glyph,
hb_draw_funcs_t *draw_funcs, void *draw_data,
void *user_data)
{
draw_helper_t draw_helper (draw_funcs, draw_data);
if (font->face->table.glyf->get_path (font, glyph, draw_helper)) return;
#ifndef HB_NO_CFF
if (font->face->table.cff1->get_path (font, glyph, draw_helper)) return;
if (font->face->table.cff2->get_path (font, glyph, draw_helper)) return;
#endif
}
#endif
static inline void free_static_ot_funcs ();
static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot_font_funcs_lazy_loader_t>
@ -279,6 +296,10 @@ static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t<hb_ot
hb_font_funcs_set_glyph_v_origin_func (funcs, hb_ot_get_glyph_v_origin, nullptr, nullptr);
#endif
#ifndef HB_NO_DRAW
hb_font_funcs_set_glyph_shape_func (funcs, hb_ot_get_glyph_shape, nullptr, nullptr);
#endif
hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr);
//hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr);

View File

@ -239,7 +239,7 @@ layered_glyph_dump (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index
if (hb_color_get_alpha (color) != 255)
fprintf (f, "fill-opacity=\"%.3f\"", (double) hb_color_get_alpha (color) / 255.);
fprintf (f, "d=\"");
hb_font_draw_glyph (font, layers[layer].glyph, funcs, &draw_data);
hb_font_get_glyph_shape (font, layers[layer].glyph, funcs, &draw_data);
fprintf (f, "\"/>\n");
}
@ -278,7 +278,7 @@ dump_glyphs (hb_font_t *font, hb_draw_funcs_t *funcs, unsigned face_index)
draw_data_t draw_data;
draw_data.ascender = font_extents.ascender;
draw_data.f = f;
hb_font_draw_glyph (font, gid, funcs, &draw_data);
hb_font_get_glyph_shape (font, gid, funcs, &draw_data);
fprintf (f, "\"/></svg>");
fclose (f);
}

View File

@ -42,7 +42,6 @@ hb_base_sources = files(
'hb-config.hh',
'hb-debug.hh',
'hb-dispatch.hh',
'hb-draw-glyph.cc',
'hb-draw.cc',
'hb-draw.hh',
'hb-face.cc',

View File

@ -174,7 +174,7 @@ static hb_draw_funcs_t *funcs2; /* this one translates quadratic calls to cubic
static void
test_hb_draw_empty (void)
{
hb_font_draw_glyph (hb_font_get_empty (), 3, funcs, NULL);
hb_font_get_glyph_shape (hb_font_get_empty (), 3, funcs, NULL);
}
static void
@ -192,10 +192,10 @@ test_hb_draw_glyf (void)
};
draw_data.consumed = 0;
hb_font_draw_glyph (font, 4, funcs, &draw_data);
hb_font_get_glyph_shape (font, 4, funcs, &draw_data);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 3, funcs, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs, &draw_data);
char expected[] = "M275,442Q232,442 198,420Q164,397 145,353Q126,309 126,245"
"Q126,182 147,139Q167,95 204,73Q240,50 287,50Q330,50 367,70"
"Q404,90 427,128L451,116Q431,54 384,21Q336,-13 266,-13"
@ -207,7 +207,7 @@ test_hb_draw_glyf (void)
/* Test translating quadratic calls to cubic by a _draw_funcs_t that doesn't set the callback */
draw_data.consumed = 0;
hb_font_draw_glyph (font, 3, funcs2, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs2, &draw_data);
char expected2[] = "M275,442C246,442 221,435 198,420C175,405 158,382 145,353"
"C132,324 126,288 126,245C126,203 133,168 147,139C160,110 179,88 204,73"
"C228,58 256,50 287,50C316,50 342,57 367,70C392,83 412,103 427,128"
@ -225,7 +225,7 @@ test_hb_draw_glyf (void)
hb_font_set_variations (font, &var, 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 3, funcs, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs, &draw_data);
char expected3[] = "M323,448Q297,448 271,430Q244,412 226,371Q209,330 209,261"
"Q209,204 225,166Q242,127 272,107Q303,86 344,86Q378,86 404,101"
"Q430,115 451,137L488,103Q458,42 404,13Q350,-16 279,-16"
@ -251,7 +251,7 @@ test_hb_draw_cff1 (void)
.size = sizeof (str),
.consumed = 0
};
hb_font_draw_glyph (font, 3, funcs, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs, &draw_data);
char expected[] = "M203,367C227,440 248,512 268,588L272,588C293,512 314,440 338,367L369,267L172,267L203,367Z"
"M3,0L88,0L151,200L390,200L452,0L541,0L319,656L225,656L3,0Z"
"M300,653L342,694L201,861L143,806L300,653Z";
@ -274,7 +274,7 @@ test_hb_draw_cff1_rline (void)
.size = sizeof (str),
.consumed = 0
};
hb_font_draw_glyph (font, 1, funcs, &draw_data);
hb_font_get_glyph_shape (font, 1, funcs, &draw_data);
char expected[] = "M775,400C705,400 650,343 650,274L650,250L391,250L713,572L392,893"
"L287,1000C311,942 296,869 250,823C250,823 286,858 321,823L571,572"
"L150,150L750,150L750,276C750,289 761,300 775,300C789,300 800,289 800,276"
@ -299,7 +299,7 @@ test_hb_draw_cff2 (void)
};
draw_data.consumed = 0;
hb_font_draw_glyph (font, 3, funcs, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs, &draw_data);
char expected[] = "M275,442C303,442 337,435 371,417L325,454L350,366"
"C357,341 370,321 403,321C428,321 443,333 448,358"
"C435,432 361,487 272,487C153,487 43,393 43,236"
@ -313,7 +313,7 @@ test_hb_draw_cff2 (void)
hb_font_set_variations (font, &var, 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 3, funcs, &draw_data);
hb_font_get_glyph_shape (font, 3, funcs, &draw_data);
char expected2[] = "M323,448C356,448 380,441 411,427L333,469L339,401"
"C343,322 379,297 420,297C458,297 480,314 492,352"
"C486,433 412,501 303,501C148,501 25,406 25,241"
@ -339,19 +339,19 @@ test_hb_draw_ttf_parser_tests (void)
hb_face_destroy (face);
{
draw_data.consumed = 0;
hb_font_draw_glyph (font, 0, funcs, &draw_data);
hb_font_get_glyph_shape (font, 0, funcs, &draw_data);
char expected[] = "M50,0L50,750L450,750L450,0L50,0Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
}
{
draw_data.consumed = 0;
hb_font_draw_glyph (font, 1, funcs, &draw_data);
hb_font_get_glyph_shape (font, 1, funcs, &draw_data);
char expected[] = "M56,416L56,487L514,487L514,416L56,416ZM56,217L56,288L514,288L514,217L56,217Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
}
{
draw_data.consumed = 0;
hb_font_draw_glyph (font, 4, funcs, &draw_data);
hb_font_get_glyph_shape (font, 4, funcs, &draw_data);
char expected[] = "M332,468L197,468L197,0L109,0L109,468L15,468L15,509L109,539"
"L109,570Q109,674 155,720Q201,765 283,765Q315,765 342,760"
"Q368,754 387,747L364,678Q348,683 327,688Q306,693 284,693"
@ -363,13 +363,13 @@ test_hb_draw_ttf_parser_tests (void)
}
{
draw_data.consumed = 0;
hb_font_draw_glyph (font, 5, funcs, &draw_data);
hb_font_get_glyph_shape (font, 5, funcs, &draw_data);
char expected[] = "";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
}
{
draw_data.consumed = 0;
hb_font_draw_glyph (font, 6, funcs, &draw_data);
hb_font_get_glyph_shape (font, 6, funcs, &draw_data);
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"
@ -385,7 +385,7 @@ test_hb_draw_ttf_parser_tests (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 1, funcs, &draw_data);
hb_font_get_glyph_shape (font, 1, funcs, &draw_data);
char expected[] = "M0,0C100,0 150,-20 250,-20C350,-20 400,0 500,0C500,100 520,150 520,250"
"C520,350 500,400 500,500C400,500 350,520 250,520C150,520 100,500 0,500"
"C0,400 -20,350 -20,250C-20,150 0,100 0,0ZM50,50C50,130 34,170 34,250"
@ -402,7 +402,7 @@ test_hb_draw_ttf_parser_tests (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 1, funcs, &draw_data);
hb_font_get_glyph_shape (font, 1, funcs, &draw_data);
char expected[] = "M82,0L164,0L164,486L82,486L82,0Z"
"M124,586C156,586 181,608 181,639C181,671 156,692 124,692"
"C92,692 67,671 67,639C67,608 92,586 124,586Z";
@ -429,7 +429,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
/* should get a path for the glyph */
draw_data.consumed = 0;
hb_font_draw_glyph (font, 37, funcs, &draw_data);
hb_font_get_glyph_shape (font, 37, funcs, &draw_data);
char expected[] = "M201,1462L614,1462Q905,1462 1035,1375Q1165,1288 1165,1100"
"Q1165,970 1093,886Q1020,801 881,776L881,766Q1214,709 1214,416"
"Q1214,220 1082,110Q949,0 711,0L201,0L201,1462ZM371,836L651,836"
@ -440,7 +440,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
/* should get a path for the glyph */
draw_data.consumed = 0;
hb_font_draw_glyph (font, 171, funcs, &draw_data);
hb_font_get_glyph_shape (font, 171, funcs, &draw_data);
char expected2[] = "M639,-20Q396,-20 256,128Q115,276 115,539Q115,804 246,960Q376,1116 596,1116"
"Q802,1116 922,981Q1042,845 1042,623L1042,518L287,518Q292,325 385,225"
"Q477,125 645,125Q822,125 995,199L995,51Q907,13 829,-3Q750,-20 639,-20Z"
@ -466,7 +466,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
/* should resolve composite glyphs recursively */
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M581,274L443,274Q409,274 384,259Q359,243 348,219Q336,194 340,166"
"Q343,138 365,111L468,-13Q470,-10 473,-6Q475,-3 477,0L253,0Q225,0 203,8"
"Q180,15 168,32Q155,48 155,73L155,269L50,269L50,73Q50,24 69,-10"
@ -482,7 +482,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
/* should transform points of a composite glyph */
draw_data.consumed = 0;
hb_font_draw_glyph (font, 2, funcs, &draw_data); /* 2 == arAlef.fina */
hb_font_get_glyph_shape (font, 2, funcs, &draw_data); /* 2 == arAlef.fina */
char expected2[] = "M155,624L155,84Q150,90 146,95Q141,99 136,105"
"L292,105L292,0L156,0Q128,0 104,14Q79,27 65,51"
"Q50,74 50,104L50,624L155,624ZM282,105L312,105"
@ -498,7 +498,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 5, funcs, &draw_data);
hb_font_get_glyph_shape (font, 5, funcs, &draw_data);
char expected[] = "M90,0L258,0C456,0 564,122 564,331C564,539 456,656 254,656L90,656L90,0Z"
"M173,68L173,588L248,588C401,588 478,496 478,331C478,165 401,68 248,68L173,68Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
@ -513,7 +513,7 @@ test_hb_draw_font_kit_glyphs_tests (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 1, funcs, &draw_data);
hb_font_get_glyph_shape (font, 1, funcs, &draw_data);
char expected[] = "M139,390C175,390 205,419 205,459C205,501 175,530 139,530C103,530 73,501 73,459"
"C73,419 103,390 139,390ZM139,-13C175,-13 205,15 205,56C205,97 175,127 139,127"
"C103,127 73,97 73,56C73,15 103,-13 139,-13Z";
@ -558,7 +558,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M371,-102L371,539L914,539L914,-27Q914,-102 840,-102"
"Q796,-102 755,-98L742,-59Q790,-66 836,-66Q871,-66 871,-31L871,504"
"L414,504L414,-102L371,-102ZM203,-94Q138,-94 86,-90L74,-52"
@ -603,7 +603,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M371,-102L371,539L914,539L914,-27Q914,-102 840,-102Q796,-102 755,-98"
"L742,-59Q790,-66 836,-66Q871,-66 871,-31L871,504L414,504L414,-102"
"L371,-102ZM203,-94Q138,-94 86,-90L74,-52Q137,-59 188,-59Q211,-59 222,-46"
@ -647,7 +647,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M371,-102L371,539L914,539L914,-27Q914,-102 840,-102Q796,-102 755,-98"
"L742,-59Q790,-66 836,-66Q871,-66 871,-31L871,504L414,504L414,-102"
"L371,-102ZM203,-94Q138,-94 86,-90L74,-52Q137,-59 188,-59Q211,-59 222,-46"
@ -694,7 +694,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M246,15C188,15 147,27 101,68L142,23L117,117C111,143 96,149 81,149"
"C65,149 56,141 52,126C71,40 137,-13 244,-13C348,-13 436,46 436,156"
"C436,229 405,295 271,349L247,359C160,393 119,439 119,506"
@ -718,7 +718,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M251,36C206,36 165,42 118,61L176,21L161,99C151,152 129,167 101,167"
"C78,167 61,155 51,131C54,43 133,-14 247,-14C388,-14 474,64 474,171"
"C474,258 430,321 294,370L257,383C188,406 150,438 150,499"
@ -743,7 +743,7 @@ test_hb_draw_font_kit_variations_tests (void)
hb_buffer_destroy (buffer);
draw_data.consumed = 0;
hb_font_draw_glyph (font, codepoint, funcs, &draw_data);
hb_font_get_glyph_shape (font, codepoint, funcs, &draw_data);
char expected[] = "M258,38C197,38 167,48 118,71L192,19L183,103C177,155 155,174 115,174"
"C89,174 64,161 51,125C52,36 124,-16 258,-16C417,-16 513,67 513,175"
"C513,278 457,328 322,388L289,403C232,429 203,452 203,500C203,562 244,589 301,589"
@ -778,7 +778,7 @@ test_hb_draw_estedad_vf (void)
hb_font_set_variations (font, &var, 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 156, funcs, &draw_data);
hb_font_get_glyph_shape (font, 156, funcs, &draw_data);
/* Skip empty path where all the points of a path are equal */
char expected[] = "M150,1158L182,1158Q256,1158 317,1170Q377,1182 421,1213L421,430L521,430"
"L521,1490L421,1490L421,1320Q393,1279 344,1262Q294,1244 182,1244L150,1244"
@ -788,7 +788,7 @@ test_hb_draw_estedad_vf (void)
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 180, funcs, &draw_data);
hb_font_get_glyph_shape (font, 180, funcs, &draw_data);
/* Skip empty path where all the points of a path are equal */
char expected2[] = "M120,693Q120,545 177,414Q233,282 333,182Q433,81 567,24"
"Q701,-33 856,-33Q1010,-33 1144,24Q1277,81 1377,182Q1477,282 1534,414"
@ -808,7 +808,7 @@ test_hb_draw_estedad_vf (void)
g_assert_cmpmem (str, draw_data.consumed, expected2, sizeof (expected2) - 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 262, funcs, &draw_data);
hb_font_get_glyph_shape (font, 262, funcs, &draw_data);
/* Skip empty path where all the points of a path are equal */
char expected3[] = "M422,598Q495,598 545,548Q595,498 595,426Q595,353 545,303Q494,252 422,252"
"Q350,252 300,303Q250,353 250,426Q250,499 300,549Q349,598 422,598ZM422,698"
@ -838,7 +838,7 @@ test_hb_draw_stroking (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 6, funcs, &draw_data);
hb_font_get_glyph_shape (font, 6, funcs, &draw_data);
/* Skip empty path where all the points of a path are equal */
char expected[] = "M436,1522Q436,1280 531,1060Q625,839 784,680Q943,521 1164,427Q1384,332 1626,332"
"Q1868,332 2089,427Q2309,521 2468,680Q2627,839 2722,1060Q2816,1280 2816,1522"
@ -853,7 +853,7 @@ test_hb_draw_stroking (void)
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 7, funcs, &draw_data);
hb_font_get_glyph_shape (font, 7, funcs, &draw_data);
char expected2[] = "M436,1522Q436,1280 531,1060Q625,839 784,680Q943,521 1164,427"
"Q1384,332 1626,332Q1868,332 2089,427Q2309,521 2468,680"
"Q2627,839 2722,1060Q2816,1280 2816,1522Q2816,1764 2722,1985"
@ -879,14 +879,14 @@ test_hb_draw_stroking (void)
hb_face_destroy (face);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 4, funcs, &draw_data);
hb_font_get_glyph_shape (font, 4, funcs, &draw_data);
/* Skip empty path in CFF */
char expected[] = "M106,372C106,532 237,662 397,662C557,662 688,532 688,372C688,212 557,81 397,81C237,81 106,212 106,372Z"
"M62,373C62,188 212,39 397,39C582,39 731,188 731,373C731,558 582,708 397,708C212,708 62,558 62,373Z";
g_assert_cmpmem (str, draw_data.consumed, expected, sizeof (expected) - 1);
draw_data.consumed = 0;
hb_font_draw_glyph (font, 5, funcs, &draw_data);
hb_font_get_glyph_shape (font, 5, funcs, &draw_data);
/* Fold consequent move-to commands */
char expected2[] = "M106,372C106,532 237,662 397,662C557,662 688,532 688,372"
"C688,212 557,81 397,81C237,81 106,212 106,372ZM62,373"

View File

@ -164,7 +164,7 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
hb_ot_var_normalize_coords (face, 0, NULL, NULL);
hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
hb_font_draw_glyph (font, cp, funcs, NULL);
hb_font_get_glyph_shape (font, cp, funcs, NULL);
hb_draw_funcs_destroy (funcs);
hb_set_destroy (set);

View File

@ -154,7 +154,7 @@ extern "C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size)
hb_set_t *set = hb_set_create ();
for (unsigned gid = 0; gid < glyph_count; ++gid)
{
hb_font_draw_glyph (font, gid, funcs, &draw_data);
hb_font_get_glyph_shape (font, gid, funcs, &draw_data);
assert (!draw_data.is_open);
/* Glyph extents also may practices the similar path, call it now that is related */