Hash :
3ee4ea94
Author :
Date :
2018-12-20T11:26:54
Fix build on older Visual Studio versions (#1499) * src/hb-cff-interp-dict-common.hh: Use ull for unsigned int64_t The llu suffix does not work for older Visual Studio versions (pre-2013), but ull works for all the compilers that we attempt to support. * test/api: Fix build on pre-C99 compilers Ensure variables are declared at the top of the block. * src/hb-dsalgs.hh: Add specialization for hb_is_signed<> for __int8 Pre-Visual Studio 2010 does not consider __int8 (which is typedef'ed to int8_t) to be equivilant to signed char, so the compiler cannot find the corresponding hb_is_signed<> specialization that is needed. The interesting thing is unsigned __int8 is considered to be equivilant to unsigned char, so as the other types (short, int, long) that we look for here, so only the specialization for __int8 is added here. This will fix builds on Visual Studio 2008 at least.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
/*
* 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"
#include <hb.h>
#include <hb-ot.h>
#include <hb-aat.h>
/* Unit tests for hb-aat.h */
static hb_face_t *face;
static hb_face_t *sbix;
static void
test_aat_get_feature_types (void)
{
hb_aat_layout_feature_type_t features[3];
unsigned int count = 3;
g_assert_cmpuint (11, ==, hb_aat_layout_get_feature_types (face, 0, &count, features));
g_assert_cmpuint (1, ==, features[0]);
g_assert_cmpuint (3, ==, features[1]);
g_assert_cmpuint (6, ==, features[2]);
g_assert_cmpuint (258, ==, hb_aat_layout_feature_type_get_name_id (face, features[0]));
g_assert_cmpuint (261, ==, hb_aat_layout_feature_type_get_name_id (face, features[1]));
g_assert_cmpuint (265, ==, hb_aat_layout_feature_type_get_name_id (face, features[2]));
}
static void
test_aat_get_feature_selectors (void)
{
unsigned int default_index;
hb_aat_layout_feature_selector_info_t settings[3];
unsigned int count = 3;
g_assert_cmpuint (4, ==, hb_aat_layout_feature_type_get_selector_infos (face,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE,
0, &count, settings,
&default_index));
g_assert_cmpuint (3, ==, count);
g_assert_cmpuint (0, ==, default_index);
g_assert_cmpuint (0, ==, settings[0].enable);
g_assert_cmpuint (294, ==, settings[0].name_id);
g_assert_cmpuint (1, ==, settings[1].enable);
g_assert_cmpuint (295, ==, settings[1].name_id);
g_assert_cmpuint (2, ==, settings[2].enable);
g_assert_cmpuint (296, ==, settings[2].name_id);
count = 3;
g_assert_cmpuint (4, ==, hb_aat_layout_feature_type_get_selector_infos (face,
HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE,
3, &count, settings,
&default_index));
g_assert_cmpuint (1, ==, count);
g_assert_cmpuint (0, ==, default_index);
g_assert_cmpuint (3, ==, settings[0].enable);
g_assert_cmpuint (297, ==, settings[0].name_id);
count = 1;
g_assert_cmpuint (1, ==, hb_aat_layout_feature_type_get_selector_infos (face,
HB_AAT_LAYOUT_FEATURE_TYPE_TYPOGRAPHIC_EXTRAS,
0, &count, settings,
&default_index));
g_assert_cmpuint (1, ==, count);
g_assert_cmpuint (HB_AAT_LAYOUT_NO_SELECTOR_INDEX, ==, default_index);
g_assert_cmpuint (8, ==, settings[0].enable);
g_assert_cmpuint (308, ==, settings[0].name_id);
count = 100;
g_assert_cmpuint (0, ==, hb_aat_layout_feature_type_get_selector_infos (face, HB_AAT_LAYOUT_FEATURE_TYPE_INVALID,
0, &count, settings,
NULL));
g_assert_cmpuint (0, ==, count);
}
static void
test_aat_has (void)
{
hb_face_t *morx = hb_test_open_font_file ("fonts/aat-morx.ttf");
hb_face_t *trak;
g_assert (hb_aat_layout_has_substitution (morx));
hb_face_destroy (morx);
trak = hb_test_open_font_file ("fonts/aat-trak.ttf");
g_assert (hb_aat_layout_has_tracking (trak));
hb_face_destroy (trak);
}
int
main (int argc, char **argv)
{
unsigned int status;
hb_test_init (&argc, &argv);
hb_test_add (test_aat_get_feature_types);
hb_test_add (test_aat_get_feature_selectors);
hb_test_add (test_aat_has);
face = hb_test_open_font_file ("fonts/aat-feat.ttf");
sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
status = hb_test_run ();
hb_face_destroy (sbix);
hb_face_destroy (face);
return status;
}