mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-25 17:01:17 +01:00
[svg] Add public API
* hb_ot_color_has_svg * hb_ot_color_glyph_svg_create_blob
This commit is contained in:
1 parent
e98af6d1ed
commit
c7a4e3dfb5
10 files changed
+200
-61
No files matched your search
@@ -103,6 +103,7 @@ static hb_face_t *cpal = NULL;
|
||||
static hb_face_t *cbdt = NULL;
|
||||
static hb_face_t *sbix = NULL;
|
||||
static hb_face_t *svg = NULL;
|
||||
static hb_face_t *empty = NULL;
|
||||
|
||||
#define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \
|
||||
const hb_color_t *_colors = (colors); \
|
||||
@@ -203,7 +204,6 @@ test_hb_ot_color_palette_get_flags_v1 (void)
|
||||
static void
|
||||
test_hb_ot_color_palette_get_colors_empty (void)
|
||||
{
|
||||
hb_face_t *empty = hb_face_get_empty ();
|
||||
g_assert_cmpint (hb_ot_color_palette_get_colors (empty, 0, 0, NULL, NULL), ==, 0);
|
||||
}
|
||||
|
||||
@@ -302,8 +302,6 @@ test_hb_ot_color_palette_get_colors_v1 (void)
|
||||
static void
|
||||
test_hb_ot_color_palette_color_get_name_id (void)
|
||||
{
|
||||
hb_face_t *empty = hb_face_get_empty ();
|
||||
|
||||
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 0), ==, HB_NAME_ID_INVALID);
|
||||
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 1), ==, HB_NAME_ID_INVALID);
|
||||
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 2), ==, HB_NAME_ID_INVALID);
|
||||
@@ -349,8 +347,6 @@ test_hb_ot_color_glyph_get_layers (void)
|
||||
static void
|
||||
test_hb_ot_color_has_data (void)
|
||||
{
|
||||
hb_face_t *empty = hb_face_get_empty ();
|
||||
|
||||
g_assert (hb_ot_color_has_layers (empty) == FALSE);
|
||||
g_assert (hb_ot_color_has_layers (cpal_v0) == TRUE);
|
||||
g_assert (hb_ot_color_has_layers (cpal_v1) == TRUE);
|
||||
@@ -366,6 +362,41 @@ test_hb_ot_color_has_data (void)
|
||||
g_assert (hb_ot_color_has_palettes (cbdt) == FALSE);
|
||||
g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
|
||||
g_assert (hb_ot_color_has_palettes (svg) == FALSE);
|
||||
|
||||
g_assert (hb_ot_color_has_svg (empty) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (cpal) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (cbdt) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (sbix) == FALSE);
|
||||
g_assert (hb_ot_color_has_svg (svg) == TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
test_hb_ot_color_svg (void)
|
||||
{
|
||||
hb_codepoint_t start_glyph, end_glyph;
|
||||
hb_blob_t *blob;
|
||||
|
||||
blob = hb_ot_color_glyph_svg_create_blob (svg, 0, &start_glyph, &end_glyph);
|
||||
g_assert (hb_blob_get_length (blob) == 0);
|
||||
g_assert (start_glyph == 0);
|
||||
g_assert (end_glyph == 0);
|
||||
|
||||
blob = hb_ot_color_glyph_svg_create_blob (svg, 1, &start_glyph, &end_glyph);
|
||||
unsigned int length;
|
||||
const char *data = hb_blob_get_data (blob, &length);
|
||||
g_assert_cmpuint (length, ==, 146);
|
||||
g_assert_cmpuint (start_glyph, ==, 1);
|
||||
g_assert_cmpuint (end_glyph, ==, 1);
|
||||
g_assert (strncmp (data, "<?xml", 4) == 0);
|
||||
g_assert (strncmp (data + 140, "</svg>", 5) == 0);
|
||||
hb_blob_destroy (blob);
|
||||
|
||||
blob = hb_ot_color_glyph_svg_create_blob (empty, 0, &start_glyph, &end_glyph);
|
||||
g_assert (hb_blob_get_length (blob) == 0);
|
||||
g_assert (start_glyph == 0);
|
||||
g_assert (end_glyph == 0);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -380,6 +411,7 @@ main (int argc, char **argv)
|
||||
cbdt = hb_test_open_font_file ("fonts/chromacheck-cbdt.ttf");
|
||||
sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
|
||||
svg = hb_test_open_font_file ("fonts/chromacheck-svg.ttf");
|
||||
empty = hb_face_get_empty ();
|
||||
hb_test_add (test_hb_ot_color_palette_get_count);
|
||||
hb_test_add (test_hb_ot_color_palette_get_name_id_empty);
|
||||
hb_test_add (test_hb_ot_color_palette_get_name_id_v0);
|
||||
@@ -393,6 +425,7 @@ main (int argc, char **argv)
|
||||
hb_test_add (test_hb_ot_color_palette_color_get_name_id);
|
||||
hb_test_add (test_hb_ot_color_glyph_get_layers);
|
||||
hb_test_add (test_hb_ot_color_has_data);
|
||||
hb_test_add (test_hb_ot_color_svg);
|
||||
status = hb_test_run();
|
||||
hb_face_destroy (cpal_v0);
|
||||
hb_face_destroy (cpal_v1);
|
||||
|
||||
Reference in new issue
Block a user