From 493e40ff787222af598b4227f40af7718548f335 Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Tue, 18 Feb 2020 13:09:08 -0800 Subject: [PATCH] [subset] add one empty byte to glyf table if it's going to end up empty after subsetting This will make OTS happy and match what fontTools is doing now. --- src/hb-ot-glyf-table.hh | 12 ++++++++++++ .../colr/TwemojiMozilla.subset.default.32.ttf | Bin 4660 -> 4664 bytes ...zilla.subset.drop-hints-retain-gids.32.ttf | Bin 4640 -> 4644 bytes .../TwemojiMozilla.subset.drop-hints.32.ttf | Bin 4640 -> 4644 bytes .../TwemojiMozilla.subset.retain-gids.32.ttf | Bin 4660 -> 4664 bytes 5 files changed, 12 insertions(+) diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index d81640bd5..31d1629dc 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -149,7 +149,19 @@ struct glyf const hb_subset_plan_t *plan) { TRACE_SERIALIZE (this); + unsigned init_len = c->length (); for (const auto &_ : it) _.serialize (c, plan); + + /* As a special case when all glyph in the font are empty, add a zero byte + * to the table, so that OTS doesn’t reject it, and to make the table work + * on Windows as well. + * See https://github.com/khaledhosny/ots/issues/52 */ + if (init_len == c->length ()) + { + HBUINT8 empty_byte; + empty_byte = 0; + c->copy (empty_byte); + } return_trace (true); } diff --git a/test/subset/data/expected/colr/TwemojiMozilla.subset.default.32.ttf b/test/subset/data/expected/colr/TwemojiMozilla.subset.default.32.ttf index b7d70ade9553cc78e31be35f09631ea7f86d0c71..136e15db810bde6578d9925f0208a7c0a124baa7 100644 GIT binary patch delta 219 zcmdm@vO{Hpczpr`1K&0OV11(irI=y{2F4r)28M*>+{6L~X~z9P{uwa8tVDr9kkN&K zfk_9*XGu>iF8KeSfti7UIReP%NYANE1JWRH2Z$LnQWH}|KB@i&GC6>JvkagB3lHNG zAm0PXSINjNsbFGY5M*HRVsrosu;t_@Cjx08U<46txrr4840BmTfb0iAtdN(On=0^3 mGaBds1CXHw`NbvwS2IWf9bf^H2V#bacZ?ZNZ5Ciu5d;9yM=US^ delta 215 zcmdm?vPETrczp~51K&0OV11(irI=y{2F45q28M*>+{6L~X~z9P{s}O@tVDr9kkN&K zfk^|%XGu>iF8KeSfti7UIRwb(NYANE1JWRH2Sj9~CZ>pdQvD6o&jRF{WdH?Oco>%e z`9L!mR5Ef)Dwr4;1Q{6I7;S(8Y&rSKi9i|z{s1vsZem3N!(0{-ARA<$LSABSs=zbN jXrKdhfQE1s+{6L~X~z9P{vHrNJ+Zjp|9=K% z1_ovqAfF>Wr!oylgTNUeX3R)UOcD8{`Wwjp0mNn*KmisW#w9>03m{)5Be$f2iGe{7 z$TtA;*>due6M-}kSTTG6l5Dw&6$K12%uj&q3qY)pmzbL>@JutBfq_W|sEMN>zqsW8 ZY6dBw15`lrK+G`lj1g1GqfLwof&ePuEG7T| delta 200 zcmZ3YvOr~mc)bS$1K&0OV11(irI=y{2F3^m28M*>+{6L~X~z9P{tgg7J+Zjp|9=K% z1_ovaAfF>Wr!oylgTNUOk&&91BJxS~H<0-Sh|My90xUd?OMv=KfP9sV+>#0=1_nVO zUkAu%%gIkp1kylY#_$G6vgIaL6fndvKLN5q1}fww=B5ff(~M?dV3Gi8;wZ>3F8RNj WK?>*q1(5v23r0+({F_-A6$AmDk}E6# diff --git a/test/subset/data/expected/colr/TwemojiMozilla.subset.drop-hints.32.ttf b/test/subset/data/expected/colr/TwemojiMozilla.subset.drop-hints.32.ttf index 279f15bbe875d21449f34752701859943bf688a0..f69b0c5d41b7f7ef779ba05c3ee9b343389c8e3b 100644 GIT binary patch delta 203 zcmZ3WvP5Nqc)bq;1K&0OV11(irI=y{2F4f$28M*>+{6L~X~z9P{vHrNJ+Zjp|9=K% z1_ovqAfF>Wr!oylgTNUeX3R)UOcD8{`Wwjp0mNn*KmisW#w9>03m{)5Be$f2iGe{7 z$TtA;*>due6M-}kSTTG6l5Dw&6$K12%uj&q3qY)pmzbL>@JutBfq_W|sEMN>zqsW8 ZY6dBw15`lrK+G`lj1g1GqfLwof&ePuEG7T| delta 200 zcmZ3YvOr~mc)bS$1K&0OV11(irI=y{2F3^m28M*>+{6L~X~z9P{tgg7J+Zjp|9=K% z1_ovaAfF>Wr!oylgTNUOk&&91BJxS~H<0-Sh|My90xUd?OMv=KfP9sV+>#0=1_nVO zUkAu%%gIkp1kylY#_$G6vgIaL6fndvKLN5q1}fww=B5ff(~M?dV3Gi8;wZ>3F8RNj WK?>*q1(5v23r0+({F_-A6$AmDk}E6# diff --git a/test/subset/data/expected/colr/TwemojiMozilla.subset.retain-gids.32.ttf b/test/subset/data/expected/colr/TwemojiMozilla.subset.retain-gids.32.ttf index b7d70ade9553cc78e31be35f09631ea7f86d0c71..136e15db810bde6578d9925f0208a7c0a124baa7 100644 GIT binary patch delta 219 zcmdm@vO{Hpczpr`1K&0OV11(irI=y{2F4r)28M*>+{6L~X~z9P{uwa8tVDr9kkN&K zfk_9*XGu>iF8KeSfti7UIReP%NYANE1JWRH2Z$LnQWH}|KB@i&GC6>JvkagB3lHNG zAm0PXSINjNsbFGY5M*HRVsrosu;t_@Cjx08U<46txrr4840BmTfb0iAtdN(On=0^3 mGaBds1CXHw`NbvwS2IWf9bf^H2V#bacZ?ZNZ5Ciu5d;9yM=US^ delta 215 zcmdm?vPETrczp~51K&0OV11(irI=y{2F45q28M*>+{6L~X~z9P{s}O@tVDr9kkN&K zfk^|%XGu>iF8KeSfti7UIRwb(NYANE1JWRH2Sj9~CZ>pdQvD6o&jRF{WdH?Oco>%e z`9L!mR5Ef)Dwr4;1Q{6I7;S(8Y&rSKi9i|z{s1vsZem3N!(0{-ARA<$LSABSs=zbN jXrKdhfQE1s