diff --git a/src/hb-subset-cff-common.cc b/src/hb-subset-cff-common.cc index 3e5ac3a79..9e4bb6008 100644 --- a/src/hb-subset-cff-common.cc +++ b/src/hb-subset-cff-common.cc @@ -28,6 +28,10 @@ #include "hb-ot-cff2-table.hh" #include "hb-subset-cff-common.hh" +/* Disable FDSelect format 0 for compatibility with fonttools which doesn't seem choose it. + * Rarely any/much smaller than format 3 anyway. */ +#define CFF_SERIALIZE_FDSELECT_0 0 + using namespace CFF; /** @@ -112,15 +116,19 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, } else { +#if CFF_SERIALIZE_FDSELECT_0 unsigned int format0_size = FDSelect0::min_size + HBUINT8::static_size * subset_num_glyphs; +#endif unsigned int format3_size = FDSelect3::min_size + FDSelect3_Range::static_size * num_ranges + HBUINT16::static_size; +#if CFF_SERIALIZE_FDSELECT_0 if (format0_size <= format3_size) { // subset_fdselect_format = 0; subset_fdselect_size = format0_size; } else +#endif { subset_fdselect_format = 3; subset_fdselect_size = format3_size; @@ -174,23 +182,25 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, switch (fdselect_format) { +#if CFF_SERIALIZE_FDSELECT_0 case 0: { FDSelect0 *p = c->allocate_size (size); if (unlikely (p == nullptr)) return_trace (false); unsigned int range_index = 0; - unsigned int fd = fdselect_ranges[range_index].code; + unsigned int fd = fdselect_ranges[range_index++].code; for (unsigned int i = 0; i < num_glyphs; i++) { if ((range_index < fdselect_ranges.len) && - (i >= fdselect_ranges[range_index + 1].glyph)) + (i >= fdselect_ranges[range_index].glyph)) { - fd = fdselect_ranges[++range_index].code; + fd = fdselect_ranges[range_index++].code; } p->fds[i].set (fd); } break; } +#endif /* CFF_SERIALIZE_FDSELECT_0 */ case 3: return serialize_fdselect_3_4 (c, diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default..otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default..otf new file mode 100644 index 000000000..7c0c5fdd8 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default..otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,3048,304A,304B.otf new file mode 100644 index 000000000..e51866acd Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,3048,304A,304B.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,73E0,5EA6,8F38.otf new file mode 100644 index 000000000..c4f6bb246 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.3042,3044,3046,73E0,5EA6,8F38.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.61,63,65,6B.otf new file mode 100644 index 000000000..62ddb6092 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.61,63,65,6B.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.otf new file mode 100644 index 000000000..7ce9d4028 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E.otf new file mode 100644 index 000000000..35d9eea4b Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.default.660E.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints..otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints..otf new file mode 100644 index 000000000..a73617ad5 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints..otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,3048,304A,304B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,3048,304A,304B.otf new file mode 100644 index 000000000..790b7141f Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,3048,304A,304B.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.otf new file mode 100644 index 000000000..c707bcd9a Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.61,63,65,6B.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.61,63,65,6B.otf new file mode 100644 index 000000000..591d13905 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.61,63,65,6B.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.otf new file mode 100644 index 000000000..efc98b643 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.otf differ diff --git a/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E.otf b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E.otf new file mode 100644 index 000000000..ce0e4fc79 Binary files /dev/null and b/test/subset/data/expected/japanese/SourceHanSans-Regular.drop-hints.660E.otf differ diff --git a/test/subset/data/fonts/SourceHanSans-Regular.otf b/test/subset/data/fonts/SourceHanSans-Regular.otf new file mode 100755 index 000000000..dd807db05 Binary files /dev/null and b/test/subset/data/fonts/SourceHanSans-Regular.otf differ diff --git a/test/subset/data/tests/japanese.tests b/test/subset/data/tests/japanese.tests index 5a0438012..fc5864666 100644 --- a/test/subset/data/tests/japanese.tests +++ b/test/subset/data/tests/japanese.tests @@ -1,5 +1,6 @@ FONTS: Mplus1p-Regular.ttf +SourceHanSans-Regular.otf PROFILES: default.txt