test-aat-layout.c 3.0 KB
Newer Older
E
Ebrahim Byagowi 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/*
 * Copyright © 2018  Google, Inc.
 *
 *  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-test.h"

E
Ebrahim Byagowi 已提交
27
#include <hb-ot.h>
E
Ebrahim Byagowi 已提交
28

E
Ebrahim Byagowi 已提交
29
/* Unit tests for hb-aat.h */
E
Ebrahim Byagowi 已提交
30 31 32 33

static void
test_aat_get_feature_settings (void)
{
E
Ebrahim Byagowi 已提交
34
  hb_aat_feature_setting_t default_setting;
35
  hb_aat_feature_type_selector_t records[3];
E
Ebrahim Byagowi 已提交
36 37 38 39
  unsigned int count = 3;

  hb_face_t *face = hb_test_open_font_file ("fonts/aat-feat.ttf");

E
Ebrahim Byagowi 已提交
40
  g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, 18, &default_setting,
E
Ebrahim Byagowi 已提交
41 42
							0, &count, records));
  g_assert_cmpuint (3, ==, count);
E
Ebrahim Byagowi 已提交
43
  g_assert_cmpuint (0, ==, default_setting);
E
Ebrahim Byagowi 已提交
44 45 46 47 48 49 50 51 52 53 54

  g_assert_cmpuint (0, ==, records[0].setting);
  g_assert_cmpuint (294, ==, records[0].name_id);

  g_assert_cmpuint (1, ==, records[1].setting);
  g_assert_cmpuint (295, ==, records[1].name_id);

  g_assert_cmpuint (2, ==, records[2].setting);
  g_assert_cmpuint (296, ==, records[2].name_id);

  count = 3;
E
Ebrahim Byagowi 已提交
55
  g_assert_cmpuint (4, ==, hb_aat_layout_get_feature_settings (face, 18, &default_setting,
E
Ebrahim Byagowi 已提交
56 57
							3, &count, records));
  g_assert_cmpuint (1, ==, count);
E
Ebrahim Byagowi 已提交
58
  g_assert_cmpuint (0, ==, default_setting);
E
Ebrahim Byagowi 已提交
59 60 61 62

  g_assert_cmpuint (3, ==, records[0].setting);
  g_assert_cmpuint (297, ==, records[0].name_id);

E
Ebrahim Byagowi 已提交
63 64

  count = 1;
E
Ebrahim Byagowi 已提交
65
  g_assert_cmpuint (1, ==, hb_aat_layout_get_feature_settings (face, 14, &default_setting,
E
Ebrahim Byagowi 已提交
66 67
							0, &count, records));
  g_assert_cmpuint (1, ==, count);
68
  g_assert_cmpuint (HB_AAT_FEATURE_NO_DEFAULT_SETTING, ==, default_setting);
E
Ebrahim Byagowi 已提交
69 70 71 72 73

  g_assert_cmpuint (8, ==, records[0].setting);
  g_assert_cmpuint (308, ==, records[0].name_id);


E
Ebrahim Byagowi 已提交
74
  count = 100;
E
Ebrahim Byagowi 已提交
75
  g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (face, 32, NULL,
E
Ebrahim Byagowi 已提交
76 77 78 79 80 81
							0, &count, records));
  g_assert_cmpuint (0, ==, count);

  hb_face_destroy (face);

  hb_face_t *sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
E
Ebrahim Byagowi 已提交
82
  g_assert_cmpuint (0, ==, hb_aat_layout_get_feature_settings (sbix, 100, NULL,
E
Ebrahim Byagowi 已提交
83 84 85 86 87 88 89 90 91 92 93 94 95
							0, &count, records));
  hb_face_destroy (sbix);
}

int
main (int argc, char **argv)
{
  hb_test_init (&argc, &argv);

  hb_test_add (test_aat_get_feature_settings);

  return hb_test_run();
}