From 72502ef02b470fa152ca823653f464672f19493c Mon Sep 17 00:00:00 2001 From: Qunxin Liu Date: Mon, 12 Aug 2024 14:08:06 -0700 Subject: [PATCH] [instancer] dont return false when variation data is empty after partial instancing --- src/OT/Color/COLR/COLR.hh | 10 ++++++++-- src/hb-ot-var-common.hh | 7 +++++-- ...r_subset.default.all.SCAN=0,XELA=0,YELA=0.ttf | Bin 0 -> 2580 bytes test/subset/data/fonts/sixtyfour_subset.ttf | Bin 0 -> 4608 bytes .../data/tests/colrv1_partial_instance.tests | 14 ++++++++++++++ test/subset/meson.build | 1 + 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 test/subset/data/expected/colrv1_partial_instance/sixtyfour_subset.default.all.SCAN=0,XELA=0,YELA=0.ttf create mode 100644 test/subset/data/fonts/sixtyfour_subset.ttf create mode 100644 test/subset/data/tests/colrv1_partial_instance.tests diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index 53c4ce0d4..6b5b104f3 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -2339,7 +2339,11 @@ struct COLR c->plan->colrv1_varstore_inner_maps.as_array ())) return_trace (false); - if (!out->varStore.serialize_serialize (c->serializer, + /* do not serialize varStore if there's no variation data after + * instancing: region_list or var_data is empty */ + if (item_vars.get_region_list () && + item_vars.get_vardata_encodings () && + !out->varStore.serialize_serialize (c->serializer, item_vars.has_long_word (), c->plan->axis_tags, item_vars.get_region_list (), @@ -2347,7 +2351,9 @@ struct COLR return_trace (false); /* if varstore is optimized, update colrv1_new_deltaset_idx_varidx_map in - * subset plan */ + * subset plan. + * If varstore is empty after instancing, varidx_map would be empty and + * all var_idxes will be updated to VarIdx::NO_VARIATION */ if (optimize) { const hb_map_t &varidx_map = item_vars.get_varidx_map (); diff --git a/src/hb-ot-var-common.hh b/src/hb-ot-var-common.hh index 7fc9b7c74..92b1caa17 100644 --- a/src/hb-ot-var-common.hh +++ b/src/hb-ot-var-common.hh @@ -1663,7 +1663,9 @@ struct item_variations_t } } - if (!all_regions || !all_unique_regions) return false; + /* regions are empty means no variation data, return true */ + if (!all_regions || !all_unique_regions) return true; + if (!region_list.alloc (all_regions.get_population ())) return false; @@ -1728,7 +1730,8 @@ struct item_variations_t bool as_item_varstore (bool optimize=true, bool use_no_variation_idx=true) { - if (!region_list) return false; + /* return true if no variation data */ + if (!region_list) return true; unsigned num_cols = region_list.length; /* pre-alloc a 2D vector for all sub_table's VarData rows */ unsigned total_rows = 0; diff --git a/test/subset/data/expected/colrv1_partial_instance/sixtyfour_subset.default.all.SCAN=0,XELA=0,YELA=0.ttf b/test/subset/data/expected/colrv1_partial_instance/sixtyfour_subset.default.all.SCAN=0,XELA=0,YELA=0.ttf new file mode 100644 index 0000000000000000000000000000000000000000..235d83d9fac319a249f7f5fb96f401e34e445215 GIT binary patch literal 2580 zcmb7FTWB0r82--8>?X~fbd6DxIJq>9fwVCxQPO~$tD$Z#bfYMu?YP-&Vw2rvcatV! zVI?i3s3=7rB0d!Lsfe`bL#cfzK|~bAM<0r)4_1ppL3|22e*c+?Nlk+B%+5Lg<@+z^ z{QsGS0N)Z~VFZ0IzDo0^$GCaqNqJE=^s-W7=BcGy zW|S~jw_%t$aTP3pLWplsUu1AVO!b(QSp`&y$Es4jO0gtzh_hIS=-%dP@e$t9`EzzJ zYTnDtK;Px}?s@h^dCwm(^)~V8t(F?%@#DK?h0L$aTs7D`+?j3%QcBYjy-CZ#liC~- z%P6gM-O6g$t^EoO&0jXGT(3pLCsiFQwISE-%B;J!Zs>H^dghW_8#=w-mAM3qNxs2T zh4HpAMGqt1s-}=vc}j}|`w9vSD^Nh4MEGYM8yt9wPAxs-Mf8L`jNEcrj)8mSa<<~Xl|H!?VUjKx6YP?-AqW!(2sv3}* zs(Lp4V5C@$n)rc0K-o%JN*M_xE z_?0{eOCR7tddu_SYIrN<)M%b(UI0@9@(!^F)P2aH7V`D=wRMmK`#@cV`^1S#+L+v1a3rg$|(stGkh-*+baKVo> zwueaU2#fJ0Sp()-E*x@+jj()g%`n26-XYkorZkaHwKgUFA35*p#?o#A+6`%MRN_0P zr>uQszg1uOv_h-8=+g#!<$_O}809~PhqutJihMeN`*FvogLnj2Jz52L_#gUo3F-HJ zx^xSsn)lWB&(7Y&)NiqEKpD>Zwv9ZDoKH8gdec6A0A1+t=@wGp|4p2on8OTW{F=^(D$Zw;s2MC0y+q3tEi*((J`2=ln5|?Vd-a3NO$uroHv@6m#?=_0Q5*i;j|G)GWGjm`{SS1u>83 od9E=c=O`5qNn%cE`x#xsQ^4vo35#JUltGk4PN|&jQ{`u literal 0 HcmV?d00001 diff --git a/test/subset/data/fonts/sixtyfour_subset.ttf b/test/subset/data/fonts/sixtyfour_subset.ttf new file mode 100644 index 0000000000000000000000000000000000000000..03181069537323eca0c4a55fb4b0ccab7d7d7a6d GIT binary patch literal 4608 zcmdT{YiL}@75?VlyStLC$4XhREk}>*l`PAmmSaaKsbgBbBOF;WUNxjpl5C~bt`bYy zu2zn18d%p&aUlt%v?VryCV`}FT0$RAC}{}Bgg_Fv1X_wQl+?zlp|~`EN*mnv_B(S& z%GFAuoBr!u?VWGVIdfifX66bCK#VU3eS;HYM~XG)KL8^C0Ibgr9_}A|{QZaiLi|3Z zChtvtVPL2*wgjjG$1S7x_aCWOv2Knjk3AE~J^SWQU)&AY?HoUxoa~>RdN=U~5PE$2~LTAHM4|BXnkz^3hCcF-Lloc#?fZ=IDu; zpZwxa4^scvIlh>oe9emo-vq*6rOe4}IyGJO{K*vceTn?uED4d*_AGh7=TgUW*sH2JCJpXL=zu1G%_}c3TB^; zbNnX!5Hq9jPi)rGhQV$#Y(BbqMHC4{dUYekE|N>NV%uq4BSR1Mlt#W|fytx_qd~vL z0cqMfCY4Yu$M_aTj0~5(!$-y`?LXh%b7rDYEet#pzxK*QbqD?i+t>8gjm{==aP5WK z3i=19QPacPf-q#B=&iVb3wY;8@0|M}{YOoz`AW?Xw!E_C!>+4cKkh>x{SgUidL%$W z^l%N)&R>{6ZHv7$?NLpG=QV8gyyjmc(eYm5%p1)}{3^chOmochdh@ruW-s0k<}<@Hc_ z*u-ZQ?INXIT`L*X+GnjicEZuY?_>-`KI|>OC!HKUrp*X!MG?-ufm+pwJXoc7-MO!~ zr=zVc5st;%UT<>UCVADibhhx%$Xd&?+qLX=EvvNfzemTFwsTx&F8c(EPQ+0}G4t4}-^uJy;kTO_8y-msf(Gh;aQL<~5 z+1D}DlhXrBa-y~Zk_WXNN@7<#U`f2Hle;Q`ZtTYhj^IH&f@Am^p2j)6grDP0yo=xC znv?)NY1EnU@ira5k8jse``E8~A2;g=ecYns@^Pz<#>cLXLAp2t%yKb`ib;h>gc%CbLC3p)mN{!-gjT?RrRxpQ|j-Pr&Rr4PyIh?X8d~9*)O+| zWxzf`_F1k0cNZHad8X^Ol3!g9T8HEtIH_^eTlgr|$ ziyZR;L=I{l>UW`J9%6c)vyQ~;P%iLoV`-ucOFTWe=uy8o^w$GDkju>KlkW?=4}BW1 zV{F5zoFbnldMfdM@p(fvj#d-WYKV0r4=_tW2Y*pr)>6#2cMz|6FY!>A_6mkdX-$0| zvv}NliZM!Qm$c<8vV_c`wizIoFWGH%(*@;Ja`t8CZG#oMoM#QTQ0qKxu#Is>=F2@Uu1Gn;YZrHO**5a|%neUHH^KiVy#bPckpbIF7SFLHi4|pXa?S zQ61CXW%!+)Ra#vOe2uA|Z2 zpvv8ny8cARJ^b%^m?uyY_pGCD{XJ9a;p#oJHqMQ_674yzyqr1yNhHzT!QWoSImx<9 zvoBwti^KXPdW7?)xL$JREwRtiPM#~^^1EBky8^8)^1p&Td@{5x5=;0p^EySzIZ{Q# iJY^o$^Jn#{K1#Z1k`vXJ%W1BhySw!%Bj?T{cKrvB=dgzW literal 0 HcmV?d00001 diff --git a/test/subset/data/tests/colrv1_partial_instance.tests b/test/subset/data/tests/colrv1_partial_instance.tests new file mode 100644 index 000000000..e7034af4f --- /dev/null +++ b/test/subset/data/tests/colrv1_partial_instance.tests @@ -0,0 +1,14 @@ +FONTS: +sixtyfour_subset.ttf + +PROFILES: +default.txt + +SUBSETS: +* + +INSTANCES: +SCAN=0,XELA=0,YELA=0 + +OPTIONS: +no_fonttools diff --git a/test/subset/meson.build b/test/subset/meson.build index b94464ed7..b35489329 100644 --- a/test/subset/meson.build +++ b/test/subset/meson.build @@ -78,6 +78,7 @@ tests = [ 'feature_variation_instance_collect_lookups', 'sync_vmetrics', 'empty_region_vardata', + 'colrv1_partial_instance', ] if get_option('experimental_api')