Merge branch 'master' into iter

This commit is contained in:
Behdad Esfahbod 2019-02-13 22:08:54 -08:00
commit 7d2376de33
7 changed files with 52 additions and 50 deletions

View File

@ -52,7 +52,7 @@ jobs:
- image: alpine
steps:
- checkout
- run: apk update && apk add ragel make pkgconfig libtool autoconf automake gettext gcc g++ glib-dev freetype-dev cairo-dev
- run: apk update && apk add ragel make pkgconfig libtool autoconf automake gettext gcc g++ glib-dev freetype-dev cairo-dev python
# C??FLAGS are not needed for a regular build
- run: CFLAGS="-O3" CXXFLAGS="-O3 -DHB_NO_MMAP" ./autogen.sh
- run: make -j32
@ -60,10 +60,10 @@ jobs:
archlinux-py3-all:
docker:
- image: base/devel
- image: archlinux/base
steps:
- checkout
- run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip
- run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip make which base-devel
- run: pip install flake8 fonttools
- run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
# C??FLAGS are not needed for a regular build
@ -71,6 +71,15 @@ jobs:
- run: make -j32 CPPFLAGS="-Werror"
- run: make check CPPFLAGS="-Werror" || .ci/fail.sh
## Doesn't play well with CircleCI apparently
#void-notest:
# docker:
# - image: voidlinux/voidlinux
# steps:
# - checkout
# - run: xbps-install -Suy freetype gettext gcc glib graphite pkg-config ragel libtool autoconf automake make
# - run: ./autogen.sh && make -j32 && make check
clang-O3-O0:
docker:
- image: ubuntu:18.10
@ -307,6 +316,7 @@ workflows:
# autotools based builds
- alpine-O3-NOMMAP
- archlinux-py3-all
#- void-notest
- gcc-valgrind
- clang-O3-O0
- clang-everything

View File

@ -327,11 +327,6 @@ hb_ceil_to_4 (unsigned int v)
template <typename T> static inline bool
hb_in_range (T u, T lo, T hi)
{
/* The sizeof() is here to force template instantiation.
* I'm sure there are better ways to do this but can't think of
* one right now. Declaring a variable won't work as HB_UNUSED
* is unusable on some platforms and unused types are less likely
* to generate a warning than unused variables. */
static_assert (!hb_is_signed<T>::value, "");
/* The casts below are important as if T is smaller than int,

View File

@ -171,7 +171,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) ||
CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay")))
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1080
# define kCTFontUIFontSystem kCTFontSystemFontType
# define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType
#endif
@ -214,7 +214,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
}
CFURLRef original_url = nullptr;
#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
ATSFontRef atsFont;
FSRef fsref;
OSStatus status;
@ -244,7 +244,7 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
* process in Blink. This can be detected by the new file URL location
* that the newly found font points to. */
CFURLRef new_url = nullptr;
#if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
atsFont = CTFontGetPlatformFont (new_ct_font, NULL);
status = ATSFontGetFileReference (atsFont, &fsref);
if (status == noErr)
@ -711,7 +711,7 @@ resize_and_retry:
/* What's the iOS equivalent of this check?
* The symbols was introduced in iOS 7.0.
* At any rate, our fallback is safe and works fine. */
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1090
# define kCTLanguageAttributeName CFSTR ("NSLanguage")
#endif
CFStringRef lang = CFStringCreateWithCStringNoCopy (kCFAllocatorDefault,
@ -783,7 +783,7 @@ resize_and_retry:
int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level);
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#if !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
#endif
CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault,

View File

@ -88,24 +88,15 @@ struct hb_enable_if<true, T> { typedef T type; };
*/
template <typename T> struct hb_is_signed;
template <> struct hb_is_signed<signed char> { enum { value = true }; };
template <> struct hb_is_signed<signed short> { enum { value = true }; };
template <> struct hb_is_signed<signed int> { enum { value = true }; };
template <> struct hb_is_signed<signed long> { enum { value = true }; };
template <> struct hb_is_signed<unsigned char> { enum { value = false }; };
template <> struct hb_is_signed<unsigned short> { enum { value = false }; };
template <> struct hb_is_signed<unsigned int> { enum { value = false }; };
template <> struct hb_is_signed<unsigned long> { enum { value = false }; };
/* We need to define hb_is_signed for the typedefs we use on pre-Visual
* Studio 2010 for the int8_t type, since __int8/__int64 is not considered
* the same as char/long. The previous lines will suffice for the other
* types, though. Note that somehow, unsigned __int8 is considered same
* as unsigned char.
* https://github.com/harfbuzz/harfbuzz/pull/1499
*/
#if defined(_MSC_VER) && (_MSC_VER < 1600)
template <> struct hb_is_signed<__int8> { enum { value = true }; };
#endif
/* https://github.com/harfbuzz/harfbuzz/issues/1535 */
template <> struct hb_is_signed<int8_t> { enum { value = true }; };
template <> struct hb_is_signed<int16_t> { enum { value = true }; };
template <> struct hb_is_signed<int32_t> { enum { value = true }; };
template <> struct hb_is_signed<int64_t> { enum { value = true }; };
template <> struct hb_is_signed<uint8_t> { enum { value = false }; };
template <> struct hb_is_signed<uint16_t> { enum { value = false }; };
template <> struct hb_is_signed<uint32_t> { enum { value = false }; };
template <> struct hb_is_signed<uint64_t> { enum { value = false }; };
#define hb_is_signed(T) hb_is_signed<T>::value
template <bool is_signed> struct hb_signedness_int;

View File

@ -215,7 +215,7 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer)
unsigned int gen_cat = (unsigned int) unicode->general_category (u);
unsigned int props = gen_cat;
if (u >= 0x80)
if (u >= 0x80u)
{
buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_NON_ASCII;
@ -232,10 +232,10 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer)
* FVSes are GC=Mn, we have use a separate bit to remember them.
* Fixes:
* https://github.com/harfbuzz/harfbuzz/issues/234 */
else if (unlikely (hb_in_range (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_HIDDEN;
else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0x180Bu, 0x180Du))) props |= UPROPS_MASK_HIDDEN;
/* TAG characters need similar treatment. Fixes:
* https://github.com/harfbuzz/harfbuzz/issues/463 */
else if (unlikely (hb_in_range (u, 0xE0020u, 0xE007Fu))) props |= UPROPS_MASK_HIDDEN;
else if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xE0020u, 0xE007Fu))) props |= UPROPS_MASK_HIDDEN;
/* COMBINING GRAPHEME JOINER should not be skipped; at least some times.
* https://github.com/harfbuzz/harfbuzz/issues/554 */
else if (unlikely (u == 0x034Fu))

View File

@ -467,7 +467,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED,
unsigned int j = new_len;
for (unsigned int i = count; i; i--)
{
if (!hb_in_range<unsigned> (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING))
if (!hb_in_range<uint8_t> (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING))
{
if (step == CUT)
{
@ -488,7 +488,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED,
unsigned int end = i;
while (i &&
hb_in_range<unsigned> (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING))
hb_in_range<uint8_t> (info[i - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING))
{
i--;
hb_position_t width = font->get_glyph_h_advance (info[i].codepoint);
@ -506,7 +506,7 @@ apply_stch (const hb_ot_shape_plan_t *plan HB_UNUSED,
unsigned int start = i;
unsigned int context = i;
while (context &&
!hb_in_range<unsigned> (info[context - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING) &&
!hb_in_range<uint8_t> (info[context - 1].arabic_shaping_action(), STCH_FIXED, STCH_REPEATING) &&
(_hb_glyph_info_is_default_ignorable (&info[context - 1]) ||
HB_ARABIC_GENERAL_CATEGORY_IS_WORD (_hb_glyph_info_get_general_category (&info[context - 1]))))
{

View File

@ -11,11 +11,13 @@ trySubset (hb_face_t *face,
const hb_codepoint_t text[],
int text_length,
bool drop_hints,
bool drop_layout)
bool drop_layout,
bool retain_gids)
{
hb_subset_input_t *input = hb_subset_input_create_or_fail ();
hb_subset_input_set_drop_hints (input, drop_hints);
hb_subset_input_set_drop_layout (input, drop_layout);
hb_subset_input_set_retain_gids (input, retain_gids);
hb_set_t *codepoints = hb_subset_input_unicode_set (input);
for (int i = 0; i < text_length; i++)
@ -32,16 +34,14 @@ trySubset (hb_face_t *face,
static void
trySubset (hb_face_t *face,
const hb_codepoint_t text[],
int text_length)
int text_length,
const uint8_t flags[1])
{
for (unsigned int drop_hints = 0; drop_hints < 2; drop_hints++)
{
for (unsigned int drop_layout = 0; drop_layout < 2; drop_layout++)
{
trySubset (face, text, text_length,
(bool) drop_hints, (bool) drop_layout);
}
}
bool drop_hints = flags[0] & (1 << 0);
bool drop_layout = flags[0] & (1 << 1);
bool retain_gids = flags[0] & (1 << 2);
trySubset (face, text, text_length,
drop_hints, drop_layout, retain_gids);
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
@ -55,21 +55,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
hb_face_collect_unicodes (face, output);
hb_set_destroy (output);
uint8_t flags[1] = {0};
const hb_codepoint_t text[] =
{
'A', 'B', 'C', 'D', 'E', 'X', 'Y', 'Z', '1', '2',
'3', '@', '_', '%', '&', ')', '*', '$', '!'
};
trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t));
trySubset (face, text, sizeof (text) / sizeof (hb_codepoint_t), flags);
hb_codepoint_t text_from_data[16];
if (size > sizeof(text_from_data)) {
if (size > sizeof(text_from_data) + sizeof(flags)) {
memcpy (text_from_data,
data + size - sizeof(text_from_data),
sizeof(text_from_data));
memcpy (flags,
data + size - sizeof(text_from_data) - sizeof(flags),
sizeof(flags));
unsigned int text_size = sizeof (text_from_data) / sizeof (hb_codepoint_t);
trySubset (face, text_from_data, text_size);
trySubset (face, text_from_data, text_size, flags);
}
hb_face_destroy (face);