static void
test_face_empty (void)
{
+ hb_face_t *created_from_empty;
+ hb_face_t *created_from_null;
+
g_assert (hb_face_get_empty ());
- g_assert (hb_face_get_empty () == hb_face_create (hb_blob_get_empty (), 0));
- g_assert (hb_face_get_empty () == hb_face_create (NULL, 0));
+
+ created_from_empty = hb_face_create (hb_blob_get_empty (), 0);
+ g_assert (hb_face_get_empty () != created_from_empty);
+
+ created_from_null = hb_face_create (NULL, 0);
+ g_assert (hb_face_get_empty () != created_from_null);
g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
g_assert_cmpint (hb_face_get_upem (hb_face_get_empty ()), ==, 1000);
+
+ hb_face_destroy (created_from_null);
+ hb_face_destroy (created_from_empty);
}
static void
hb_codepoint_t glyph;
hb_position_t x, y;
hb_glyph_extents_t extents;
+ unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
x = y = 13;
g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
g_assert_cmpint (y, ==, 0);
x = hb_font_get_glyph_h_advance (font, 17);
- g_assert_cmpint (x, ==, 0);
+ g_assert_cmpint (x, ==, upem);
extents.x_bearing = extents.y_bearing = 13;
extents.width = extents.height = 15;
x = hb_font_get_glyph_h_advance (font1, 2);
g_assert_cmpint (x, ==, 0);
-
+ /* creating sub-font doesn't make the parent font immutable;
+ * making a font immutable however makes it's lineage immutable.
+ */
font2 = hb_font_create_sub_font (font1);
+ font3 = hb_font_create_sub_font (font2);
+ g_assert (!hb_font_is_immutable (font1));
+ g_assert (!hb_font_is_immutable (font2));
+ g_assert (!hb_font_is_immutable (font3));
+ hb_font_make_immutable (font3);
g_assert (hb_font_is_immutable (font1));
+ g_assert (hb_font_is_immutable (font2));
+ g_assert (hb_font_is_immutable (font3));
+ hb_font_destroy (font2);
+ hb_font_destroy (font3);
+
+ font2 = hb_font_create_sub_font (font1);
hb_font_destroy (font1);
/* setup font2 to override some funcs */
x = hb_font_get_glyph_h_advance (font2, 2);
g_assert_cmpint (x, ==, 0);
-
- font3 = hb_font_create_sub_font (font2);
- g_assert (hb_font_is_immutable (font2));
- hb_font_destroy (font2);
-
/* setup font3 to override scale */
+ font3 = hb_font_create_sub_font (font2);
hb_font_set_scale (font3, 20, 30);
x = y = 1;
static void
test_font_empty (void)
{
+ hb_font_t *created_from_empty;
+ hb_font_t *created_from_null;
+ hb_font_t *created_sub_from_null;
+
g_assert (hb_font_get_empty ());
- g_assert (hb_font_get_empty () == hb_font_create (hb_face_get_empty ()));
- g_assert (hb_font_get_empty () == hb_font_create (NULL));
- g_assert (hb_font_get_empty () == hb_font_create_sub_font (NULL));
+
+ created_from_empty = hb_font_create (hb_face_get_empty ());
+ g_assert (hb_font_get_empty () != created_from_empty);
+
+ created_from_null = hb_font_create (NULL);
+ g_assert (hb_font_get_empty () != created_from_null);
+
+ created_sub_from_null = hb_font_create_sub_font (NULL);
+ g_assert (hb_font_get_empty () != created_sub_from_null);
+
g_assert (hb_font_is_immutable (hb_font_get_empty ()));
g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
g_assert (hb_font_get_parent (hb_font_get_empty ()) == NULL);
+
+ hb_font_destroy (created_sub_from_null);
+ hb_font_destroy (created_from_null);
+ hb_font_destroy (created_from_empty);
}
static void
hb_font_t *subfont;
int x_scale, y_scale;
unsigned int x_ppem, y_ppem;
+ unsigned int upem;
blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
face = hb_face_create (blob, 0);
g_assert (hb_font_get_face (font) == face);
- g_assert (hb_font_get_parent (font) == NULL);
+ g_assert (hb_font_get_parent (font) == hb_font_get_empty ());
+ subfont = hb_font_create_sub_font (font);
+ g_assert (hb_font_get_parent (subfont) == font);
+ hb_font_set_parent(subfont, NULL);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_set_parent(subfont, font);
+ g_assert (hb_font_get_parent (subfont) == font);
+ hb_font_set_parent(subfont, NULL);
+ hb_font_make_immutable (subfont);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_set_parent(subfont, font);
+ g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
+ hb_font_destroy (subfont);
/* Check scale */
+ upem = hb_face_get_upem (hb_font_get_face (font));
hb_font_get_scale (font, NULL, NULL);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, NULL);
- g_assert_cmpint (x_scale, ==, 0);
+ g_assert_cmpint (x_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, NULL, &y_scale);
- g_assert_cmpint (y_scale, ==, 0);
+ g_assert_cmpint (y_scale, ==, upem);
x_scale = y_scale = 13;
hb_font_get_scale (font, &x_scale, &y_scale);
- g_assert_cmpint (x_scale, ==, 0);
- g_assert_cmpint (y_scale, ==, 0);
+ g_assert_cmpint (x_scale, ==, upem);
+ g_assert_cmpint (y_scale, ==, upem);
hb_font_set_scale (font, 17, 19);