(root)/
harfbuzz-8.3.0/
test/
api/
test-font.c
       1  /*
       2   * Copyright © 2011  Google, Inc.
       3   *
       4   *  This is part of HarfBuzz, a text shaping library.
       5   *
       6   * Permission is hereby granted, without written agreement and without
       7   * license or royalty fees, to use, copy, modify, and distribute this
       8   * software and its documentation for any purpose, provided that the
       9   * above copyright notice and the following two paragraphs appear in
      10   * all copies of this software.
      11   *
      12   * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
      13   * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
      14   * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
      15   * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
      16   * DAMAGE.
      17   *
      18   * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
      19   * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
      20   * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
      21   * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
      22   * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
      23   *
      24   * Google Author(s): Behdad Esfahbod
      25   */
      26  
      27  #include "hb-test.h"
      28  
      29  /* Unit tests for hb-font.h */
      30  
      31  
      32  static const char test_data[] = "test\0data";
      33  
      34  
      35  static void
      36  test_face_empty (void)
      37  {
      38    hb_face_t *created_from_empty;
      39    hb_face_t *created_from_null;
      40  
      41    g_assert (hb_face_get_empty ());
      42  
      43    created_from_empty = hb_face_create (hb_blob_get_empty (), 0);
      44    g_assert (hb_face_get_empty () != created_from_empty);
      45  
      46    created_from_null = hb_face_create (NULL, 0);
      47    g_assert (hb_face_get_empty () != created_from_null);
      48  
      49    g_assert (hb_face_reference_table (hb_face_get_empty (), HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
      50  
      51    g_assert_cmpint (hb_face_get_upem (hb_face_get_empty ()), ==, 1000);
      52  
      53    hb_face_destroy (created_from_null);
      54    hb_face_destroy (created_from_empty);
      55  }
      56  
      57  static void
      58  test_face_create (void)
      59  {
      60    hb_face_t *face;
      61    hb_blob_t *blob;
      62  
      63    blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
      64    face = hb_face_create (blob, 0);
      65    hb_blob_destroy (blob);
      66  
      67    g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
      68  
      69    g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
      70  
      71    hb_face_destroy (face);
      72  }
      73  
      74  
      75  static void
      76  free_up (void *user_data)
      77  {
      78    int *freed = (int *) user_data;
      79  
      80    g_assert (!*freed);
      81  
      82    (*freed)++;
      83  }
      84  
      85  static hb_blob_t *
      86  get_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void *user_data HB_UNUSED)
      87  {
      88    if (tag == HB_TAG ('a','b','c','d'))
      89      return hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
      90  
      91    return hb_blob_get_empty ();
      92  }
      93  
      94  static void
      95  test_face_createfortables (void)
      96  {
      97    hb_face_t *face;
      98    hb_blob_t *blob;
      99    const char *data;
     100    unsigned int len;
     101    int freed = 0;
     102  
     103    face = hb_face_create_for_tables (get_table, &freed, free_up);
     104    g_assert (!freed);
     105  
     106    g_assert (hb_face_reference_table (face, HB_TAG ('h','e','a','d')) == hb_blob_get_empty ());
     107  
     108    blob = hb_face_reference_table (face, HB_TAG ('a','b','c','d'));
     109    g_assert (blob != hb_blob_get_empty ());
     110  
     111    data = hb_blob_get_data (blob, &len);
     112    g_assert_cmpint (len, ==, sizeof (test_data));
     113    g_assert (0 == memcmp (data, test_data, sizeof (test_data)));
     114    hb_blob_destroy (blob);
     115  
     116    g_assert_cmpint (hb_face_get_upem (face), ==, 1000);
     117  
     118    hb_face_destroy (face);
     119    g_assert (freed);
     120  }
     121  
     122  static void
     123  _test_font_nil_funcs (hb_font_t *font)
     124  {
     125    hb_codepoint_t glyph;
     126    hb_position_t x, y;
     127    hb_glyph_extents_t extents;
     128    unsigned int upem = hb_face_get_upem (hb_font_get_face (font));
     129  
     130    x = y = 13;
     131    g_assert (!hb_font_get_glyph_contour_point (font, 17, 2, &x, &y));
     132    g_assert_cmpint (x, ==, 0);
     133    g_assert_cmpint (y, ==, 0);
     134  
     135    x = hb_font_get_glyph_h_advance (font, 17);
     136    g_assert_cmpint (x, ==, upem);
     137  
     138    extents.x_bearing = extents.y_bearing = 13;
     139    extents.width = extents.height = 15;
     140    hb_font_get_glyph_extents (font, 17, &extents);
     141    g_assert_cmpint (extents.x_bearing, ==, 0);
     142    g_assert_cmpint (extents.y_bearing, ==, 0);
     143    g_assert_cmpint (extents.width, ==, 0);
     144    g_assert_cmpint (extents.height, ==, 0);
     145  
     146    glyph = 3;
     147    g_assert (!hb_font_get_glyph (font, 17, 2, &glyph));
     148    g_assert_cmpint (glyph, ==, 0);
     149  }
     150  
     151  static void
     152  _test_fontfuncs_nil (hb_font_funcs_t *ffuncs)
     153  {
     154    hb_blob_t *blob;
     155    hb_face_t *face;
     156    hb_font_t *font;
     157    hb_font_t *subfont;
     158    int freed = 0;
     159  
     160    blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
     161    face = hb_face_create (blob, 0);
     162    hb_blob_destroy (blob);
     163    g_assert (!hb_face_is_immutable (face));
     164    font = hb_font_create (face);
     165    g_assert (font);
     166    g_assert (hb_face_is_immutable (face));
     167    hb_face_destroy (face);
     168  
     169  
     170    hb_font_set_funcs (font, ffuncs, &freed, free_up);
     171    g_assert_cmpint (freed, ==, 0);
     172  
     173    _test_font_nil_funcs (font);
     174  
     175    subfont = hb_font_create_sub_font (font);
     176    g_assert (subfont);
     177  
     178    g_assert_cmpint (freed, ==, 0);
     179    hb_font_destroy (font);
     180    g_assert_cmpint (freed, ==, 0);
     181  
     182    _test_font_nil_funcs (subfont);
     183  
     184    hb_font_destroy (subfont);
     185    g_assert_cmpint (freed, ==, 1);
     186  }
     187  
     188  static void
     189  test_fontfuncs_empty (void)
     190  {
     191    g_assert (hb_font_funcs_get_empty ());
     192    g_assert (hb_font_funcs_is_immutable (hb_font_funcs_get_empty ()));
     193    _test_fontfuncs_nil (hb_font_funcs_get_empty ());
     194  }
     195  
     196  static void
     197  test_fontfuncs_nil (void)
     198  {
     199    hb_font_funcs_t *ffuncs;
     200  
     201    ffuncs = hb_font_funcs_create ();
     202  
     203    g_assert (!hb_font_funcs_is_immutable (ffuncs));
     204    _test_fontfuncs_nil (hb_font_funcs_get_empty ());
     205  
     206    hb_font_funcs_destroy (ffuncs);
     207  }
     208  
     209  static hb_bool_t
     210  contour_point_func1 (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED,
     211  		     hb_codepoint_t glyph, unsigned int point_index HB_UNUSED,
     212  		     hb_position_t *x, hb_position_t *y,
     213  		     void *user_data HB_UNUSED)
     214  {
     215    if (glyph == 1) {
     216      *x = 2;
     217      *y = 3;
     218      return TRUE;
     219    }
     220    if (glyph == 2) {
     221      *x = 4;
     222      *y = 5;
     223      return TRUE;
     224    }
     225  
     226    return FALSE;
     227  }
     228  
     229  static hb_bool_t
     230  contour_point_func2 (hb_font_t *font, void *font_data HB_UNUSED,
     231  		     hb_codepoint_t glyph, unsigned int point_index,
     232  		     hb_position_t *x, hb_position_t *y,
     233  		     void *user_data HB_UNUSED)
     234  {
     235    if (glyph == 1) {
     236      *x = 6;
     237      *y = 7;
     238      return TRUE;
     239    }
     240  
     241    return hb_font_get_glyph_contour_point (hb_font_get_parent (font),
     242  					  glyph, point_index, x, y);
     243  }
     244  
     245  static hb_position_t
     246  glyph_h_advance_func1 (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED,
     247  		       hb_codepoint_t glyph,
     248  		       void *user_data HB_UNUSED)
     249  {
     250    if (glyph == 1)
     251      return 8;
     252  
     253    return 0;
     254  }
     255  
     256  static void
     257  test_fontfuncs_subclassing (void)
     258  {
     259    hb_blob_t *blob;
     260    hb_face_t *face;
     261  
     262    hb_font_funcs_t *ffuncs1;
     263    hb_font_funcs_t *ffuncs2;
     264  
     265    hb_font_t *font1;
     266    hb_font_t *font2;
     267    hb_font_t *font3;
     268  
     269    hb_position_t x;
     270    hb_position_t y;
     271  
     272    blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
     273    face = hb_face_create (blob, 0);
     274    hb_blob_destroy (blob);
     275    font1 = hb_font_create (face);
     276    hb_face_destroy (face);
     277    hb_font_set_scale (font1, 10, 10);
     278  
     279    /* setup font1 */
     280    ffuncs1 = hb_font_funcs_create ();
     281    hb_font_funcs_set_glyph_contour_point_func (ffuncs1, contour_point_func1, NULL, NULL);
     282    hb_font_funcs_set_glyph_h_advance_func (ffuncs1, glyph_h_advance_func1, NULL, NULL);
     283    hb_font_set_funcs (font1, ffuncs1, NULL, NULL);
     284    hb_font_funcs_destroy (ffuncs1);
     285  
     286    x = y = 1;
     287    g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 1, 2, HB_DIRECTION_LTR, &x, &y));
     288    g_assert_cmpint (x, ==, 2);
     289    g_assert_cmpint (y, ==, 3);
     290    g_assert (hb_font_get_glyph_contour_point_for_origin (font1, 2, 5, HB_DIRECTION_LTR, &x, &y));
     291    g_assert_cmpint (x, ==, 4);
     292    g_assert_cmpint (y, ==, 5);
     293    g_assert (!hb_font_get_glyph_contour_point_for_origin (font1, 3, 7, HB_DIRECTION_RTL, &x, &y));
     294    g_assert_cmpint (x, ==, 0);
     295    g_assert_cmpint (y, ==, 0);
     296    x = hb_font_get_glyph_h_advance (font1, 1);
     297    g_assert_cmpint (x, ==, 8);
     298    x = hb_font_get_glyph_h_advance (font1, 2);
     299    g_assert_cmpint (x, ==, 0);
     300  
     301    /* creating sub-font doesn't make the parent font immutable;
     302     * making a font immutable however makes it's lineage immutable.
     303     */
     304    font2 = hb_font_create_sub_font (font1);
     305    font3 = hb_font_create_sub_font (font2);
     306    g_assert (!hb_font_is_immutable (font1));
     307    g_assert (!hb_font_is_immutable (font2));
     308    g_assert (!hb_font_is_immutable (font3));
     309    hb_font_make_immutable (font3);
     310    g_assert (hb_font_is_immutable (font1));
     311    g_assert (hb_font_is_immutable (font2));
     312    g_assert (hb_font_is_immutable (font3));
     313    hb_font_destroy (font2);
     314    hb_font_destroy (font3);
     315  
     316    font2 = hb_font_create_sub_font (font1);
     317    hb_font_destroy (font1);
     318  
     319    /* setup font2 to override some funcs */
     320    ffuncs2 = hb_font_funcs_create ();
     321    hb_font_funcs_set_glyph_contour_point_func (ffuncs2, contour_point_func2, NULL, NULL);
     322    hb_font_set_funcs (font2, ffuncs2, NULL, NULL);
     323    hb_font_funcs_destroy (ffuncs2);
     324  
     325    x = y = 1;
     326    g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 1, 2, HB_DIRECTION_LTR, &x, &y));
     327    g_assert_cmpint (x, ==, 6);
     328    g_assert_cmpint (y, ==, 7);
     329    g_assert (hb_font_get_glyph_contour_point_for_origin (font2, 2, 5, HB_DIRECTION_RTL, &x, &y));
     330    g_assert_cmpint (x, ==, 4);
     331    g_assert_cmpint (y, ==, 5);
     332    g_assert (!hb_font_get_glyph_contour_point_for_origin (font2, 3, 7, HB_DIRECTION_LTR, &x, &y));
     333    g_assert_cmpint (x, ==, 0);
     334    g_assert_cmpint (y, ==, 0);
     335    x = hb_font_get_glyph_h_advance (font2, 1);
     336    g_assert_cmpint (x, ==, 8);
     337    x = hb_font_get_glyph_h_advance (font2, 2);
     338    g_assert_cmpint (x, ==, 0);
     339  
     340    /* setup font3 to override scale */
     341    font3 = hb_font_create_sub_font (font2);
     342    hb_font_set_scale (font3, 20, 30);
     343  
     344    x = y = 1;
     345    g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 1, 2, HB_DIRECTION_RTL, &x, &y));
     346    g_assert_cmpint (x, ==, 6*2);
     347    g_assert_cmpint (y, ==, 7*3);
     348    g_assert (hb_font_get_glyph_contour_point_for_origin (font3, 2, 5, HB_DIRECTION_LTR, &x, &y));
     349    g_assert_cmpint (x, ==, 4*2);
     350    g_assert_cmpint (y, ==, 5*3);
     351    g_assert (!hb_font_get_glyph_contour_point_for_origin (font3, 3, 7, HB_DIRECTION_LTR, &x, &y));
     352    g_assert_cmpint (x, ==, 0*2);
     353    g_assert_cmpint (y, ==, 0*3);
     354    x = hb_font_get_glyph_h_advance (font3, 1);
     355    g_assert_cmpint (x, ==, 8*2);
     356    x = hb_font_get_glyph_h_advance (font3, 2);
     357    g_assert_cmpint (x, ==, 0*2);
     358  
     359  
     360    hb_font_destroy (font3);
     361    hb_font_destroy (font2);
     362  }
     363  
     364  static hb_bool_t
     365  nominal_glyph_func (hb_font_t *font HB_UNUSED,
     366  		    void *font_data HB_UNUSED,
     367  		    hb_codepoint_t unicode HB_UNUSED,
     368  		    hb_codepoint_t *glyph,
     369  		    void *user_data HB_UNUSED)
     370  {
     371    *glyph = 0;
     372    return FALSE;
     373  }
     374  
     375  static unsigned int
     376  nominal_glyphs_func (hb_font_t *font HB_UNUSED,
     377  		     void *font_data HB_UNUSED,
     378  		     unsigned int count HB_UNUSED,
     379  		     const hb_codepoint_t *first_unicode HB_UNUSED,
     380  		     unsigned int unicode_stride HB_UNUSED,
     381  		     hb_codepoint_t *first_glyph HB_UNUSED,
     382  		     unsigned int glyph_stride HB_UNUSED,
     383  		     void *user_data HB_UNUSED)
     384  {
     385    return 0;
     386  }
     387  
     388  static void
     389  test_fontfuncs_parallels (void)
     390  {
     391    hb_blob_t *blob;
     392    hb_face_t *face;
     393  
     394    hb_font_funcs_t *ffuncs1;
     395    hb_font_funcs_t *ffuncs2;
     396  
     397    hb_font_t *font0;
     398    hb_font_t *font1;
     399    hb_font_t *font2;
     400    hb_codepoint_t glyph;
     401  
     402    blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
     403    face = hb_face_create (blob, 0);
     404    hb_blob_destroy (blob);
     405    font0 = hb_font_create (face);
     406    hb_face_destroy (face);
     407  
     408    /* setup sub-font1 */
     409    font1 = hb_font_create_sub_font (font0);
     410    hb_font_destroy (font0);
     411    ffuncs1 = hb_font_funcs_create ();
     412    hb_font_funcs_set_nominal_glyph_func (ffuncs1, nominal_glyph_func, NULL, NULL);
     413    hb_font_set_funcs (font1, ffuncs1, NULL, NULL);
     414    hb_font_funcs_destroy (ffuncs1);
     415  
     416    /* setup sub-font2 */
     417    font2 = hb_font_create_sub_font (font1);
     418    hb_font_destroy (font1);
     419    ffuncs2 = hb_font_funcs_create ();
     420    hb_font_funcs_set_nominal_glyphs_func (ffuncs1, nominal_glyphs_func, NULL, NULL);
     421    hb_font_set_funcs (font2, ffuncs2, NULL, NULL);
     422    hb_font_funcs_destroy (ffuncs2);
     423  
     424    /* Just test that calling get_nominal_glyph doesn't infinite-loop. */
     425    hb_font_get_nominal_glyph (font2, 0x0020u, &glyph);
     426  
     427    hb_font_destroy (font2);
     428  }
     429  
     430  static void
     431  test_font_empty (void)
     432  {
     433    hb_font_t *created_from_empty;
     434    hb_font_t *created_from_null;
     435    hb_font_t *created_sub_from_null;
     436  
     437    g_assert (hb_font_get_empty ());
     438  
     439    created_from_empty = hb_font_create (hb_face_get_empty ());
     440    g_assert (hb_font_get_empty () != created_from_empty);
     441  
     442    created_from_null = hb_font_create (NULL);
     443    g_assert (hb_font_get_empty () != created_from_null);
     444  
     445    created_sub_from_null = hb_font_create_sub_font (NULL);
     446    g_assert (hb_font_get_empty () != created_sub_from_null);
     447  
     448    g_assert (hb_font_is_immutable (hb_font_get_empty ()));
     449  
     450    g_assert (hb_font_get_face (hb_font_get_empty ()) == hb_face_get_empty ());
     451    g_assert (hb_font_get_parent (hb_font_get_empty ()) == NULL);
     452  
     453    hb_font_destroy (created_sub_from_null);
     454    hb_font_destroy (created_from_null);
     455    hb_font_destroy (created_from_empty);
     456  }
     457  
     458  static void
     459  test_font_properties (void)
     460  {
     461    hb_blob_t *blob;
     462    hb_face_t *face;
     463    hb_font_t *font;
     464    hb_font_t *subfont;
     465    int x_scale, y_scale;
     466    unsigned int x_ppem, y_ppem;
     467    unsigned int upem;
     468  
     469    blob = hb_blob_create (test_data, sizeof (test_data), HB_MEMORY_MODE_READONLY, NULL, NULL);
     470    face = hb_face_create (blob, 0);
     471    hb_blob_destroy (blob);
     472    font = hb_font_create (face);
     473    hb_face_destroy (face);
     474  
     475  
     476    g_assert (hb_font_get_face (font) == face);
     477    g_assert (hb_font_get_parent (font) == hb_font_get_empty ());
     478    subfont = hb_font_create_sub_font (font);
     479    g_assert (hb_font_get_parent (subfont) == font);
     480    hb_font_set_parent(subfont, NULL);
     481    g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
     482    hb_font_set_parent(subfont, font);
     483    g_assert (hb_font_get_parent (subfont) == font);
     484    hb_font_set_parent(subfont, NULL);
     485    hb_font_make_immutable (subfont);
     486    g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
     487    hb_font_set_parent(subfont, font);
     488    g_assert (hb_font_get_parent (subfont) == hb_font_get_empty());
     489    hb_font_destroy (subfont);
     490  
     491  
     492    /* Check scale */
     493  
     494    upem = hb_face_get_upem (hb_font_get_face (font));
     495    hb_font_get_scale (font, NULL, NULL);
     496    x_scale = y_scale = 13;
     497    hb_font_get_scale (font, &x_scale, NULL);
     498    g_assert_cmpint (x_scale, ==, upem);
     499    x_scale = y_scale = 13;
     500    hb_font_get_scale (font, NULL, &y_scale);
     501    g_assert_cmpint (y_scale, ==, upem);
     502    x_scale = y_scale = 13;
     503    hb_font_get_scale (font, &x_scale, &y_scale);
     504    g_assert_cmpint (x_scale, ==, upem);
     505    g_assert_cmpint (y_scale, ==, upem);
     506  
     507    hb_font_set_scale (font, 17, 19);
     508  
     509    x_scale = y_scale = 13;
     510    hb_font_get_scale (font, &x_scale, &y_scale);
     511    g_assert_cmpint (x_scale, ==, 17);
     512    g_assert_cmpint (y_scale, ==, 19);
     513  
     514  
     515    /* Check ppem */
     516  
     517    hb_font_get_ppem (font, NULL, NULL);
     518    x_ppem = y_ppem = 13;
     519    hb_font_get_ppem (font, &x_ppem, NULL);
     520    g_assert_cmpint (x_ppem, ==, 0);
     521    x_ppem = y_ppem = 13;
     522    hb_font_get_ppem (font, NULL, &y_ppem);
     523    g_assert_cmpint (y_ppem, ==, 0);
     524    x_ppem = y_ppem = 13;
     525    hb_font_get_ppem (font, &x_ppem, &y_ppem);
     526    g_assert_cmpint (x_ppem, ==, 0);
     527    g_assert_cmpint (y_ppem, ==, 0);
     528  
     529    hb_font_set_ppem (font, 17, 19);
     530  
     531    x_ppem = y_ppem = 13;
     532    hb_font_get_ppem (font, &x_ppem, &y_ppem);
     533    g_assert_cmpint (x_ppem, ==, 17);
     534    g_assert_cmpint (y_ppem, ==, 19);
     535  
     536    /* Check ptem */
     537    g_assert_cmpint (hb_font_get_ptem (font), ==, 0);
     538    hb_font_set_ptem (font, 42);
     539    g_assert_cmpint (hb_font_get_ptem (font), ==, 42);
     540  
     541  
     542    /* Check immutable */
     543  
     544    g_assert (!hb_font_is_immutable (font));
     545    hb_font_make_immutable (font);
     546    g_assert (hb_font_is_immutable (font));
     547  
     548    hb_font_set_scale (font, 10, 12);
     549    x_scale = y_scale = 13;
     550    hb_font_get_scale (font, &x_scale, &y_scale);
     551    g_assert_cmpint (x_scale, ==, 17);
     552    g_assert_cmpint (y_scale, ==, 19);
     553  
     554    hb_font_set_ppem (font, 10, 12);
     555    x_ppem = y_ppem = 13;
     556    hb_font_get_ppem (font, &x_ppem, &y_ppem);
     557    g_assert_cmpint (x_ppem, ==, 17);
     558    g_assert_cmpint (y_ppem, ==, 19);
     559  
     560  
     561    /* sub_font now */
     562    subfont = hb_font_create_sub_font (font);
     563    hb_font_destroy (font);
     564  
     565    g_assert (hb_font_get_parent (subfont) == font);
     566    g_assert (hb_font_get_face (subfont) == face);
     567  
     568    /* scale */
     569    x_scale = y_scale = 13;
     570    hb_font_get_scale (subfont, &x_scale, &y_scale);
     571    g_assert_cmpint (x_scale, ==, 17);
     572    g_assert_cmpint (y_scale, ==, 19);
     573    hb_font_set_scale (subfont, 10, 12);
     574    x_scale = y_scale = 13;
     575    hb_font_get_scale (subfont, &x_scale, &y_scale);
     576    g_assert_cmpint (x_scale, ==, 10);
     577    g_assert_cmpint (y_scale, ==, 12);
     578    x_scale = y_scale = 13;
     579    hb_font_get_scale (font, &x_scale, &y_scale);
     580    g_assert_cmpint (x_scale, ==, 17);
     581    g_assert_cmpint (y_scale, ==, 19);
     582  
     583    /* ppem */
     584    x_ppem = y_ppem = 13;
     585    hb_font_get_ppem (subfont, &x_ppem, &y_ppem);
     586    g_assert_cmpint (x_ppem, ==, 17);
     587    g_assert_cmpint (y_ppem, ==, 19);
     588    hb_font_set_ppem (subfont, 10, 12);
     589    x_ppem = y_ppem = 13;
     590    hb_font_get_ppem (subfont, &x_ppem, &y_ppem);
     591    g_assert_cmpint (x_ppem, ==, 10);
     592    g_assert_cmpint (y_ppem, ==, 12);
     593    x_ppem = y_ppem = 13;
     594    hb_font_get_ppem (font, &x_ppem, &y_ppem);
     595    g_assert_cmpint (x_ppem, ==, 17);
     596    g_assert_cmpint (y_ppem, ==, 19);
     597  
     598    hb_font_destroy (subfont);
     599  }
     600  
     601  int
     602  main (int argc, char **argv)
     603  {
     604    hb_test_init (&argc, &argv);
     605  
     606    hb_test_add (test_face_empty);
     607    hb_test_add (test_face_create);
     608    hb_test_add (test_face_createfortables);
     609  
     610    hb_test_add (test_fontfuncs_empty);
     611    hb_test_add (test_fontfuncs_nil);
     612    hb_test_add (test_fontfuncs_subclassing);
     613    hb_test_add (test_fontfuncs_parallels);
     614  
     615    hb_test_add (test_font_empty);
     616    hb_test_add (test_font_properties);
     617  
     618    return hb_test_run();
     619  }