diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-13 10:10:45 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2016-09-13 10:10:45 +0000 |
commit | a8951d1db45ca51c96ffa2c431777eb37c8a2f94 (patch) | |
tree | bcaa37c326975a1771aaf85bb9a2675127f22729 /Build/source/libs/freetype2/freetype-src/src | |
parent | 873f349d7e0ae42e35ccf4d96fce5a6cfa685fe6 (diff) |
freetype 2.7.0
git-svn-id: svn://tug.org/texlive/trunk@42052 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src')
38 files changed, 1220 insertions, 660 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c index 95786ed6f2b..7719c02caab 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.c @@ -32,13 +32,13 @@ '\0', '\xD9', '\x80', /* ـ */ '\0', - '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x93', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Փ Բ Գ Դ Օ */ + '\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Ս Բ Գ Դ Օ */ '\0', - '\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD5', '\x93', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Փ Ճ Շ Ս Տ Օ */ + '\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Դ Ճ Շ Ս Տ Օ */ '\0', - '\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x83', ' ', '\xD6', '\x86', ' ', '\xD6', '\x83', /* ե է ի մ վ փ ֆ փ */ + '\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x86', ' ', '\xD5', '\xB3', /* ե է ի մ վ ֆ ճ */ '\0', - '\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xBB', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ ջ ր օ */ + '\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xB7', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ շ ր օ */ '\0', '\xD5', '\xB0', ' ', '\xD5', '\xB8', ' ', '\xD5', '\xB3', ' ', '\xD5', '\xA1', ' ', '\xD5', '\xA5', ' ', '\xD5', '\xAE', ' ', '\xD5', '\xBD', ' ', '\xD6', '\x85', /* հ ո ճ ա ե ծ ս օ */ '\0', diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat index 0734ec71f00..f5f04f28982 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.dat @@ -87,13 +87,13 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN: "ـ" AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP - "Ա Մ Ւ Փ Բ Գ Դ Օ" + "Ա Մ Ւ Ս Բ Գ Դ Օ" AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM - "Ւ Ո Փ Ճ Շ Ս Տ Օ" + "Ւ Ո Դ Ճ Շ Ս Տ Օ" AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER - "ե է ի մ վ փ ֆ փ" + "ե է ի մ վ ֆ ճ" AF_BLUE_STRING_ARMENIAN_SMALL_TOP - "ա յ ւ ս գ ջ ր օ" + "ա յ ւ ս գ շ ր օ" AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM "հ ո ճ ա ե ծ ս օ" AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h index 41f838e4577..75c3ab50834 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afblue.h @@ -83,104 +83,104 @@ FT_BEGIN_HEADER AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 36, AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 60, AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 84, - AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 108, - AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 132, - AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 156, - AF_BLUE_STRING_BENGALI_BASE = 180, - AF_BLUE_STRING_BENGALI_TOP = 212, - AF_BLUE_STRING_BENGALI_HEAD = 240, - AF_BLUE_STRING_CHEROKEE_CAPITAL = 272, - AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 304, - AF_BLUE_STRING_CHEROKEE_SMALL = 336, - AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 368, - AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 384, - AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 408, - AF_BLUE_STRING_CYRILLIC_SMALL = 432, - AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 456, - AF_BLUE_STRING_DEVANAGARI_BASE = 465, - AF_BLUE_STRING_DEVANAGARI_TOP = 497, - AF_BLUE_STRING_DEVANAGARI_HEAD = 529, - AF_BLUE_STRING_DEVANAGARI_BOTTOM = 561, - AF_BLUE_STRING_ETHIOPIC_TOP = 569, - AF_BLUE_STRING_ETHIOPIC_BOTTOM = 601, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 633, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 665, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 697, - AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 729, - AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 761, - AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 793, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 825, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 857, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 889, - AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 921, - AF_BLUE_STRING_GREEK_CAPITAL_TOP = 953, - AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 974, - AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 992, - AF_BLUE_STRING_GREEK_SMALL = 1010, - AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 1034, - AF_BLUE_STRING_GUJARATI_TOP = 1058, - AF_BLUE_STRING_GUJARATI_BOTTOM = 1090, - AF_BLUE_STRING_GUJARATI_ASCENDER = 1122, - AF_BLUE_STRING_GUJARATI_DESCENDER = 1172, - AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 1205, - AF_BLUE_STRING_GURMUKHI_BASE = 1225, - AF_BLUE_STRING_GURMUKHI_HEAD = 1257, - AF_BLUE_STRING_GURMUKHI_TOP = 1289, - AF_BLUE_STRING_GURMUKHI_BOTTOM = 1321, - AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 1353, - AF_BLUE_STRING_HEBREW_TOP = 1373, - AF_BLUE_STRING_HEBREW_BOTTOM = 1397, - AF_BLUE_STRING_HEBREW_DESCENDER = 1415, - AF_BLUE_STRING_KANNADA_TOP = 1430, - AF_BLUE_STRING_KANNADA_BOTTOM = 1474, - AF_BLUE_STRING_KHMER_TOP = 1506, - AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 1530, - AF_BLUE_STRING_KHMER_BOTTOM = 1570, - AF_BLUE_STRING_KHMER_DESCENDER = 1602, - AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 1636, - AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 1723, - AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 1731, - AF_BLUE_STRING_LAO_TOP = 1739, - AF_BLUE_STRING_LAO_BOTTOM = 1771, - AF_BLUE_STRING_LAO_ASCENDER = 1803, - AF_BLUE_STRING_LAO_LARGE_ASCENDER = 1819, - AF_BLUE_STRING_LAO_DESCENDER = 1831, - AF_BLUE_STRING_LATIN_CAPITAL_TOP = 1855, - AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 1871, - AF_BLUE_STRING_LATIN_SMALL_F_TOP = 1887, - AF_BLUE_STRING_LATIN_SMALL = 1901, - AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 1915, - AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 1925, - AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 1945, - AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 1965, - AF_BLUE_STRING_LATIN_SUBS_SMALL = 1985, - AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 2021, - AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 2041, - AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 2072, - AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 2101, - AF_BLUE_STRING_LATIN_SUPS_SMALL = 2127, - AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 2152, - AF_BLUE_STRING_MALAYALAM_TOP = 2163, - AF_BLUE_STRING_MALAYALAM_BOTTOM = 2207, - AF_BLUE_STRING_MYANMAR_TOP = 2239, - AF_BLUE_STRING_MYANMAR_BOTTOM = 2271, - AF_BLUE_STRING_MYANMAR_ASCENDER = 2303, - AF_BLUE_STRING_MYANMAR_DESCENDER = 2331, - AF_BLUE_STRING_SINHALA_TOP = 2363, - AF_BLUE_STRING_SINHALA_BOTTOM = 2395, - AF_BLUE_STRING_SINHALA_DESCENDER = 2427, - AF_BLUE_STRING_TAMIL_TOP = 2471, - AF_BLUE_STRING_TAMIL_BOTTOM = 2503, - AF_BLUE_STRING_TELUGU_TOP = 2535, - AF_BLUE_STRING_TELUGU_BOTTOM = 2563, - AF_BLUE_STRING_THAI_TOP = 2591, - AF_BLUE_STRING_THAI_BOTTOM = 2615, - AF_BLUE_STRING_THAI_ASCENDER = 2643, - AF_BLUE_STRING_THAI_LARGE_ASCENDER = 2655, - AF_BLUE_STRING_THAI_DESCENDER = 2667, - AF_BLUE_STRING_THAI_LARGE_DESCENDER = 2683, - AF_BLUE_STRING_THAI_DIGIT_TOP = 2691, - af_blue_1_1 = 2702, + AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 105, + AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 129, + AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 153, + AF_BLUE_STRING_BENGALI_BASE = 177, + AF_BLUE_STRING_BENGALI_TOP = 209, + AF_BLUE_STRING_BENGALI_HEAD = 237, + AF_BLUE_STRING_CHEROKEE_CAPITAL = 269, + AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 301, + AF_BLUE_STRING_CHEROKEE_SMALL = 333, + AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 365, + AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 381, + AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 405, + AF_BLUE_STRING_CYRILLIC_SMALL = 429, + AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 453, + AF_BLUE_STRING_DEVANAGARI_BASE = 462, + AF_BLUE_STRING_DEVANAGARI_TOP = 494, + AF_BLUE_STRING_DEVANAGARI_HEAD = 526, + AF_BLUE_STRING_DEVANAGARI_BOTTOM = 558, + AF_BLUE_STRING_ETHIOPIC_TOP = 566, + AF_BLUE_STRING_ETHIOPIC_BOTTOM = 598, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 630, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 662, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 694, + AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 726, + AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 758, + AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 790, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 822, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 854, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 886, + AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 918, + AF_BLUE_STRING_GREEK_CAPITAL_TOP = 950, + AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 971, + AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 989, + AF_BLUE_STRING_GREEK_SMALL = 1007, + AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 1031, + AF_BLUE_STRING_GUJARATI_TOP = 1055, + AF_BLUE_STRING_GUJARATI_BOTTOM = 1087, + AF_BLUE_STRING_GUJARATI_ASCENDER = 1119, + AF_BLUE_STRING_GUJARATI_DESCENDER = 1169, + AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 1202, + AF_BLUE_STRING_GURMUKHI_BASE = 1222, + AF_BLUE_STRING_GURMUKHI_HEAD = 1254, + AF_BLUE_STRING_GURMUKHI_TOP = 1286, + AF_BLUE_STRING_GURMUKHI_BOTTOM = 1318, + AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 1350, + AF_BLUE_STRING_HEBREW_TOP = 1370, + AF_BLUE_STRING_HEBREW_BOTTOM = 1394, + AF_BLUE_STRING_HEBREW_DESCENDER = 1412, + AF_BLUE_STRING_KANNADA_TOP = 1427, + AF_BLUE_STRING_KANNADA_BOTTOM = 1471, + AF_BLUE_STRING_KHMER_TOP = 1503, + AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 1527, + AF_BLUE_STRING_KHMER_BOTTOM = 1567, + AF_BLUE_STRING_KHMER_DESCENDER = 1599, + AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 1633, + AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 1720, + AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 1728, + AF_BLUE_STRING_LAO_TOP = 1736, + AF_BLUE_STRING_LAO_BOTTOM = 1768, + AF_BLUE_STRING_LAO_ASCENDER = 1800, + AF_BLUE_STRING_LAO_LARGE_ASCENDER = 1816, + AF_BLUE_STRING_LAO_DESCENDER = 1828, + AF_BLUE_STRING_LATIN_CAPITAL_TOP = 1852, + AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 1868, + AF_BLUE_STRING_LATIN_SMALL_F_TOP = 1884, + AF_BLUE_STRING_LATIN_SMALL = 1898, + AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 1912, + AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 1922, + AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 1942, + AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 1962, + AF_BLUE_STRING_LATIN_SUBS_SMALL = 1982, + AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 2018, + AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 2038, + AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 2069, + AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 2098, + AF_BLUE_STRING_LATIN_SUPS_SMALL = 2124, + AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 2149, + AF_BLUE_STRING_MALAYALAM_TOP = 2160, + AF_BLUE_STRING_MALAYALAM_BOTTOM = 2204, + AF_BLUE_STRING_MYANMAR_TOP = 2236, + AF_BLUE_STRING_MYANMAR_BOTTOM = 2268, + AF_BLUE_STRING_MYANMAR_ASCENDER = 2300, + AF_BLUE_STRING_MYANMAR_DESCENDER = 2328, + AF_BLUE_STRING_SINHALA_TOP = 2360, + AF_BLUE_STRING_SINHALA_BOTTOM = 2392, + AF_BLUE_STRING_SINHALA_DESCENDER = 2424, + AF_BLUE_STRING_TAMIL_TOP = 2468, + AF_BLUE_STRING_TAMIL_BOTTOM = 2500, + AF_BLUE_STRING_TELUGU_TOP = 2532, + AF_BLUE_STRING_TELUGU_BOTTOM = 2560, + AF_BLUE_STRING_THAI_TOP = 2588, + AF_BLUE_STRING_THAI_BOTTOM = 2612, + AF_BLUE_STRING_THAI_ASCENDER = 2640, + AF_BLUE_STRING_THAI_LARGE_ASCENDER = 2652, + AF_BLUE_STRING_THAI_DESCENDER = 2664, + AF_BLUE_STRING_THAI_LARGE_DESCENDER = 2680, + AF_BLUE_STRING_THAI_DIGIT_TOP = 2688, + af_blue_1_1 = 2699, #ifdef AF_CONFIG_OPTION_CJK AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1, AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203, diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c index 6c3d032d1c7..0f7f6e5c419 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.c @@ -420,20 +420,19 @@ dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" )); if ( axis->num_segments ) - AF_DUMP(( " index pos dir from to" - " link serif edge" + AF_DUMP(( " index pos delta dir from to " + " link serif edge" " height extra flags\n" )); else AF_DUMP(( " (none)\n" )); for ( seg = segments; seg < limit; seg++ ) - AF_DUMP(( " %5d %5.2g %5s %4d %4d" + AF_DUMP(( " %5d %5d %5d %5s %4d %4d" " %4s %5s %4s" " %6d %5d %11s\n", AF_INDEX_NUM( seg, segments ), - dimension == AF_DIMENSION_HORZ - ? (int)seg->first->ox / 64.0 - : (int)seg->first->oy / 64.0, + seg->pos, + seg->delta, af_dir_str( (AF_Direction)seg->dir ), AF_INDEX_NUM( seg->first, points ), AF_INDEX_NUM( seg->last, points ), @@ -553,18 +552,26 @@ * note: AF_DIMENSION_HORZ corresponds to _vertical_ edges * since they have a constant X coordinate. */ - AF_DUMP(( "Table of %s edges:\n", - dimension == AF_DIMENSION_HORZ ? "vertical" - : "horizontal" )); + if ( dimension == AF_DIMENSION_HORZ ) + AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", + "vertical", + 65536.0 * 64.0 / hints->x_scale, + 10.0 * hints->x_scale / 65536.0 / 64.0 )); + else + AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n", + "horizontal", + 65536.0 * 64.0 / hints->y_scale, + 10.0 * hints->y_scale / 65536.0 / 64.0 )); + if ( axis->num_edges ) - AF_DUMP(( " index pos dir link serif" - " blue opos pos flags\n" )); + AF_DUMP(( " index pos dir link serif" + " blue opos pos flags\n" )); else AF_DUMP(( " (none)\n" )); for ( edge = edges; edge < limit; edge++ ) - AF_DUMP(( " %5d %5.2g %5s %4s %5s" - " %c %5.2f %5.2f %11s\n", + AF_DUMP(( " %5d %7.2f %5s %4s %5s" + " %c %7.2f %7.2f %11s\n", AF_INDEX_NUM( edge, edges ), (int)edge->opos / 64.0, af_dir_str( (AF_Direction)edge->dir ), diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h index 5142e6ed217..4fdf732d423 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afhints.h @@ -260,6 +260,7 @@ FT_BEGIN_HEADER FT_Byte flags; /* edge/segment flags for this segment */ FT_Char dir; /* segment direction */ FT_Short pos; /* position of segment */ + FT_Short delta; /* deviation from segment position */ FT_Short min_coord; /* minimum coordinate of segment */ FT_Short max_coord; /* maximum coordinate of segment */ FT_Short height; /* the hinted segment height */ diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c index 7ccf3f6e370..db7aaff7b6c 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/aflatin.c @@ -1076,7 +1076,7 @@ FT_UInt ppem; - scaled = FT_MulFix( blue->shoot.org, scaler->y_scale ); + scaled = FT_MulFix( blue->shoot.org, scale ); ppem = metrics->root.scaler.face->size->metrics.x_ppem; limit = metrics->root.globals->increase_x_height; threshold = 40; @@ -1123,8 +1123,6 @@ if ( dist == 0 ) { - scale = new_scale; - FT_TRACE5(( "af_latin_metrics_scale_dim:" " x height alignment (style `%s'):\n" @@ -1132,9 +1130,11 @@ " vertical scaling changed from %.4f to %.4f (by %d%%)\n" "\n", af_style_names[metrics->root.style_class->style], - axis->org_scale / 65536.0, scale / 65536.0, + new_scale / 65536.0, ( fitted - scaled ) * 100 / scaled )); + + scale = new_scale; } #ifdef FT_DEBUG_LEVEL_TRACE else @@ -1536,8 +1536,9 @@ /* points are different: we are just leaving an edge, thus */ /* record a new segment */ - segment->last = point; - segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->last = point; + segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 ); /* a segment is round if either its first or last point */ /* is a control point, and the length of the on points */ @@ -1966,6 +1967,7 @@ FT_Fixed scale; FT_Pos edge_distance_threshold; FT_Pos segment_length_threshold; + FT_Pos segment_width_threshold; axis->num_edges = 0; @@ -1987,9 +1989,15 @@ * corresponding threshold in font units. */ if ( dim == AF_DIMENSION_HORZ ) - segment_length_threshold = FT_DivFix( 64, hints->y_scale ); + segment_length_threshold = FT_DivFix( 64, hints->y_scale ); else - segment_length_threshold = 0; + segment_length_threshold = 0; + + /* + * Similarly, we ignore segments that have a width delta + * larger than 0.5px (i.e., a width larger than 1px). + */ + segment_width_threshold = FT_DivFix( 32, scale ); /*********************************************************************/ /* */ @@ -2022,9 +2030,10 @@ FT_Int ee; - /* ignore too short segments and, in this loop, */ - /* one-point segments without a direction */ + /* ignore too short segments, too wide ones, and, in this loop, */ + /* one-point segments without a direction */ if ( seg->height < segment_length_threshold || + seg->delta > segment_width_threshold || seg->dir == AF_DIR_NONE ) continue; diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c index 4127382c003..e8f8ff40710 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afmodule.c @@ -107,18 +107,29 @@ static FT_Error af_property_set( FT_Module ft_module, const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; AF_Module module = (AF_Module)ft_module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "fallback-script" ) ) { - FT_UInt* fallback_script = (FT_UInt*)value; + FT_UInt* fallback_script; + FT_UInt ss; + - FT_UInt ss; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + fallback_script = (FT_UInt*)value; /* We translate the fallback script to a fallback style that uses */ /* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */ @@ -147,19 +158,33 @@ } else if ( !ft_strcmp( property_name, "default-script" ) ) { - FT_UInt* default_script = (FT_UInt*)value; + FT_UInt* default_script; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + + default_script = (FT_UInt*)value; + module->default_script = *default_script; return error; } else if ( !ft_strcmp( property_name, "increase-x-height" ) ) { - FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value; + FT_Prop_IncreaseXHeight* prop; AF_FaceGlobals globals; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + return FT_THROW( Invalid_Argument ); +#endif + + prop = (FT_Prop_IncreaseXHeight*)value; + error = af_property_get_face_globals( prop->face, &globals, module ); if ( !error ) globals->increase_x_height = prop->limit; @@ -169,27 +194,76 @@ #ifdef AF_CONFIG_OPTION_USE_WARPER else if ( !ft_strcmp( property_name, "warping" ) ) { - FT_Bool* warping = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long w = ft_strtol( s, NULL, 10 ); + + + if ( w == 0 ) + module->warping = 0; + else if ( w == 1 ) + module->warping = 1; + else + return FT_THROW( Invalid_Argument ); + } + else +#endif + { + FT_Bool* warping = (FT_Bool*)value; - module->warping = *warping; + module->warping = *warping; + } return error; } #endif /* AF_CONFIG_OPTION_USE_WARPER */ else if ( !ft_strcmp( property_name, "darkening-parameters" ) ) { - FT_Int* darken_params = (FT_Int*)value; + FT_Int* darken_params; + FT_Int x1, y1, x2, y2, x3, y3, x4, y4; + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_Int dp[8]; + + + if ( value_is_string ) + { + const char* s = (const char*)value; + char* ep; + int i; + + + /* eight comma-separated numbers */ + for ( i = 0; i < 7; i++ ) + { + dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( *ep != ',' || s == ep ) + return FT_THROW( Invalid_Argument ); + + s = ep + 1; + } - FT_Int x1 = darken_params[0]; - FT_Int y1 = darken_params[1]; - FT_Int x2 = darken_params[2]; - FT_Int y2 = darken_params[3]; - FT_Int x3 = darken_params[4]; - FT_Int y3 = darken_params[5]; - FT_Int x4 = darken_params[6]; - FT_Int y4 = darken_params[7]; + dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) + return FT_THROW( Invalid_Argument ); + darken_params = dp; + } + else +#endif + darken_params = (FT_Int*)value; + + x1 = darken_params[0]; + y1 = darken_params[1]; + x2 = darken_params[2]; + y2 = darken_params[3]; + x3 = darken_params[4]; + y3 = darken_params[5]; + x4 = darken_params[6]; + y4 = darken_params[7]; if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || @@ -210,10 +284,28 @@ } else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) { - FT_Bool* no_stem_darkening = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long nsd = ft_strtol( s, NULL, 10 ); + + if ( nsd == 0 ) + module->no_stem_darkening = 0; + else if ( nsd == 1 ) + module->no_stem_darkening = 1; + else + return FT_THROW( Invalid_Argument ); + } + else +#endif + { + FT_Bool* no_stem_darkening = (FT_Bool*)value; - module->no_stem_darkening = *no_stem_darkening; + + module->no_stem_darkening = *no_stem_darkening; + } return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h b/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h index 33c30129816..cffe59105dc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h +++ b/Build/source/libs/freetype2/freetype-src/src/autofit/afscript.h @@ -40,7 +40,7 @@ "Armenian", HB_SCRIPT_ARMENIAN, HINTING_BOTTOM_TO_TOP, - "\xD6\x85 \xD5\x95" ) /* օ Օ */ + "\xD5\xBD \xD5\x8D" ) /* ս Ս */ /* there are no simple forms for letters; we thus use two digit shapes */ SCRIPT( beng, BENG, diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c b/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c index 6ab50727482..38d1a803f05 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftdbgmem.c @@ -842,7 +842,7 @@ p = getenv( "FT2_ALLOC_TOTAL_MAX" ); if ( p != NULL ) { - FT_Long total_max = ft_atol( p ); + FT_Long total_max = ft_strtol( p, NULL, 10 ); if ( total_max > 0 ) @@ -855,7 +855,7 @@ p = getenv( "FT2_ALLOC_COUNT_MAX" ); if ( p != NULL ) { - FT_Long total_count = ft_atol( p ); + FT_Long total_count = ft_strtol( p, NULL, 10 ); if ( total_count > 0 ) @@ -868,7 +868,7 @@ p = getenv( "FT2_KEEP_ALIVE" ); if ( p != NULL ) { - FT_Long keep_alive = ft_atol( p ); + FT_Long keep_alive = ft_strtol( p, NULL, 10 ); if ( keep_alive > 0 ) diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c b/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c index c2dd0a7b372..02ef938d5ea 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftinit.c @@ -226,6 +226,115 @@ } +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + +#define MAX_LENGTH 128 + + /* + * Set default properties derived from the `FREETYPE_PROPERTIES' + * environment variable. + * + * `FREETYPE_PROPERTIES' has the following syntax form (broken here into + * multiple lines for better readability) + * + * <optional whitespace> + * <module-name1> ':' + * <property-name1> '=' <property-value1> + * <whitespace> + * <module-name2> ':' + * <property-name2> '=' <property-value2> + * ... + * + * Example: + * + * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ + * cff:no-stem-darkening=1 \ + * autofitter:warping=1 + * + */ + + static void + ft_set_default_properties( FT_Library library ) + { + const char* env; + const char* p; + const char* q; + + char module_name[MAX_LENGTH + 1]; + char property_name[MAX_LENGTH + 1]; + char property_value[MAX_LENGTH + 1]; + + int i; + + + env = ft_getenv( "FREETYPE_PROPERTIES" ); + if ( !env ) + return; + + for ( p = env; *p; p++ ) + { + /* skip leading whitespace and separators */ + if ( *p == ' ' || *p == '\t' ) + continue; + + /* read module name, followed by `:' */ + q = p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == ':' ) + break; + module_name[i] = *p++; + } + module_name[i] = '\0'; + + if ( !*p || *p != ':' || p == q ) + break; + + /* read property name, followed by `=' */ + q = ++p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == '=' ) + break; + property_name[i] = *p++; + } + property_name[i] = '\0'; + + if ( !*p || *p != '=' || p == q ) + break; + + /* read property value, followed by whitespace (if any) */ + q = ++p; + for ( i = 0; i < MAX_LENGTH; i++ ) + { + if ( !*p || *p == ' ' || *p == '\t' ) + break; + property_value[i] = *p++; + } + property_value[i] = '\0'; + + if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q ) + break; + + /* we completely ignore errors */ + ft_property_string_set( library, + module_name, + property_name, + property_value ); + } + } + +#else + + static void + ft_set_default_properties( FT_Library library ) + { + FT_UNUSED( library ); + } + +#endif + + /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) @@ -256,6 +365,8 @@ else FT_Add_Default_Modules( *alibrary ); + ft_set_default_properties( *alibrary ); + return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c index c2dc6183b04..0c9e4090c56 100644 --- a/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/base/ftobjs.c @@ -2314,11 +2314,24 @@ if ( bsize->height < 0 ) - bsize->height = (FT_Short)-bsize->height; + bsize->height = -bsize->height; if ( bsize->x_ppem < 0 ) - bsize->x_ppem = (FT_Short)-bsize->x_ppem; + bsize->x_ppem = -bsize->x_ppem; if ( bsize->y_ppem < 0 ) bsize->y_ppem = -bsize->y_ppem; + + /* check whether negation actually has worked */ + if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 ) + { + FT_TRACE0(( "FT_Open_Face:" + " Invalid bitmap dimensions for stroke %d," + " now disabled\n", i )); + bsize->width = 0; + bsize->height = 0; + bsize->size = 0; + bsize->x_ppem = 0; + bsize->y_ppem = 0; + } } } @@ -4564,7 +4577,8 @@ const FT_String* module_name, const FT_String* property_name, void* value, - FT_Bool set ) + FT_Bool set, + FT_Bool value_is_string ) { FT_Module* cur; FT_Module* limit; @@ -4634,8 +4648,13 @@ return FT_THROW( Unimplemented_Feature ); } - return set ? service->set_property( cur[0], property_name, value ) - : service->get_property( cur[0], property_name, value ); + return set ? service->set_property( cur[0], + property_name, + value, + value_is_string ) + : service->get_property( cur[0], + property_name, + value ); } @@ -4651,7 +4670,8 @@ module_name, property_name, (void*)value, - TRUE ); + TRUE, + FALSE ); } @@ -4667,10 +4687,33 @@ module_name, property_name, value, + FALSE, FALSE ); } +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + + /* this variant is used for handling the FREETYPE_PROPERTIES */ + /* environment variable */ + + FT_BASE_DEF( FT_Error ) + ft_property_string_set( FT_Library library, + const FT_String* module_name, + const FT_String* property_name, + FT_String* value ) + { + return ft_property_do( library, + module_name, + property_name, + (void*)value, + TRUE, + TRUE ); + } + +#endif + + /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c index 7d663dd0eca..10e7b4b6459 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c @@ -469,6 +469,8 @@ CF2_GlyphPathRec glyphPath; + FT_ZERO( &storage ); + /* initialize the remaining objects */ cf2_arrstack_init( &subrStack, memory, diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c index 6fafd901f33..8f3adb6d686 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cf2stack.c @@ -53,14 +53,14 @@ cf2_stack_init( FT_Memory memory, FT_Error* e ) { - FT_Error error = FT_Err_Ok; /* for FT_QNEW */ + FT_Error error = FT_Err_Ok; /* for FT_NEW */ CF2_Stack stack = NULL; - if ( !FT_QNEW( stack ) ) + if ( !FT_NEW( stack ) ) { - /* initialize the structure; FT_QNEW zeroes it */ + /* initialize the structure; FT_NEW zeroes it */ stack->memory = memory; stack->error = e; stack->top = &stack->buffer[0]; /* empty stack */ diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c index 950a9605c38..67bf09d8c0d 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c @@ -659,26 +659,62 @@ static FT_Error cff_property_set( FT_Module module, /* CFF_Driver */ const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; CFF_Driver driver = (CFF_Driver)module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "darkening-parameters" ) ) { - FT_Int* darken_params = (FT_Int*)value; + FT_Int* darken_params; + FT_Int x1, y1, x2, y2, x3, y3, x4, y4; - FT_Int x1 = darken_params[0]; - FT_Int y1 = darken_params[1]; - FT_Int x2 = darken_params[2]; - FT_Int y2 = darken_params[3]; - FT_Int x3 = darken_params[4]; - FT_Int y3 = darken_params[5]; - FT_Int x4 = darken_params[6]; - FT_Int y4 = darken_params[7]; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_Int dp[8]; + if ( value_is_string ) + { + const char* s = (const char*)value; + char* ep; + int i; + + + /* eight comma-separated numbers */ + for ( i = 0; i < 7; i++ ) + { + dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( *ep != ',' || s == ep ) + return FT_THROW( Invalid_Argument ); + + s = ep + 1; + } + + dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); + if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) + return FT_THROW( Invalid_Argument ); + + darken_params = dp; + } + else +#endif + darken_params = (FT_Int*)value; + + x1 = darken_params[0]; + y1 = darken_params[1]; + x2 = darken_params[2]; + y2 = darken_params[3]; + x3 = darken_params[4]; + y3 = darken_params[5]; + x4 = darken_params[6]; + y4 = darken_params[7]; + if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || x1 > x2 || x2 > x3 || x3 > x4 || @@ -698,26 +734,62 @@ } else if ( !ft_strcmp( property_name, "hinting-engine" ) ) { - FT_UInt* hinting_engine = (FT_UInt*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; - if ( *hinting_engine == FT_CFF_HINTING_ADOBE + if ( !ft_strcmp( s, "adobe" ) ) + driver->hinting_engine = FT_CFF_HINTING_ADOBE; #ifdef CFF_CONFIG_OPTION_OLD_ENGINE - || *hinting_engine == FT_CFF_HINTING_FREETYPE + else if ( !ft_strcmp( s, "freetype" ) ) + driver->hinting_engine = FT_CFF_HINTING_FREETYPE; #endif - ) - driver->hinting_engine = *hinting_engine; + else + return FT_THROW( Invalid_Argument ); + } else - error = FT_ERR( Unimplemented_Feature ); +#endif + { + FT_UInt* hinting_engine = (FT_UInt*)value; - return error; + if ( *hinting_engine == FT_CFF_HINTING_ADOBE +#ifdef CFF_CONFIG_OPTION_OLD_ENGINE + || *hinting_engine == FT_CFF_HINTING_FREETYPE +#endif + ) + driver->hinting_engine = *hinting_engine; + else + error = FT_ERR( Unimplemented_Feature ); + + return error; + } } else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) { - FT_Bool* no_stem_darkening = (FT_Bool*)value; +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + long nsd = ft_strtol( s, NULL, 10 ); + + + if ( nsd == 0 ) + driver->no_stem_darkening = 0; + else if ( nsd == 1 ) + driver->no_stem_darkening = 1; + else + return FT_THROW( Invalid_Argument ); + } + else +#endif + { + FT_Bool* no_stem_darkening = (FT_Bool*)value; - driver->no_stem_darkening = *no_stem_darkening; + driver->no_stem_darkening = *no_stem_darkening; + } return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c index 752c18ed92b..4f375a61231 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c @@ -2942,6 +2942,7 @@ cff_decoder_init( &decoder, face, size, glyph, hinting, FT_LOAD_TARGET_MODE( load_flags ) ); + /* this is for pure CFFs */ if ( load_flags & FT_LOAD_ADVANCE_ONLY ) decoder.width_only = TRUE; diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c index 3d1bda97b94..470fa82151b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c @@ -602,7 +602,8 @@ if ( !FT_ALLOC( name, byte_len + 1 ) ) { - FT_MEM_COPY( name, bytes, byte_len ); + if ( byte_len ) + FT_MEM_COPY( name, bytes, byte_len ); name[byte_len] = 0; } cff_index_forget_element( idx, &bytes ); diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c index d4f1ad1a7fb..21397c2c0e5 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidload.c @@ -777,7 +777,8 @@ CID_FaceDict dict = cid->font_dicts + n; - if ( dict->sd_bytes < 0 ) + if ( dict->sd_bytes < 0 || + ( dict->num_subrs && dict->sd_bytes < 1 ) ) { FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" )); error = FT_THROW( Invalid_File_Format ); diff --git a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c index 73aca2ac6a7..cb07c45099f 100644 --- a/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c +++ b/Build/source/libs/freetype2/freetype-src/src/cid/cidparse.c @@ -199,7 +199,7 @@ limit = parser->root.limit; cur = parser->root.cursor; - while ( cur < limit - SFNTS_LEN ) + while ( cur <= limit - SFNTS_LEN ) { if ( parser->root.error ) { @@ -208,12 +208,12 @@ } if ( cur[0] == 'S' && - cur < limit - STARTDATA_LEN && + cur <= limit - STARTDATA_LEN && ft_strncmp( (char*)cur, STARTDATA, STARTDATA_LEN ) == 0 ) { if ( ft_strncmp( (char*)arg1, "(Hex)", 5 ) == 0 ) { - FT_Long tmp = ft_atol( (const char *)arg2 ); + FT_Long tmp = ft_strtol( (const char *)arg2, NULL, 10 ); if ( tmp < 0 ) diff --git a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c index e17b3c5247a..9e66ba983f3 100644 --- a/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c +++ b/Build/source/libs/freetype2/freetype-src/src/lzw/ftzopen.c @@ -42,7 +42,12 @@ state->buf_total += count; state->in_eof = FT_BOOL( count < state->num_bits ); state->buf_offset = 0; - state->buf_size = ( state->buf_size << 3 ) - ( state->num_bits - 1 ); + + state->buf_size <<= 3; + if ( state->buf_size > state->num_bits ) + state->buf_size -= state->num_bits - 1; + else + return -1; /* not enough data */ if ( count == 0 ) /* end of file */ return -1; @@ -66,7 +71,10 @@ { if ( state->free_ent >= state->free_bits ) { - state->num_bits = ++num_bits; + state->num_bits = ++num_bits; + if ( num_bits > LZW_MAX_BITS ) + return -1; + state->free_bits = state->num_bits < state->max_bits ? (FT_UInt)( ( 1UL << num_bits ) - 256 ) : state->max_free + 1; diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c index 47e89677527..22332694bbc 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfdriver.c @@ -459,55 +459,62 @@ FT_DEFINE_SFNT_INTERFACE( sfnt_interface, - tt_face_goto_table, + tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */ - sfnt_init_face, - sfnt_load_face, - sfnt_done_face, - sfnt_get_interface, + sfnt_init_face, /* TT_Init_Face_Func init_face */ + sfnt_load_face, /* TT_Load_Face_Func load_face */ + sfnt_done_face, /* TT_Done_Face_Func done_face */ + sfnt_get_interface, /* FT_Module_Requester get_interface */ - tt_face_load_any, + tt_face_load_any, /* TT_Load_Any_Func load_any */ - tt_face_load_head, - tt_face_load_hhea, - tt_face_load_cmap, - tt_face_load_maxp, - tt_face_load_os2, - tt_face_load_post, + tt_face_load_head, /* TT_Load_Table_Func load_head */ + tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */ + tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */ + tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */ + tt_face_load_os2, /* TT_Load_Table_Func load_os2 */ + tt_face_load_post, /* TT_Load_Table_Func load_post */ - tt_face_load_name, - tt_face_free_name, + tt_face_load_name, /* TT_Load_Table_Func load_name */ + tt_face_free_name, /* TT_Free_Table_Func free_name */ - tt_face_load_kern, - tt_face_load_gasp, - tt_face_load_pclt, + tt_face_load_kern, /* TT_Load_Table_Func load_kern */ + tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */ + tt_face_load_pclt, /* TT_Load_Table_Func load_init */ /* see `ttload.h' */ PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ), - + /* TT_Load_Table_Func load_bhed */ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ), + /* TT_Load_SBit_Image_Func load_sbit_image */ /* see `ttpost.h' */ PUT_PS_NAMES( tt_face_get_ps_name ), + /* TT_Get_PS_Name_Func get_psname */ PUT_PS_NAMES( tt_face_free_ps_names ), + /* TT_Free_Table_Func free_psnames */ /* since version 2.1.8 */ - tt_face_get_kerning, + tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */ /* since version 2.2 */ - tt_face_load_font_dir, - tt_face_load_hmtx, + tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */ + tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */ /* see `ttsbit.h' and `sfnt.h' */ PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ), + /* TT_Load_Table_Func load_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ), + /* TT_Free_Table_Func free_eblc */ PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ), + /* TT_Set_SBit_Strike_Func set_sbit_strike */ PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ), + /* TT_Load_Strike_Metrics_Func load_strike_metrics */ - tt_face_get_metrics, + tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */ - tt_face_get_name + tt_face_get_name /* TT_Get_Name_Func get_name */ ) diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c index 2e8c1ecde6f..4413bbcf2a9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/sfobjs.c @@ -977,7 +977,7 @@ #endif face->root.num_faces = face->ttc_header.count; - face->root.face_index = face_index; + face->root.face_index = face_instance_index; return error; } diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c index 01255a887ee..cd7467d4d86 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttcmap.c @@ -763,6 +763,9 @@ static void tt_cmap4_next( TT_CMap4 cmap ) { + TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face; + FT_Byte* limit = face->cmap_table + face->cmap_size; + FT_UInt charcode; @@ -788,15 +791,19 @@ FT_Byte* p = values + 2 * ( charcode - cmap->cur_start ); + /* if p > limit, the whole segment is invalid */ + if ( p > limit ) + goto Next_Segment; + do { FT_UInt gindex = FT_NEXT_USHORT( p ); - if ( gindex != 0 ) + if ( gindex ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; - if ( gindex != 0 ) + if ( gindex ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; @@ -812,7 +819,26 @@ FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; - if ( gindex != 0 ) + if ( gindex >= (FT_UInt)face->root.num_glyphs ) + { + /* we have an invalid glyph index; if there is an overflow, */ + /* we can adjust `charcode', otherwise the whole segment is */ + /* invalid */ + gindex = 0; + + if ( (FT_Int)charcode + delta < 0 && + (FT_Int)end + delta >= 0 ) + charcode = (FT_UInt)( -delta ); + + else if ( (FT_Int)charcode + delta < 0x10000L && + (FT_Int)end + delta >= 0x10000L ) + charcode = (FT_UInt)( 0x10000L - delta ); + + else + goto Next_Segment; + } + + if ( gindex ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; @@ -822,6 +848,7 @@ } } + Next_Segment: /* we need to find another range */ if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 ) break; @@ -1170,6 +1197,9 @@ FT_UInt32* pcharcode, FT_Bool next ) { + TT_Face face = (TT_Face)cmap->cmap.charmap.face; + FT_Byte* limit = face->cmap_table + face->cmap_size; + FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt max, min, mid, num_segs; @@ -1221,10 +1251,6 @@ if ( mid >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { - TT_Face face = (TT_Face)cmap->cmap.charmap.face; - FT_Byte* limit = face->cmap_table + face->cmap_size; - - if ( offset && p + offset + 2 > limit ) { delta = 1; @@ -1347,13 +1373,40 @@ if ( offset ) { p += offset + ( charcode - start ) * 2; + + /* if p > limit, the whole segment is invalid */ + if ( next && p > limit ) + break; + gindex = TT_PEEK_USHORT( p ); - if ( gindex != 0 ) + if ( gindex ) + { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; + if ( gindex >= (FT_UInt)face->root.num_glyphs ) + gindex = 0; + } } else + { gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; + if ( next && gindex >= (FT_UInt)face->root.num_glyphs ) + { + /* we have an invalid glyph index; if there is an overflow, */ + /* we can adjust `charcode', otherwise the whole segment is */ + /* invalid */ + gindex = 0; + + if ( (FT_Int)charcode + delta < 0 && + (FT_Int)end + delta >= 0 ) + charcode = (FT_UInt)( -delta ); + + else if ( (FT_Int)charcode + delta < 0x10000L && + (FT_Int)end + delta >= 0x10000L ) + charcode = (FT_UInt)( 0x10000L - delta ); + } + } + break; } } diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c index 2f5b2c38438..a653a718690 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttload.c @@ -775,15 +775,6 @@ maxProfile->maxTwilightPoints = 0xFFFFU - 4; } - - /* we arbitrarily limit recursion to avoid stack exhaustion */ - if ( maxProfile->maxComponentDepth > 100 ) - { - FT_TRACE0(( "tt_face_load_maxp:" - " abnormally large component depth (%d) set to 100\n", - maxProfile->maxComponentDepth )); - maxProfile->maxComponentDepth = 100; - } } FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs )); @@ -1193,8 +1184,8 @@ #define FT_STRUCTURE TT_Postscript FT_FRAME_START( 32 ), - FT_FRAME_ULONG( FormatType ), - FT_FRAME_ULONG( italicAngle ), + FT_FRAME_LONG ( FormatType ), + FT_FRAME_LONG ( italicAngle ), FT_FRAME_SHORT( underlinePosition ), FT_FRAME_SHORT( underlineThickness ), FT_FRAME_ULONG( isFixedPitch ), diff --git a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c index e24e7d6cdd8..36c261dcce9 100644 --- a/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c +++ b/Build/source/libs/freetype2/freetype-src/src/sfnt/ttsbit.c @@ -197,6 +197,27 @@ if ( !error ) FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes )); + face->ebdt_start = 0; + face->ebdt_size = 0; + + if ( face->sbit_table_type != TT_SBIT_TABLE_TYPE_NONE ) + { + FT_ULong ebdt_size; + + + error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size ); + if ( error ) + error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size ); + if ( error ) + error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size ); + + if ( !error ) + { + face->ebdt_start = FT_STREAM_POS(); + face->ebdt_size = ebdt_size; + } + } + return FT_Err_Ok; Exit: @@ -323,6 +344,16 @@ strike[18] + /* max_width */ (FT_Char)strike[23] /* min_advance_SB */ ) * 64; + + /* set the scale values (in 16.16 units) so advances */ + /* from the hmtx and vmtx table are scaled correctly */ + metrics->x_scale = FT_MulDiv( metrics->x_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + metrics->y_scale = FT_MulDiv( metrics->y_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + return FT_Err_Ok; } @@ -414,17 +445,13 @@ FT_ULong strike_index, TT_SBit_MetricsRec* metrics ) { - FT_Error error; + FT_Error error = FT_ERR( Table_Missing ); FT_Stream stream = face->root.stream; - FT_ULong ebdt_size; - error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size ); - if ( error ) - error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size ); - if ( error ) - error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size ); - if ( error ) + if ( !face->ebdt_size ) + goto Exit; + if ( FT_STREAM_SEEK( face->ebdt_start ) ) goto Exit; decoder->face = face; @@ -435,8 +462,8 @@ decoder->metrics_loaded = 0; decoder->bitmap_allocated = 0; - decoder->ebdt_start = FT_STREAM_POS(); - decoder->ebdt_size = ebdt_size; + decoder->ebdt_start = face->ebdt_start; + decoder->ebdt_size = face->ebdt_size; decoder->eblc_base = face->sbit_table; decoder->eblc_limit = face->sbit_table + face->sbit_table_size; @@ -854,7 +881,7 @@ } *pwrite++ |= ( ( rval >> nbits ) & 0xFF ) & - ( ~( 0xFF << w ) << ( 8 - w - x_pos ) ); + ( ~( 0xFFU << w ) << ( 8 - w - x_pos ) ); rval <<= 8; w = line_bits - w; diff --git a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c index 0bf3ac6ffb7..59fafdb4def 100644 --- a/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c +++ b/Build/source/libs/freetype2/freetype-src/src/smooth/ftgrays.c @@ -403,9 +403,12 @@ typedef ptrdiff_t FT_PtrDist; } TCell; + typedef struct TPixmap_ + { + unsigned char* origin; /* pixmap origin at the bottom-left */ + int pitch; /* pitch to go down one row */ - /* maximum number of gray spans in a call to the span callback */ -#define FT_MAX_GRAY_SPANS 32 + } TPixmap; /* maximum number of gray cells in the buffer */ #if FT_RENDER_POOL_SIZE > 2048 @@ -430,7 +433,6 @@ typedef ptrdiff_t FT_PtrDist; TCoord ex, ey; TCoord min_ex, max_ex; TCoord min_ey, max_ey; - TCoord count_ex, count_ey; TArea area; TCoord cover; @@ -443,14 +445,10 @@ typedef ptrdiff_t FT_PtrDist; TPos x, y; FT_Outline outline; - FT_Bitmap target; - - FT_Span gray_spans[FT_MAX_GRAY_SPANS]; - int num_gray_spans; + TPixmap target; FT_Raster_Span_Func render_span; void* render_span_data; - int span_y; PCell* ycells; @@ -482,17 +480,17 @@ typedef ptrdiff_t FT_PtrDist; static void gray_dump_cells( RAS_ARG ) { - int yindex; + int y; - for ( yindex = 0; yindex < ras.count_ey; yindex++ ) + for ( y = ras.min_ey; y < ras.max_ey; y++ ) { - PCell cell; + PCell cell = ras.ycells[y - ras.min_ey]; - printf( "%3d:", yindex ); + printf( "%3d:", y ); - for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next ) + for ( ; cell != NULL; cell = cell->next ) printf( " (%3d, c:%4d, a:%6d)", cell->x, cell->cover, cell->area ); printf( "\n" ); @@ -513,10 +511,10 @@ typedef ptrdiff_t FT_PtrDist; TCoord x = ras.ex; - if ( x > ras.count_ex ) - x = ras.count_ex; + if ( x > ras.max_ex ) + x = ras.max_ex; - pcell = &ras.ycells[ras.ey]; + pcell = &ras.ycells[ras.ey - ras.min_ey]; for (;;) { cell = *pcell; @@ -579,14 +577,11 @@ typedef ptrdiff_t FT_PtrDist; /* All cells that are on the left of the clipping region go to the */ /* min_ex - 1 horizontal position. */ - ey -= ras.min_ey; - if ( ex > ras.max_ex ) ex = ras.max_ex; - ex -= ras.min_ex; - if ( ex < 0 ) - ex = -1; + if ( ex < ras.min_ex ) + ex = ras.min_ex - 1; /* are we moving to a different cell ? */ if ( ex != ras.ex || ey != ras.ey ) @@ -601,34 +596,11 @@ typedef ptrdiff_t FT_PtrDist; ras.ey = ey; } - ras.invalid = ( (unsigned int)ey >= (unsigned int)ras.count_ey || - ex >= ras.count_ex ); + ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey || + ex >= ras.max_ex ); } - /*************************************************************************/ - /* */ - /* Start a new contour at a given cell. */ - /* */ - static void - gray_start_cell( RAS_ARG_ TCoord ex, - TCoord ey ) - { - if ( ex > ras.max_ex ) - ex = ras.max_ex; - - if ( ex < ras.min_ex ) - ex = ras.min_ex - 1; - - ras.area = 0; - ras.cover = 0; - ras.ex = ex - ras.min_ex; - ras.ey = ey - ras.min_ey; - ras.invalid = 0; - - gray_set_cell( RAS_VAR_ ex, ey ); - } - #ifndef FT_LONG64 /*************************************************************************/ @@ -657,14 +629,14 @@ typedef ptrdiff_t FT_PtrDist; return; } - fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); - fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); + fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); + fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); + delta = y2 - y1; /* everything is located in a single cell. That is easy! */ /* */ if ( ex1 == ex2 ) { - delta = y2 - y1; ras.area += (TArea)(( fx1 + fx2 ) * delta); ras.cover += delta; return; @@ -673,14 +645,17 @@ typedef ptrdiff_t FT_PtrDist; /* ok, we'll have to render a run of adjacent cells on the same */ /* scanline... */ /* */ - p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 ); - first = ONE_PIXEL; - incr = 1; - dx = x2 - x1; + dx = x2 - x1; - if ( dx < 0 ) + if ( dx > 0 ) + { + p = ( ONE_PIXEL - fx1 ) * delta; + first = ONE_PIXEL; + incr = 1; + } + else { - p = fx1 * ( y2 - y1 ); + p = fx1 * delta; first = 0; incr = -1; dx = -dx; @@ -764,8 +739,6 @@ typedef ptrdiff_t FT_PtrDist; dy = to_y - ras.y; /* vertical line - avoid calling gray_render_scanline */ - incr = 1; - if ( dx == 0 ) { TCoord ex = TRUNC( ras.x ); @@ -773,8 +746,12 @@ typedef ptrdiff_t FT_PtrDist; TArea area; - first = ONE_PIXEL; - if ( dy < 0 ) + if ( dy > 0) + { + first = ONE_PIXEL; + incr = 1; + } + else { first = 0; incr = -1; @@ -806,11 +783,13 @@ typedef ptrdiff_t FT_PtrDist; } /* ok, we have to render several scanlines */ - p = ( ONE_PIXEL - fy1 ) * dx; - first = ONE_PIXEL; - incr = 1; - - if ( dy < 0 ) + if ( dy > 0) + { + p = ( ONE_PIXEL - fy1 ) * dx; + first = ONE_PIXEL; + incr = 1; + } + else { p = fy1 * dx; first = 0; @@ -1218,15 +1197,11 @@ typedef ptrdiff_t FT_PtrDist; TPos x, y; - /* record current cell, if any */ - if ( !ras.invalid ) - gray_record_cell( RAS_VAR ); - /* start to a new position */ x = UPSCALE( to->x ); y = UPSCALE( to->y ); - gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); + gray_set_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); ras.x = x; ras.y = y; @@ -1265,59 +1240,13 @@ typedef ptrdiff_t FT_PtrDist; static void - gray_render_span( int y, - int count, - const FT_Span* spans, - gray_PWorker worker ) - { - unsigned char* p; - FT_Bitmap* map = &worker->target; - - - /* first of all, compute the scanline offset */ - p = (unsigned char*)map->buffer - y * map->pitch; - if ( map->pitch >= 0 ) - p += ( map->rows - 1 ) * (unsigned int)map->pitch; - - for ( ; count > 0; count--, spans++ ) - { - unsigned char coverage = spans->coverage; - - - if ( coverage ) - { - unsigned char* q = p + spans->x; - - - /* For small-spans it is faster to do it by ourselves than - * calling `memset'. This is mainly due to the cost of the - * function call. - */ - switch ( spans->len ) - { - case 7: *q++ = coverage; - case 6: *q++ = coverage; - case 5: *q++ = coverage; - case 4: *q++ = coverage; - case 3: *q++ = coverage; - case 2: *q++ = coverage; - case 1: *q = coverage; - case 0: break; - default: - FT_MEM_SET( q, coverage, spans->len ); - } - } - } - } - - - static void gray_hline( RAS_ARG_ TCoord x, TCoord y, TArea area, TCoord acount ) { - int coverage; + int coverage; + FT_Span span; /* compute the coverage line's coverage, depending on the */ @@ -1346,64 +1275,37 @@ typedef ptrdiff_t FT_PtrDist; coverage = 255; } - y += ras.min_ey; - x += ras.min_ex; + if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */ + { + span.x = (short)x; + span.len = (unsigned short)acount; + span.coverage = (unsigned char)coverage; - if ( coverage ) + ras.render_span( y, 1, &span, ras.render_span_data ); + } + else { - FT_Span* span; - int count; + unsigned char* q = ras.target.origin - ras.target.pitch * y + x; + unsigned char c = (unsigned char)coverage; - /* see whether we can add this span to the current list */ - count = ras.num_gray_spans; - span = ras.gray_spans + count - 1; - if ( span->coverage == coverage && - span->x + span->len == x && - ras.span_y == y && - count > 0 ) + /* For small-spans it is faster to do it by ourselves than + * calling `memset'. This is mainly due to the cost of the + * function call. + */ + switch ( acount ) { - span->len = (unsigned short)( span->len + acount ); - return; + case 7: *q++ = c; + case 6: *q++ = c; + case 5: *q++ = c; + case 4: *q++ = c; + case 3: *q++ = c; + case 2: *q++ = c; + case 1: *q = c; + case 0: break; + default: + FT_MEM_SET( q, c, acount ); } - - if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS ) - { - if ( ras.render_span && count > 0 ) - ras.render_span( ras.span_y, count, ras.gray_spans, - ras.render_span_data ); - -#ifdef FT_DEBUG_LEVEL_TRACE - - if ( count > 0 ) - { - int n; - - - FT_TRACE7(( "y = %3d ", ras.span_y )); - span = ras.gray_spans; - for ( n = 0; n < count; n++, span++ ) - FT_TRACE7(( "[%d..%d]:%02x ", - span->x, span->x + span->len - 1, span->coverage )); - FT_TRACE7(( "\n" )); - } - -#endif /* FT_DEBUG_LEVEL_TRACE */ - - ras.num_gray_spans = 0; - ras.span_y = (int)y; - - span = ras.gray_spans; - } - else - span++; - - /* add a gray span to the current list */ - span->x = (short)x; - span->len = (unsigned short)acount; - span->coverage = (unsigned char)coverage; - - ras.num_gray_spans++; } } @@ -1411,22 +1313,19 @@ typedef ptrdiff_t FT_PtrDist; static void gray_sweep( RAS_ARG ) { - int yindex; + int y; if ( ras.num_cells == 0 ) return; - ras.num_gray_spans = 0; - ras.span_y = 0; - FT_TRACE7(( "gray_sweep: start\n" )); - for ( yindex = 0; yindex < ras.count_ey; yindex++ ) + for ( y = ras.min_ey; y < ras.max_ey; y++ ) { - PCell cell = ras.ycells[yindex]; + PCell cell = ras.ycells[y - ras.min_ey]; TCoord cover = 0; - TCoord x = 0; + TCoord x = ras.min_ex; for ( ; cell != NULL; cell = cell->next ) @@ -1434,48 +1333,25 @@ typedef ptrdiff_t FT_PtrDist; TArea area; - if ( cell->x > x && cover != 0 ) - gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ), + if ( cover != 0 && cell->x > x ) + gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ), cell->x - x ); cover += cell->cover; area = (TArea)cover * ( ONE_PIXEL * 2 ) - cell->area; - if ( area != 0 && cell->x >= 0 ) - gray_hline( RAS_VAR_ cell->x, yindex, area, 1 ); + if ( area != 0 && cell->x >= ras.min_ex ) + gray_hline( RAS_VAR_ cell->x, y, area, 1 ); x = cell->x + 1; } if ( cover != 0 ) - gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ), - ras.count_ex - x ); - } - - if ( ras.render_span && ras.num_gray_spans > 0 ) - ras.render_span( ras.span_y, ras.num_gray_spans, - ras.gray_spans, ras.render_span_data ); - -#ifdef FT_DEBUG_LEVEL_TRACE - - if ( ras.num_gray_spans > 0 ) - { - FT_Span* span; - int n; - - - FT_TRACE7(( "y = %3d ", ras.span_y )); - span = ras.gray_spans; - for ( n = 0; n < ras.num_gray_spans; n++, span++ ) - FT_TRACE7(( "[%d..%d]:%02x ", - span->x, span->x + span->len - 1, span->coverage )); - FT_TRACE7(( "\n" )); + gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ), + ras.max_ex - x ); } FT_TRACE7(( "gray_sweep: end\n" )); - -#endif /* FT_DEBUG_LEVEL_TRACE */ - } @@ -1839,13 +1715,6 @@ typedef ptrdiff_t FT_PtrDist; #endif /* STANDALONE_ */ - typedef struct gray_TBand_ - { - TCoord min, max; - - } gray_TBand; - - FT_DEFINE_OUTLINE_FUNCS( func_interface, @@ -1892,20 +1761,21 @@ typedef ptrdiff_t FT_PtrDist; static int gray_convert_glyph( RAS_ARG ) { - TCell buffer[FT_MAX_GRAY_POOL]; - TCoord band_size = FT_MAX_GRAY_POOL / 8; - int num_bands; - TCoord min, max, max_y; - gray_TBand bands[32]; /* enough to accommodate bisections */ - gray_TBand* band; + TCell buffer[FT_MAX_GRAY_POOL]; + TCoord band_size = FT_MAX_GRAY_POOL / 8; + TCoord count = ras.max_ey - ras.min_ey; + int num_bands; + TCoord min, max, max_y; + TCoord bands[32]; /* enough to accommodate bisections */ + TCoord* band; /* set up vertical bands */ - if ( ras.count_ey > band_size ) + if ( count > band_size ) { /* two divisions rounded up */ - num_bands = (int)( ( ras.count_ey + band_size - 1) / band_size ); - band_size = ( ras.count_ey + num_bands - 1 ) / num_bands; + num_bands = (int)( ( count + band_size - 1) / band_size ); + band_size = ( count + num_bands - 1 ) / num_bands; } min = ras.min_ey; @@ -1917,19 +1787,19 @@ typedef ptrdiff_t FT_PtrDist; if ( max > max_y ) max = max_y; - bands[0].min = min; - bands[0].max = max; - band = bands; + band = bands; + band[1] = min; + band[0] = max; do { - TCoord bottom, top, middle; + TCoord width = band[0] - band[1]; int error; /* memory management */ { - size_t ycount = (size_t)( band->max - band->min ); + size_t ycount = (size_t)width; size_t cell_start; @@ -1949,9 +1819,8 @@ typedef ptrdiff_t FT_PtrDist; ras.num_cells = 0; ras.invalid = 1; - ras.min_ey = band->min; - ras.max_ey = band->max; - ras.count_ey = band->max - band->min; + ras.min_ey = band[1]; + ras.max_ey = ras.ey = band[0]; error = gray_convert_glyph_inner( RAS_VAR ); @@ -1966,23 +1835,19 @@ typedef ptrdiff_t FT_PtrDist; ReduceBands: /* render pool overflow; we will reduce the render band by half */ - bottom = band->min; - top = band->max; - middle = bottom + ( ( top - bottom ) >> 1 ); + width >>= 1; /* This is too complex for a single scanline; there must */ /* be some problems. */ - if ( middle == bottom ) + if ( width == 0 ) { FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" )); return 1; } - band[1].min = bottom; - band[1].max = middle; - band[0].min = middle; - band[0].max = top; band++; + band[1] = band[0]; + band[0] += width; } while ( band >= bands ); } @@ -1998,12 +1863,18 @@ typedef ptrdiff_t FT_PtrDist; const FT_Bitmap* target_map = params->target; FT_BBox cbox, clip; +#ifndef FT_STATIC_RASTER gray_TWorker worker[1]; +#endif if ( !raster ) return FT_THROW( Invalid_Argument ); + /* this version does not support monochrome rendering */ + if ( !( params->flags & FT_RASTER_FLAG_AA ) ) + return FT_THROW( Invalid_Mode ); + if ( !outline ) return FT_THROW( Invalid_Outline ); @@ -2018,9 +1889,19 @@ typedef ptrdiff_t FT_PtrDist; outline->contours[outline->n_contours - 1] + 1 ) return FT_THROW( Invalid_Outline ); - /* if direct mode is not set, we must have a target bitmap */ - if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) + ras.outline = *outline; + + if ( params->flags & FT_RASTER_FLAG_DIRECT ) + { + if ( !params->gray_spans ) + return 0; + + ras.render_span = (FT_Raster_Span_Func)params->gray_spans; + ras.render_span_data = params->user; + } + else { + /* if direct mode is not set, we must have a target bitmap */ if ( !target_map ) return FT_THROW( Invalid_Argument ); @@ -2030,11 +1911,18 @@ typedef ptrdiff_t FT_PtrDist; if ( !target_map->buffer ) return FT_THROW( Invalid_Argument ); - } - /* this version does not support monochrome rendering */ - if ( !( params->flags & FT_RASTER_FLAG_AA ) ) - return FT_THROW( Invalid_Mode ); + if ( target_map->pitch < 0 ) + ras.target.origin = target_map->buffer; + else + ras.target.origin = target_map->buffer + + ( target_map->rows - 1 ) * (unsigned int)target_map->pitch; + + ras.target.pitch = target_map->pitch; + + ras.render_span = (FT_Raster_Span_Func)NULL; + ras.render_span_data = NULL; + } FT_Outline_Get_CBox( outline, &cbox ); @@ -2077,23 +1965,6 @@ typedef ptrdiff_t FT_PtrDist; if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey ) return 0; - ras.count_ex = ras.max_ex - ras.min_ex; - ras.count_ey = ras.max_ey - ras.min_ey; - - ras.outline = *outline; - - if ( params->flags & FT_RASTER_FLAG_DIRECT ) - { - ras.render_span = (FT_Raster_Span_Func)params->gray_spans; - ras.render_span_data = params->user; - } - else - { - ras.target = *target_map; - ras.render_span = (FT_Raster_Span_Func)gray_render_span; - ras.render_span_data = &ras; - } - return gray_convert_glyph( RAS_VAR ); } diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile index 2e619299cdf..24dc49c5639 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/Makefile @@ -5,7 +5,12 @@ TOP_DIR ?= ../../.. OBJ_DIR ?= $(TOP_DIR)/objs -# The setup below is for gcc on a Unix-like platform. +# The setup below is for gcc on a Unix-like platform, +# where FreeType has been set up to create a static library +# (which is the default). + +VPATH = $(OBJ_DIR) \ + $(OBJ_DIR)/.libs SRC_DIR = $(TOP_DIR)/src/tools/ftrandom @@ -20,16 +25,21 @@ WFLAGS = -Wmissing-prototypes \ -Wchar-subscripts \ -Wsequence-point CFLAGS = $(WFLAGS) \ - -g \ - -I $(TOP_DIR)/include + -g +INCLUDES = -I $(TOP_DIR)/include +LDFLAGS = LIBS = -lm \ - -L $(OBJ_DIR) \ - -lfreetype \ - -lz + -lz \ + -lpng \ + -lbz2 \ + -lharfbuzz all: $(OBJ_DIR)/ftrandom -$(OBJ_DIR)/ftrandom: $(SRC_DIR)/ftrandom.c $(OBJ_DIR)/libfreetype.a - $(CC) -o $(OBJ_DIR)/ftrandom $(CFLAGS) $(SRC_DIR)/ftrandom.c $(LIBS) +$(OBJ_DIR)/ftrandom.o: $(SRC_DIR)/ftrandom.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $< + +$(OBJ_DIR)/ftrandom: $(OBJ_DIR)/ftrandom.o libfreetype.a + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) # EOF diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README index 71bf05323da..7c610864b6a 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/README @@ -1,48 +1,69 @@ ftrandom --------- +======== This program expects a set of directories containing good fonts, and a set of extensions of fonts to be tested. It will randomly pick a font, copy it, -introduce and error and then test it. +introduce an error and then test it. -The FreeType tests are quite basic: +The FreeType tests are quite basic; for each erroneous font ftrandom - For each erroneous font it - forks off a new tester; - initializes the library; - opens each font in the file; - loads each glyph; - (optionally reviewing the contours of the glyph) - (optionally rasterizing) - closes the face. + . forks off a new tester, + . initializes the library, + . opens each font in the file, + . loads each glyph, + . optionally reviews the contours of the glyph, + . optionally rasterizes the glyph, and + . closes the face. -If the tester exits with a signal, or takes longer than 20 seconds then -ftrandom saves the erroneous font and continues. If the tester exits -normally or with an error, then the superstructure removes the test font and -continues. +If a tester takes longer than 20 seconds, ftrandom saves the erroneous font +and continues. If the tester exits normally or with an error, then the +superstructure removes the test font and continues. -Arguments are: + +Command line options +-------------------- --all Test every font in the directory(ies) no matter - what its extension (some CID-keyed fonts have no - extension). - --check-outlines Call FT_Outline_Decompose on each glyph. + what its extension. + --check-outlines Call `FT_Outline_Decompose' on each glyph. --dir <dir> Append <dir> to the list of directories to search - for good fonts. + for good fonts. No recursive search. --error-count <cnt> Introduce <cnt> single-byte errors into the - erroneous fonts. + erroneous fonts (default: 1). --error-fraction <frac> Multiply the file size of the font by <frac> and introduce that many errors into the erroneous - font file. - --ext <ext> Add <ext> to the set of font types tested. Known - extensions are `ttf', `otf', `ttc', `cid', `pfb', - `pfa', `bdf', `pcf', `pfr', `fon', `otb', and - `cff'. + font file. <frac> should be in the range [0;1] + (default: 0.0). + --ext <ext> Add <ext> to the set of font types tested. --help Print out this list of options. --nohints Specify FT_LOAD_NO_HINTING when loading glyphs. - --rasterize Call FT_Render_Glyph as well as loading it. + --rasterize Call `FT_Render_Glyph' as well as loading it. --result <dir> This is the directory in which test files are placed. --test <file> Run a single test on a pre-generated testcase. - Done in the current process so it can be debugged - more easily. + This is done in the current process so it can be + debugged more easily. + +The default font extensions tested by ftrandom are + + .ttf .otf .ttc .cid .pfb .pfa .bdf .pcf .pfr .fon .otb .cff + +The default font directory is controlled by the macro `GOOD_FONTS_DIR' in +the source code (and can be thus specified during compilation); its default +value is + + /usr/local/share/fonts + +The default result directory is `results' (in the current directory). + + +Compilation +----------- + +Two possible solutions. + +. Run ftrandom within a debugging tool like `valgrind' to catch various + memory issues. + +. Compile FreeType with sanitizer flags as provided by gcc or clang, for + example, then link it with ftrandom. diff --git a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c index 9a5b632673c..ff311690927 100644 --- a/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c +++ b/Build/source/libs/freetype2/freetype-src/src/tools/ftrandom/ftrandom.c @@ -29,6 +29,9 @@ /* This file is now part of the FreeType library */ +#define _XOPEN_SOURCE 500 /* for `kill', `strdup', `random', and `srandom' */ + + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -38,7 +41,6 @@ #include <sys/wait.h> #include <unistd.h> #include <dirent.h> -#include <math.h> #include <signal.h> #include <time.h> @@ -56,7 +58,7 @@ static int rasterize = false; static char* results_dir = "results"; -#define GOOD_FONTS_DIR "/home/wl/freetype-testfonts" +#define GOOD_FONTS_DIR "/usr/local/share/fonts" static char* default_dir_list[] = { @@ -81,28 +83,31 @@ NULL }; - static int error_count = 1; - static int error_fraction = 0; + static unsigned int error_count = 1; + static double error_fraction = 0.0; static FT_F26Dot6 font_size = 12 * 64; static struct fontlist { char* name; - int len; + long len; unsigned int isbinary: 1; unsigned int isascii: 1; unsigned int ishex: 1; } *fontlist; - static int fcnt; + static unsigned int fcnt; static int FT_MoveTo( const FT_Vector *to, void *user ) { + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -111,6 +116,9 @@ FT_LineTo( const FT_Vector *to, void *user ) { + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -120,6 +128,10 @@ const FT_Vector *to, void *user ) { + FT_UNUSED( _cp ); + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -130,6 +142,11 @@ const FT_Vector *to, void *user ) { + FT_UNUSED( cp1 ); + FT_UNUSED( cp2 ); + FT_UNUSED( to ); + FT_UNUSED( user ); + return 0; } @@ -147,8 +164,8 @@ static void TestFace( FT_Face face ) { - int gid; - int load_flags = FT_LOAD_DEFAULT; + unsigned int gid; + int load_flags = FT_LOAD_DEFAULT; if ( check_outlines && @@ -202,7 +219,7 @@ TestFace( face ); else { - int i, num; + long i, num; num = face->num_faces; @@ -215,6 +232,8 @@ } } + FT_Done_FreeType( context ); + exit( 0 ); } @@ -329,9 +348,10 @@ FindFonts( char** fontdirs, char** extensions ) { - int i, max; - char buffer[1025]; - struct stat statb; + int i; + unsigned int max; + char buffer[1025]; + struct stat statb; max = 0; @@ -392,13 +412,13 @@ } - static int + static unsigned int getErrorCnt( struct fontlist* item ) { - if ( error_count == 0 && error_fraction == 0 ) + if ( error_count == 0 && error_fraction == 0.0 ) return 0; - return error_count + ceil( error_fraction * item->len ); + return error_count + (unsigned int)( error_fraction * item->len ); } @@ -417,10 +437,10 @@ copyfont( struct fontlist* item, char* newfont ) { - static char buffer[8096]; - FILE *good, *new; - int len; - int i, err_cnt; + static char buffer[8096]; + FILE *good, *new; + size_t len; + unsigned int i, err_cnt; good = fopen( item->name, "r" ); @@ -446,7 +466,7 @@ err_cnt = getErrorCnt( item ); for ( i = 0; i < err_cnt; ++i ) { - fseek( new, getRandom( 0, item->len - 1 ), SEEK_SET ); + fseek( new, getRandom( 0, (int)( item->len - 1 ) ), SEEK_SET ); if ( item->isbinary ) putc( getRandom( 0, 0xFF ), new ); @@ -484,6 +504,8 @@ static void abort_test( int sig ) { + FT_UNUSED( sig ); + /* If a time-out happens, then kill the child */ kill( child_pid, SIGFPE ); write( 2, "Timeout... ", 11 ); @@ -493,7 +515,7 @@ static void do_test( void ) { - int i = getRandom( 0, fcnt - 1 ); + int i = getRandom( 0, (int)( fcnt - 1 ) ); static int test_num = 0; char buffer[1024]; @@ -534,22 +556,42 @@ usage( FILE* out, char* name ) { + char** d = default_dir_list; + char** e = default_ext_list; + + fprintf( out, "%s [options] -- Generate random erroneous fonts\n" " and attempt to parse them with FreeType.\n\n", name ); fprintf( out, " --all All non-directory files are assumed to be fonts.\n" ); fprintf( out, " --check-outlines Make sure we can parse the outlines of each glyph.\n" ); - fprintf( out, " --dir <path> Append <path> to list of font search directories.\n" ); - fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font.\n" ); + fprintf( out, " --dir <path> Append <path> to list of font search directories\n" + " (no recursive search).\n" ); + fprintf( out, " --error-count <cnt> Introduce <cnt> single byte errors into each font\n" + " (default: 1)\n" ); fprintf( out, " --error-fraction <frac> Introduce <frac>*filesize single byte errors\n" - " into each font.\n" ); + " into each font (default: 0.0).\n" ); fprintf( out, " --ext <ext> Add <ext> to list of extensions indicating fonts.\n" ); fprintf( out, " --help Print this.\n" ); fprintf( out, " --nohints Turn off hinting.\n" ); fprintf( out, " --rasterize Attempt to rasterize each glyph.\n" ); - fprintf( out, " --results <dir> Directory in which to place the test fonts.\n" ); + fprintf( out, " --results <path> Place the created test fonts into <path>\n" + " (default: `results')\n" ); fprintf( out, " --size <float> Use the given font size for the tests.\n" ); fprintf( out, " --test <file> Run a single test on an already existing file.\n" ); + fprintf( out, "\n" ); + + fprintf( out, "Default font extensions:\n" ); + fprintf( out, " " ); + while ( *e ) + fprintf( out, " .%s", *e++ ); + fprintf( out, "\n" ); + + fprintf( out, "Default font directories:\n" ); + fprintf( out, " " ); + while ( *d ) + fprintf( out, " %s", *d++ ); + fprintf( out, "\n" ); } @@ -564,8 +606,8 @@ char* testfile = NULL; - dirs = calloc( argc + 1, sizeof ( char ** ) ); - exts = calloc( argc + 1, sizeof ( char ** ) ); + dirs = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) ); + exts = calloc( (size_t)( argc + 1 ), sizeof ( char ** ) ); for ( i = 1; i < argc; ++i ) { @@ -585,9 +627,9 @@ else if ( strcmp( pt, "-error-count" ) == 0 ) { if ( !rset ) - error_fraction = 0; + error_fraction = 0.0; rset = true; - error_count = strtol( argv[++i], &end, 10 ); + error_count = (unsigned int)strtoul( argv[++i], &end, 10 ); if ( *end != '\0' ) { fprintf( stderr, "Bad value for error-count: %s\n", argv[i] ); @@ -605,6 +647,11 @@ fprintf( stderr, "Bad value for error-fraction: %s\n", argv[i] ); exit( 1 ); } + if ( error_fraction < 0.0 || error_fraction > 1.0 ) + { + fprintf( stderr, "error-fraction must be in the range [0;1]\n" ); + exit( 1 ); + } } else if ( strcmp( pt, "-ext" ) == 0 ) exts[ecnt++] = argv[++i]; @@ -658,7 +705,7 @@ ExecuteTest( testfile ); /* This should never return */ time( &now ); - srandom( now ); + srandom( (unsigned int)now ); FindFonts( dirs, exts ); mkdir( results_dir, 0755 ); diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c index c9d4081efe3..6520c93df65 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttdriver.c @@ -61,26 +61,48 @@ static FT_Error tt_property_set( FT_Module module, /* TT_Driver */ const char* property_name, - const void* value ) + const void* value, + FT_Bool value_is_string ) { FT_Error error = FT_Err_Ok; TT_Driver driver = (TT_Driver)module; +#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + FT_UNUSED( value_is_string ); +#endif + if ( !ft_strcmp( property_name, "interpreter-version" ) ) { - FT_UInt* interpreter_version = (FT_UInt*)value; + FT_UInt interpreter_version; + + +#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES + if ( value_is_string ) + { + const char* s = (const char*)value; + + + interpreter_version = (FT_UInt)ft_strtol( s, NULL, 10 ); + } + else +#endif + { + FT_UInt* iv = (FT_UInt*)value; + + interpreter_version = *iv; + } - if ( *interpreter_version == TT_INTERPRETER_VERSION_35 + if ( interpreter_version == TT_INTERPRETER_VERSION_35 #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY - || *interpreter_version == TT_INTERPRETER_VERSION_38 + || interpreter_version == TT_INTERPRETER_VERSION_38 #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - || *interpreter_version == TT_INTERPRETER_VERSION_40 + || interpreter_version == TT_INTERPRETER_VERSION_40 #endif ) - driver->interpreter_version = *interpreter_version; + driver->interpreter_version = interpreter_version; else error = FT_ERR( Unimplemented_Feature ); @@ -317,6 +339,25 @@ { error = tt_size_reset( ttsize ); ttsize->root.metrics = ttsize->metrics; + +#ifdef TT_USE_BYTECODE_INTERPRETER + /* for the `MPS' bytecode instruction we need the point size */ + { + FT_UInt resolution = ttsize->metrics.x_ppem > ttsize->metrics.y_ppem + ? req->horiResolution + : req->vertResolution; + + + /* if we don't have a resolution value, assume 72dpi */ + if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES || + !resolution ) + resolution = 72; + + ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem, + 64 * 72, + resolution ); + } +#endif } return error; diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c index 8be9b6ae65d..2d0b29f0715 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgload.c @@ -1436,13 +1436,12 @@ FT_TRACE5(( " nesting level: %d\n", recurse_count )); #endif - /* some fonts have an incorrect value of `maxComponentDepth', */ - /* thus we allow depth 1 to catch the majority of them */ - if ( recurse_count > 1 && - recurse_count > face->max_profile.maxComponentDepth ) + /* some fonts have an incorrect value of `maxComponentDepth' */ + if ( recurse_count > face->max_profile.maxComponentDepth ) { - error = FT_THROW( Invalid_Composite ); - goto Exit; + FT_TRACE1(( "load_truetype_glyph: maxComponentDepth set to %d\n", + recurse_count )); + face->max_profile.maxComponentDepth = (FT_UShort)recurse_count; } #ifndef FT_CONFIG_OPTION_INCREMENTAL @@ -1808,11 +1807,11 @@ for ( i = 0; i < limit; i++, subglyph++ ) { - /* XXX: overflow check for subglyph->{arg1,arg2}. */ - /* Deltas must be within signed 16-bit, */ - /* but the restriction of summed deltas is not clear */ - subglyph->arg1 = (FT_Int16)points[i].x; - subglyph->arg2 = (FT_Int16)points[i].y; + if ( subglyph->flags & ARGS_ARE_XY_VALUES ) + { + subglyph->arg1 = (FT_Int16)points[i].x; + subglyph->arg2 = (FT_Int16)points[i].y; + } } loader->pp1.x = points[i + 0].x; diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c index 9a02c5a8c14..c0d013c17fe 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttgxvar.c @@ -158,48 +158,49 @@ return NULL; } - if ( FT_NEW_ARRAY( points, n ) ) + /* in the nested loops below we increase `i' twice; */ + /* it is faster to simply allocate one more slot */ + /* than to add another test within the loop */ + if ( FT_NEW_ARRAY( points, n + 1 ) ) return NULL; *point_cnt = n; - i = 0; + first = 0; + i = 0; while ( i < n ) { runcnt = FT_GET_BYTE(); if ( runcnt & GX_PT_POINTS_ARE_WORDS ) { runcnt &= GX_PT_POINT_RUN_COUNT_MASK; - first = FT_GET_USHORT(); + first += FT_GET_USHORT(); points[i++] = first; - if ( runcnt < 1 || i + runcnt > n ) - goto Exit; - /* first point not included in run count */ for ( j = 0; j < runcnt; j++ ) { first += FT_GET_USHORT(); points[i++] = first; + if ( i >= n ) + break; } } else { - first = FT_GET_BYTE(); + first += FT_GET_BYTE(); points[i++] = first; - if ( runcnt < 1 || i + runcnt > n ) - goto Exit; - for ( j = 0; j < runcnt; j++ ) { first += FT_GET_BYTE(); points[i++] = first; + if ( i >= n ) + break; } } } - Exit: return points; } @@ -1716,12 +1717,11 @@ /* modeled after `Ins_IUP */ static void - tt_handle_deltas( FT_Outline* outline, - FT_Vector* in_points, - FT_Bool* has_delta ) + tt_interpolate_deltas( FT_Outline* outline, + FT_Vector* out_points, + FT_Vector* in_points, + FT_Bool* has_delta ) { - FT_Vector* out_points; - FT_Int first_point; FT_Int end_point; @@ -1736,8 +1736,6 @@ if ( !outline->n_contours ) return; - out_points = outline->points; - contour = 0; point = 0; @@ -1841,6 +1839,7 @@ GX_Blend blend = face->blend; FT_Vector* points_org = NULL; + FT_Vector* points_out = NULL; FT_Bool* has_delta = NULL; FT_Error error; @@ -1872,6 +1871,7 @@ } if ( FT_NEW_ARRAY( points_org, n_points ) || + FT_NEW_ARRAY( points_out, n_points ) || FT_NEW_ARRAY( has_delta, n_points ) ) goto Fail1; @@ -1894,7 +1894,8 @@ offsetToData = FT_GET_USHORT(); /* rough sanity test */ - if ( offsetToData + tupleCount * 4 > blend->gvar_size ) + if ( offsetToData + ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) * 4 > + blend->gvar_size ) { FT_TRACE2(( "TT_Vary_Apply_Glyph_Deltas:" " invalid glyph variation array header\n" )); @@ -1922,6 +1923,9 @@ FT_TRACE5(( "gvar: there are %d tuples:\n", tupleCount & GX_TC_TUPLE_COUNT_MASK )); + for ( j = 0; j < n_points; j++ ) + points_org[j] = outline->points[j]; + for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); i++ ) { FT_UInt tupleDataSize; @@ -1976,10 +1980,10 @@ here = FT_Stream_FTell( stream ); + FT_Stream_SeekSet( stream, offsetToData ); + if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) { - FT_Stream_SeekSet( stream, offsetToData ); - localpoints = ft_var_readpackedpoints( stream, blend->gvar_size, &point_count ); @@ -2015,22 +2019,20 @@ /* this means that there are deltas for every point in the glyph */ for ( j = 0; j < n_points; j++ ) { -#ifdef FT_DEBUG_LEVEL_TRACE - FT_Vector point_org = outline->points[j]; -#endif + FT_Pos delta_x = FT_MulFix( deltas_x[j], apply ); + FT_Pos delta_y = FT_MulFix( deltas_y[j], apply ); - outline->points[j].x += FT_MulFix( deltas_x[j], apply ); - outline->points[j].y += FT_MulFix( deltas_y[j], apply ); + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; #ifdef FT_DEBUG_LEVEL_TRACE - if ( ( point_org.x != outline->points[j].x ) || - ( point_org.y != outline->points[j].y ) ) + if ( delta_x || delta_y ) { FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", j, - point_org.x, - point_org.y, + outline->points[j].x - delta_x, + outline->points[j].y - delta_y, outline->points[j].x, outline->points[j].y )); count++; @@ -2044,9 +2046,6 @@ #endif } - else if ( localpoints == NULL ) - ; /* failure, ignore it */ - else { #ifdef FT_DEBUG_LEVEL_TRACE @@ -2058,13 +2057,13 @@ /* IUP bytecode instruction */ for ( j = 0; j < n_points; j++ ) { - points_org[j] = outline->points[j]; has_delta[j] = FALSE; + points_out[j] = points_org[j]; } for ( j = 0; j < point_count; j++ ) { - FT_UShort idx = localpoints[j]; + FT_UShort idx = points[j]; if ( idx >= n_points ) @@ -2072,34 +2071,43 @@ has_delta[idx] = TRUE; - outline->points[idx].x += FT_MulFix( deltas_x[j], apply ); - outline->points[idx].y += FT_MulFix( deltas_y[j], apply ); + points_out[idx].x += FT_MulFix( deltas_x[j], apply ); + points_out[idx].y += FT_MulFix( deltas_y[j], apply ); } /* no need to handle phantom points here, */ /* since solitary points can't be interpolated */ - tt_handle_deltas( outline, - points_org, - has_delta ); + tt_interpolate_deltas( outline, + points_out, + points_org, + has_delta ); -#ifdef FT_DEBUG_LEVEL_TRACE FT_TRACE7(( " point deltas:\n" )); - for ( j = 0; j < n_points; j++) + for ( j = 0; j < n_points; j++ ) { - if ( ( points_org[j].x != outline->points[j].x ) || - ( points_org[j].y != outline->points[j].y ) ) + FT_Pos delta_x = points_out[j].x - points_org[j].x; + FT_Pos delta_y = points_out[j].y - points_org[j].y; + + + outline->points[j].x += delta_x; + outline->points[j].y += delta_y; + +#ifdef FT_DEBUG_LEVEL_TRACE + if ( delta_x || delta_y ) { FT_TRACE7(( " %d: (%d, %d) -> (%d, %d)\n", j, - points_org[j].x, - points_org[j].y, + outline->points[j].x - delta_x, + outline->points[j].y - delta_y, outline->points[j].x, outline->points[j].y )); count++; } +#endif } +#ifdef FT_DEBUG_LEVEL_TRACE if ( !count ) FT_TRACE7(( " none\n" )); #endif @@ -2128,6 +2136,7 @@ Fail1: FT_FREE( points_org ); + FT_FREE( points_out ); FT_FREE( has_delta ); return error; diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c index 8fe83c5ea83..2d15ea7121b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c @@ -26,10 +26,14 @@ #include FT_TRIGONOMETRY_H #include FT_SYSTEM_H #include FT_TRUETYPE_DRIVER_H +#include FT_MULTIPLE_MASTERS_H #include "ttinterp.h" #include "tterrors.h" #include "ttsubpix.h" +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT +#include "ttgxvar.h" +#endif #ifdef TT_USE_BYTECODE_INTERPRETER @@ -396,6 +400,7 @@ exec->maxIDefs = size->max_instruction_defs; exec->FDefs = size->function_defs; exec->IDefs = size->instruction_defs; + exec->pointSize = size->point_size; exec->tt_metrics = size->ttmetrics; exec->metrics = size->metrics; @@ -681,17 +686,17 @@ /* IUP[0] */ PACK( 0, 0 ), /* IUP[1] */ PACK( 0, 0 ), - /* SHP[0] */ PACK( 0, 0 ), - /* SHP[1] */ PACK( 0, 0 ), + /* SHP[0] */ PACK( 0, 0 ), /* loops */ + /* SHP[1] */ PACK( 0, 0 ), /* loops */ /* SHC[0] */ PACK( 1, 0 ), /* SHC[1] */ PACK( 1, 0 ), /* SHZ[0] */ PACK( 1, 0 ), /* SHZ[1] */ PACK( 1, 0 ), - /* SHPIX */ PACK( 1, 0 ), - /* IP */ PACK( 0, 0 ), + /* SHPIX */ PACK( 1, 0 ), /* loops */ + /* IP */ PACK( 0, 0 ), /* loops */ /* MSIRP[0] */ PACK( 2, 0 ), /* MSIRP[1] */ PACK( 2, 0 ), - /* AlignRP */ PACK( 0, 0 ), + /* AlignRP */ PACK( 0, 0 ), /* loops */ /* RTDG */ PACK( 0, 0 ), /* MIAP[0] */ PACK( 2, 0 ), /* MIAP[1] */ PACK( 2, 0 ), @@ -764,7 +769,7 @@ /* SANGW */ PACK( 1, 0 ), /* AA */ PACK( 1, 0 ), - /* FlipPT */ PACK( 0, 0 ), + /* FlipPT */ PACK( 0, 0 ), /* loops */ /* FlipRgON */ PACK( 2, 0 ), /* FlipRgOFF */ PACK( 2, 0 ), /* INS_$83 */ PACK( 0, 0 ), @@ -782,8 +787,8 @@ /* INS_$8F */ PACK( 0, 0 ), /* INS_$90 */ PACK( 0, 0 ), - /* INS_$91 */ PACK( 0, 0 ), - /* INS_$92 */ PACK( 0, 0 ), + /* GETVAR */ PACK( 0, 0 ), /* will be handled specially */ + /* GETDATA */ PACK( 0, 1 ), /* INS_$93 */ PACK( 0, 0 ), /* INS_$94 */ PACK( 0, 0 ), /* INS_$95 */ PACK( 0, 0 ), @@ -1065,8 +1070,13 @@ "7 INS_$8F", "7 INS_$90", +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + "6 GETVAR", + "7 GETDATA", +#else "7 INS_$91", "7 INS_$92", +#endif "7 INS_$93", "7 INS_$94", "7 INS_$95", @@ -2574,13 +2584,20 @@ Ins_MPS( TT_ExecContext exc, FT_Long* args ) { - /* Note: The point size should be irrelevant in a given font program; */ - /* we thus decide to return only the PPEM value. */ -#if 0 - args[0] = exc->metrics.pointSize; -#else - args[0] = exc->func_cur_ppem( exc ); -#endif + if ( NO_SUBPIXEL_HINTING ) + { + /* Microsoft's GDI bytecode interpreter always returns value 12; */ + /* we return the current PPEM value instead. */ + args[0] = exc->func_cur_ppem( exc ); + } + else + { + /* A possible practical application of the MPS instruction is to */ + /* implement optical scaling and similar features, which should be */ + /* based on perceptual attributes, thus independent of the */ + /* resolution. */ + args[0] = exc->pointSize; + } } @@ -2873,7 +2890,7 @@ /* */ /* NEG[]: NEGate */ /* Opcode range: 0x65 */ - /* Stack: f26.6 --> f26.6 */ + /* Stack: f26.6 --> f26.6 */ /* */ static void Ins_NEG( FT_Long* args ) @@ -3113,7 +3130,7 @@ /*************************************************************************/ /* */ /* MAX[]: MAXimum */ - /* Opcode range: 0x68 */ + /* Opcode range: 0x8B */ /* Stack: int32? int32? --> int32 */ /* */ static void @@ -3127,7 +3144,7 @@ /*************************************************************************/ /* */ /* MIN[]: MINimum */ - /* Opcode range: 0x69 */ + /* Opcode range: 0x8C */ /* Stack: int32? int32? --> int32 */ /* */ static void @@ -4002,6 +4019,7 @@ exc->error = FT_THROW( Nested_DEFS ); return; case 0x2D: /* ENDF */ + def->end = exc->IP; return; } } @@ -4485,7 +4503,7 @@ /* */ /* FLIPOFF[]: Set auto-FLIP to OFF */ /* Opcode range: 0x4E */ - /* Stack: --> */ + /* Stack: --> */ /* */ static void Ins_FLIPOFF( TT_ExecContext exc ) @@ -6088,7 +6106,6 @@ exc->GS.freeVector.x != 0 && !( exc->sph_tweak_flags & SPH_TWEAK_NORMAL_ROUND ) ) control_value_cutin = minimum_distance = 0; - else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ /* XXX: UNDOCUMENTED! cvt[-1] = 0 always */ @@ -7228,7 +7245,7 @@ /* Return Bit(s): 8 */ /* */ if ( ( args[0] & 2 ) != 0 && exc->tt_metrics.rotated ) - K |= 0x80; + K |= 1 << 8; /********************************/ /* GLYPH STRETCHED */ @@ -7236,7 +7253,18 @@ /* Return Bit(s): 9 */ /* */ if ( ( args[0] & 4 ) != 0 && exc->tt_metrics.stretched ) - K |= 1 << 8; + K |= 1 << 9; + +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + /********************************/ + /* VARIATION GLYPH */ + /* Selector Bit: 3 */ + /* Return Bit(s): 10 */ + /* */ + /* XXX: UNDOCUMENTED! */ + if ( (args[0] & 8 ) != 0 && exc->face->blend ) + K |= 1 << 10; +#endif /********************************/ /* BI-LEVEL HINTING AND */ @@ -7380,6 +7408,57 @@ } +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + + /*************************************************************************/ + /* */ + /* GETVARIATION[]: get normalized variation (blend) coordinates */ + /* Opcode range: 0x91 */ + /* Stack: --> f2.14... */ + /* */ + /* XXX: UNDOCUMENTED! There is no official documentation from Apple for */ + /* this bytecode instruction. Active only if a font has GX */ + /* variation axes. */ + /* */ + static void + Ins_GETVARIATION( TT_ExecContext exc, + FT_Long* args ) + { + FT_UInt num_axes = exc->face->blend->num_axis; + FT_Fixed* coords = exc->face->blend->normalizedcoords; + + FT_UInt i; + + + if ( BOUNDS( num_axes, exc->stackSize + 1 - exc->top ) ) + { + exc->error = FT_THROW( Stack_Overflow ); + return; + } + + for ( i = 0; i < num_axes; i++ ) + args[i] = coords[i] >> 2; /* convert 16.16 to 2.14 format */ + } + + + /*************************************************************************/ + /* */ + /* GETDATA[]: no idea what this is good for */ + /* Opcode range: 0x92 */ + /* Stack: --> 17 */ + /* */ + /* XXX: UNDOCUMENTED! There is no documentation from Apple for this */ + /* very weird bytecode instruction. */ + /* */ + static void + Ins_GETDATA( FT_Long* args ) + { + args[0] = 17; + } + +#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + + static void Ins_UNKNOWN( TT_ExecContext exc ) { @@ -7566,7 +7645,21 @@ exc->args = 0; } - exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 ); +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( exc->opcode == 0x91 ) + { + /* this is very special: GETVARIATION returns */ + /* a variable number of arguments */ + + /* it is the job of the application to `activate' GX handling, */ + /* this is, calling any of the GX API functions on the current */ + /* font to select a variation instance */ + if ( exc->face->blend ) + exc->new_top = exc->args + exc->face->blend->num_axis; + } + else +#endif + exc->new_top = exc->args + ( Pop_Push_Count[exc->opcode] & 15 ); /* `new_top' is the new top of the stack, after the instruction's */ /* execution. `top' will be set to `new_top' after the `switch' */ @@ -7759,7 +7852,7 @@ Ins_ALIGNPTS( exc, args ); break; - case 0x28: /* ???? */ + case 0x28: /* RAW */ Ins_UNKNOWN( exc ); break; @@ -8111,10 +8204,33 @@ Ins_INSTCTRL( exc, args ); break; - case 0x8F: + case 0x8F: /* ADJUST */ + case 0x90: /* ADJUST */ Ins_UNKNOWN( exc ); break; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + case 0x91: + /* it is the job of the application to `activate' GX handling, */ + /* this is, calling any of the GX API functions on the current */ + /* font to select a variation instance */ + if ( exc->face->blend ) + Ins_GETVARIATION( exc, args ); + else + Ins_UNKNOWN( exc ); + break; + + case 0x92: + /* there is at least one MS font (LaoUI.ttf version 5.01) that */ + /* uses IDEFs for 0x91 and 0x92; for this reason we activate */ + /* GETDATA for GX fonts only, similar to GETVARIATION */ + if ( exc->face->blend ) + Ins_GETDATA( args ); + else + Ins_UNKNOWN( exc ); + break; +#endif + default: if ( opcode >= 0xE0 ) Ins_MIRP( exc, args ); diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h index df7ce51f1c6..53f09446bf8 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.h @@ -170,6 +170,7 @@ FT_BEGIN_HEADER pts, twilight; + FT_Long pointSize; /* in 26.6 format */ FT_Size_Metrics metrics; TT_Size_Metrics tt_metrics; /* size metrics */ diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h index ed61a7d5178..98ad383736b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h +++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttobjs.h @@ -286,6 +286,8 @@ FT_BEGIN_HEADER #ifdef TT_USE_BYTECODE_INTERPRETER + FT_Long point_size; /* for the `MPS' bytecode instruction */ + FT_UInt num_function_defs; /* number of function definitions */ FT_UInt max_function_defs; TT_DefArray function_defs; /* table of function definitions */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c index c981adcf2cc..e728cf4507b 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c +++ b/Build/source/libs/freetype2/freetype-src/src/type1/t1load.c @@ -321,7 +321,7 @@ mmvar->num_axis = mmaster.num_axis; mmvar->num_designs = mmaster.num_designs; - mmvar->num_namedstyles = ~0U; /* Does not apply */ + mmvar->num_namedstyles = 0; /* Not supported */ mmvar->axis = (FT_Var_Axis*)&mmvar[1]; /* Point to axes after MM_Var struct */ mmvar->namedstyle = NULL; @@ -1776,6 +1776,12 @@ } } + if ( !n ) + { + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + loader->num_glyphs = n; /* if /.notdef is found but does not occupy index 0, do our magic. */ diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c index c63ed0c8127..54c4eb32883 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42drivr.c @@ -81,7 +81,8 @@ if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) ) - return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] ); + return (FT_UInt)ft_strtol( (const char *)face->type1.charstrings[i], + NULL, 10 ); } return 0; diff --git a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c index 4672c6e164c..089ae0f5af2 100644 --- a/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c +++ b/Build/source/libs/freetype2/freetype-src/src/type42/t42objs.c @@ -656,8 +656,9 @@ FT_TRACE1(( "T42_GlyphSlot_Load: glyph index %d\n", glyph_index )); /* map T42 glyph index to embedded TTF's glyph index */ - glyph_index = (FT_UInt)ft_atol( - (const char *)t42face->type1.charstrings[glyph_index] ); + glyph_index = (FT_UInt)ft_strtol( + (const char *)t42face->type1.charstrings[glyph_index], + NULL, 10 ); t42_glyphslot_clear( t42slot->ttslot ); error = ttclazz->load_glyph( t42slot->ttslot, diff --git a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c index 1c74ccd5ab3..a0a18001b62 100644 --- a/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c +++ b/Build/source/libs/freetype2/freetype-src/src/winfonts/winfnt.c @@ -759,6 +759,14 @@ if ( error ) goto Fail; + /* sanity check */ + if ( !face->font->header.pixel_height ) + { + FT_TRACE2(( "invalid pixel height\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Fail; + } + /* we now need to fill the root FT_Face fields */ /* with relevant information */ { @@ -1062,7 +1070,8 @@ bitmap->rows = font->header.pixel_height; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; - if ( offset + pitch * bitmap->rows > font->header.file_size ) + if ( !pitch || + offset + pitch * bitmap->rows > font->header.file_size ) { FT_TRACE2(( "invalid bitmap width\n" )); error = FT_THROW( Invalid_File_Format ); |