From 7145607149be79a548d5a2e25ccbeb1fc6dc3492 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Mon, 25 Mar 2024 21:41:16 +0000 Subject: [PATCH 1/5] [subset] place the gdef var store at the end of the GDEF table. It appears that some font processors assume it is the last sub table. --- src/OT/Layout/GDEF/GDEF.hh | 38 +++++++++++------- ....default.retain-all-codepoint.wght=700.ttf | Bin 131584 -> 131584 bytes .../Foldit.default.retain-all-codepoint.ttf | Bin 44324 -> 44324 bytes ...hints-retain-gids.retain-all-codepoint.ttf | Bin 44288 -> 44288 bytes ...Foldit.drop-hints.retain-all-codepoint.ttf | Bin 44288 -> 44288 bytes ...oldit.retain-gids.retain-all-codepoint.ttf | Bin 44324 -> 44324 bytes ....retain-all-codepoint.wght=150,wdth=80.ttf | Bin 114196 -> 114196 bytes ....retain-all-codepoint.wght=300,wdth=90.ttf | Bin 114296 -> 114296 bytes ....retain-all-codepoint.wght=150,wdth=80.ttf | Bin 114196 -> 114196 bytes ....retain-all-codepoint.wght=300,wdth=90.ttf | Bin 114296 -> 114296 bytes ...-test-retain-gids.retain-all-codepoint.ttf | Bin 142456 -> 142456 bytes ...gular.layout-test.retain-all-codepoint.ttf | Bin 142456 -> 142456 bytes ...ghtItalic.default.retain-all-codepoint.ttf | Bin 134344 -> 134344 bytes ...talic.glyph-names.retain-all-codepoint.ttf | Bin 145620 -> 145620 bytes ...ic.notdef-outline.retain-all-codepoint.ttf | Bin 134472 -> 134472 bytes ...in-subset.default.retain-all-codepoint.ttf | Bin 40128 -> 40128 bytes .../Roboto-Regular.default.1E00,303.ttf | Bin 2464 -> 2464 bytes .../Roboto-Regular.default.303.ttf | Bin 2068 -> 2068 bytes .../Roboto-Regular.default.309,20,30F.ttf | Bin 2140 -> 2140 bytes .../Roboto-Regular.default.323.ttf | Bin 1960 -> 1960 bytes .../Roboto-Regular.drop-hints.1E00,303.ttf | Bin 1320 -> 1320 bytes .../Roboto-Regular.drop-hints.303.ttf | Bin 1064 -> 1064 bytes .../Roboto-Regular.drop-hints.309,20,30F.ttf | Bin 1100 -> 1100 bytes .../Roboto-Regular.drop-hints.323.ttf | Bin 1008 -> 1008 bytes ...Roboto-Regular.keep-gdef-gpos.1E00,303.ttf | Bin 2464 -> 2464 bytes .../Roboto-Regular.keep-gdef-gpos.303.ttf | Bin 2068 -> 2068 bytes ...boto-Regular.keep-gdef-gpos.309,20,30F.ttf | Bin 2140 -> 2140 bytes .../Roboto-Regular.keep-gdef-gpos.323.ttf | Bin 1960 -> 1960 bytes ...default.627,644,623,62D,644,627,645,2E.ttf | Bin 17552 -> 17552 bytes ...iqUrdu-Regular.default.627,644,62D,628.ttf | Bin 24520 -> 24520 bytes ...toNastaliqUrdu-Regular.default.633,6D2.ttf | Bin 14280 -> 14280 bytes ...staliqUrdu-Regular.default.63A,64A,631.ttf | Bin 26116 -> 26116 bytes ...u-Regular.default.retain-all-codepoint.ttf | Bin 542328 -> 542328 bytes ...in-gids.627,644,623,62D,644,627,645,2E.ttf | Bin 24212 -> 24212 bytes ...du-Regular.retain-gids.627,644,62D,628.ttf | Bin 30420 -> 30420 bytes ...staliqUrdu-Regular.retain-gids.633,6D2.ttf | Bin 20120 -> 20120 bytes ...iqUrdu-Regular.retain-gids.63A,64A,631.ttf | Bin 31976 -> 31976 bytes ...gular.retain-gids.retain-all-codepoint.ttf | Bin 542360 -> 542360 bytes 38 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index 475e6d74d1e..03c83a5149e 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -663,19 +663,12 @@ struct GDEFVersion1_2 auto *out = c->serializer->start_embed (*this); if (unlikely (!c->serializer->extend_min (out))) return_trace (false); - out->version.major = version.major; - out->version.minor = version.minor; - bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this, nullptr, false, true); - bool subset_attachlist = out->attachList.serialize_subset (c, attachList, this); - bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true); - - bool subset_markglyphsetsdef = false; + // Serialize var store first (if it's needed) so that it's serialized last. Some font parsers assume + // that varstore runs to the end of the GDEF table. + // TODO(garretrieger): add a virtual link from all non-var store sub tables to the var store. auto snapshot_version0 = c->serializer->snapshot (); - if (version.to_int () >= 0x00010002u) - { - if (unlikely (!c->serializer->embed (markGlyphSetsDef))) return_trace (false); - subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this); - } + if (unlikely (version.to_int () >= 0x00010002u && !c->serializer->embed (markGlyphSetsDef))) + return_trace (false); bool subset_varstore = false; auto snapshot_version2 = c->serializer->snapshot (); @@ -705,18 +698,33 @@ struct GDEFVersion1_2 } + out->version.major = version.major; + out->version.minor = version.minor; + + if (!subset_varstore && version.to_int () >= 0x00010002u) { + c->serializer->revert (snapshot_version2); + } + + bool subset_markglyphsetsdef = false; + if (version.to_int () >= 0x00010002u) + { + subset_markglyphsetsdef = out->markGlyphSetsDef.serialize_subset (c, markGlyphSetsDef, this); + } + if (subset_varstore) { out->version.minor = 3; c->plan->has_gdef_varstore = true; } else if (subset_markglyphsetsdef) { - out->version.minor = 2; - c->serializer->revert (snapshot_version2); + out->version.minor = 2; } else { out->version.minor = 0; c->serializer->revert (snapshot_version0); } + bool subset_glyphclassdef = out->glyphClassDef.serialize_subset (c, glyphClassDef, this, nullptr, false, true); + bool subset_attachlist = out->attachList.serialize_subset (c, attachList, this); + bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true); bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this); return_trace (subset_glyphclassdef || subset_attachlist || @@ -1013,7 +1021,7 @@ struct GDEF if (!has_var_store ()) return; const ItemVariationStore &var_store = get_var_store (); float *store_cache = var_store.create_cache (); - + unsigned new_major = 0, new_minor = 0; unsigned last_major = (layout_variation_indices->get_min ()) >> 16; for (unsigned idx : layout_variation_indices->iter ()) diff --git a/test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=700.ttf b/test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=700.ttf index 6715573fd7d039ccfca219a00dbbf79d922f7d6f..69ea3a2d9cf73dd6d4c70890bc34647c7c03bf7e 100644 GIT binary patch delta 69 zcmZo@;b>^#5Mf|sU|#-P`%G5G^gjS^HWZNn delta 69 zcmZo@;b>^#5Mf|sU|;o VR@=?HnHMoO&t%;`la(?34**5P68ZoD diff --git a/test/subset/data/expected/colrv1_copy_varstore/Foldit.default.retain-all-codepoint.ttf b/test/subset/data/expected/colrv1_copy_varstore/Foldit.default.retain-all-codepoint.ttf index 11a6cf786fdeb87f4c49f90d63bb01c1efb5d339..fe803d765412c9e6b7177ebafffe1cf444889466 100644 GIT binary patch delta 61 zcmZ2-i)qO%rU?ctjE!&OH=1l=0RiL~7=e%(h#43dC#x|lYz|_+ Gv=RXNE)8G+ delta 88 zcmZ2-i)qO%rU?ctEE7LQZ#3D!#3IjQ<1zUKlc9wn0|E#!FakNEV3G$+0{L%%3?StI PgkTmkL}GIw^W~KQGFc8b diff --git a/test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints-retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints-retain-gids.retain-all-codepoint.ttf index 2112796ecd53d41aa27b864aba88833648b917b0..28a7e1a21717c8ff4fc3c227084481644e8121ff 100644 GIT binary patch delta 61 zcmZp;#nf<%X@UU@W8>TSjV3dgSW>?nn>+aelcA�|Lk~FajYn5Hm0^PUd4)*lfjo GY$X6MQx1~= delta 61 zcmZp;#nf<%X@UU@%fye-8%<^~vBY25w{-FaCPQ9B1_ThAEXAzA&B(yWzzoC;42+vC InUAjo067Q_o&W#< diff --git a/test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints.retain-all-codepoint.ttf b/test/subset/data/expected/colrv1_copy_varstore/Foldit.drop-hints.retain-all-codepoint.ttf index 2112796ecd53d41aa27b864aba88833648b917b0..28a7e1a21717c8ff4fc3c227084481644e8121ff 100644 GIT binary patch delta 61 zcmZp;#nf<%X@UU@W8>TSjV3dgSW>?nn>+aelcA�|Lk~FajYn5Hm0^PUd4)*lfjo GY$X6MQx1~= delta 61 zcmZp;#nf<%X@UU@%fye-8%<^~vBY25w{-FaCPQ9B1_ThAEXAzA&B(yWzzoC;42+vC InUAjo067Q_o&W#< diff --git a/test/subset/data/expected/colrv1_copy_varstore/Foldit.retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/colrv1_copy_varstore/Foldit.retain-gids.retain-all-codepoint.ttf index 11a6cf786fdeb87f4c49f90d63bb01c1efb5d339..fe803d765412c9e6b7177ebafffe1cf444889466 100644 GIT binary patch delta 61 zcmZ2-i)qO%rU?ctjE!&OH=1l=0RiL~7=e%(h#43dC#x|lYz|_+ Gv=RXNE)8G+ delta 88 zcmZ2-i)qO%rU?ctEE7LQZ#3D!#3IjQ<1zUKlc9wn0|E#!FakNEV3G$+0{L%%3?StI PgkTmkL}GIw^W~KQGFc8b diff --git a/test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=150,wdth=80.ttf b/test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=150,wdth=80.ttf index 2d92644a015952b53c466c712a2cada2c82b99bf..d8b2b85b140c70f94d6ab50c7d0f34edd1e1b3bf 100644 GIT binary patch delta 65 zcmbR8hi%FqHX#N^1_lNpAi=_*;O^q;mcDPJ&?H8t+sd1lF*-AI@&RRmfN|SqCDxUU SlRvWkvE7@e6p?SQf%z&Cjoo8jiq REGrnBPqS@5&Bo}t9RU9q5eonS diff --git a/test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=300,wdth=90.ttf b/test/subset/data/expected/full_instance/Roboto-Variable.default.retain-all-codepoint.wght=300,wdth=90.ttf index b70db5c0bfcb74b942834f1ad84230ceb27db7a4..9407bc4cf51d5798a48978e2f0489ca46e86ed0a 100644 GIT binary patch delta 65 zcmezIhwaB7HX#N^1_lNpAi=_*;O^q;mcDPJ&?H8t{Ibo<81tDq`GB%Oz_@L*AL~lS S$?~iQ&EMI!e`jNC+ztRk77|qe delta 65 zcmezIhwaB7HX#N^1_lNpAi=_*;O^q;mgcrmXc8k+QQGEZjQPx*c0gGW;G2Am&2Y0k R>k7u^?`+$@voSVq2LLS$5zhbs diff --git a/test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=150,wdth=80.ttf b/test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=150,wdth=80.ttf index 2d92644a015952b53c466c712a2cada2c82b99bf..d8b2b85b140c70f94d6ab50c7d0f34edd1e1b3bf 100644 GIT binary patch delta 65 zcmbR8hi%FqHX#N^1_lNpAi=_*;O^q;mcDPJ&?H8t+sd1lF*-AI@&RRmfN|SqCDxUU SlRvWkvE7@e6p?SQf%z&Cjoo8jiq REGrnBPqS@5&Bo}t9RU9q5eonS diff --git a/test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=300,wdth=90.ttf b/test/subset/data/expected/full_instance/Roboto-Variable.no-prune-unicode-ranges.retain-all-codepoint.wght=300,wdth=90.ttf index b70db5c0bfcb74b942834f1ad84230ceb27db7a4..9407bc4cf51d5798a48978e2f0489ca46e86ed0a 100644 GIT binary patch delta 65 zcmezIhwaB7HX#N^1_lNpAi=_*;O^q;mcDPJ&?H8t{Ibo<81tDq`GB%Oz_@L*AL~lS S$?~iQ&EMI!e`jNC+ztRk77|qe delta 65 zcmezIhwaB7HX#N^1_lNpAi=_*;O^q;mgcrmXc8k+QQGEZjQPx*c0gGW;G2Am&2Y0k R>k7u^?`+$@voSVq2LLS$5zhbs diff --git a/test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test-retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test-retain-gids.retain-all-codepoint.ttf index c2ef8fed6e21237f17a753da1cd1d99ef31aa93e..3a9398d238e5783191013c702ef6335ec4296161 100644 GIT binary patch delta 73 zcmexygX6~y4iN@M1_lORh6V;^h5&aLSGScPmfqedV#3IB^CJ; d41AMI*e`Eh&vJ~Z*`1@^or7_^I|q}Y3IH~@6?6aq diff --git a/test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test.retain-all-codepoint.ttf b/test/subset/data/expected/layout.context_format2/NotoSansNewa-Regular.layout-test.retain-all-codepoint.ttf index c2ef8fed6e21237f17a753da1cd1d99ef31aa93e..3a9398d238e5783191013c702ef6335ec4296161 100644 GIT binary patch delta 73 zcmexygX6~y4iN@M1_lORh6V;^h5&aLSGScPmfqedV#3IB^CJ; d41AMI*e`Eh&vJ~Z*`1@^or7_^I|q}Y3IH~@6?6aq diff --git a/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.default.retain-all-codepoint.ttf b/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.default.retain-all-codepoint.ttf index 7dcb3ecec817a39ed2fc2c22b7050d2d3fa90a1e..4f0453e63314b62cf8c6c9107b7cc3e00a4cb8bf 100644 GIT binary patch delta 73 zcmX>xljFop4iN@M1_lN}Ai=^Q;O^q;mhvq5^hS{yMwX~s?TwqKFe)-}@&Q!<0i(j^ aSIokUllL?0H2-C3|I5O-{VxmCX?6g*r4)|< delta 73 zcmX>xljFop4iN@M1_lN}Ai=^Q;O^q;mST}Sd80@TBTI}~`^U{w7!{c~t$->(fN$~z Z7TwMJnS~ge|FX3IWntX@mxbvxI{=AR6L$ar diff --git a/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.glyph-names.retain-all-codepoint.ttf b/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.glyph-names.retain-all-codepoint.ttf index f17c60961d41cedf74c4603150126753381c95e4..f49b3618cd53107408bc83318b5619f281e507ad 100644 GIT binary patch delta 73 zcmccek>koo4iN@M1_lN}Ai=^Q;O^q;mhvq5^hS{wMwW;5rgoc47!{c~`G6{bfKg%d aDQ02D$@7_Yn(wl--(_LkewT&myDkoo4iN@M1_lN}Ai=^Q;O^q;mST}Sd80@SBg>=Prt3DBFe)-}S^-sn0N>;d ZEV`TLGYc^`-(_jP%fh(*E(_ClV*tn06iomC diff --git a/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.notdef-outline.retain-all-codepoint.ttf b/test/subset/data/expected/layout.drop_feature/SpectralSC-ExtraLightItalic.notdef-outline.retain-all-codepoint.ttf index 490ab70c743fa20c1dfe36064062b1754524c020..17bf19b973a8ce2cfda6f1b50c20ee07fe7bbbf1 100644 GIT binary patch delta 73 zcmX>xi{r#B4iN@M1_lN}Ai=^Q;O^q;mhvq5^hS{yMwa5>l=RJ07!{c~`G6{bfKg%d aD`sKF$@`ggn*Xx2|7Bs^{+ETxn*#u!>l0@H delta 73 zcmX>xi{r#B4iN@M1_lN}Ai=^Q;O^q;mST}Sd80@TBTLEpl;b ZEV`TbGYc^`|7B_a%fh(*FAI}52LP6H6HWjC diff --git a/test/subset/data/expected/layout.empty_ligature_offset/AnekBangla-latin-subset.default.retain-all-codepoint.ttf b/test/subset/data/expected/layout.empty_ligature_offset/AnekBangla-latin-subset.default.retain-all-codepoint.ttf index e940516bfc98373ef1b38b3d47719135f39c7436..95218938cc420921d07cc281804e88dca2af5c5a 100644 GIT binary patch delta 63 zcmX@Glj*=tCLsn!1_lNJAi=`G;O^q;CY!TSsEm<>_KuJCzj+>mu6gXL$ PSz+>arj*Ur%&jv4!sHKP diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.default.1E00,303.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.default.1E00,303.ttf index dcd48b2e2379dba7e99e42c466f98623948441a3..f0a4b602a0963f2104f0a0607e4a6f786d95bef3 100644 GIT binary patch delta 78 zcmZ1=yg*olfsuiMK?q2&FetdYxVkZzFo-j` V2`I)g`46Kl^CyN6n{Aj<*a29!3KReU delta 78 zcmZ1=yg*olfsuiMK?q2&FetdYxVkYoGw^H_Im)Ok2NVYZKA;Ma8V(@I1XRTWq*;J0 VW(LN|e;93%1pz*wJV*rxkYoZw5Y5QIJeiHD Mm{DwV71JzM03XK(*8l(j diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.default.309,20,30F.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.default.309,20,30F.ttf index 1d4d5d0d93b4db99834befd827c7b8aabfc83380..17e765012398d7e308166dd794769a2ed0179090 100644 GIT binary patch delta 74 zcmca3a7RFdfsuiMK?q2&FetdYxVkYIGe~U|xydNc2NVYZ37`rlAY=wYMzCrQAjvYB Qhsl+BcgdU0Axs=>0A9KYp#T5? delta 55 zcmca3a7RFdfsuiMK?q2&FetdYxVkZTFz{~_xyi_>1QZ7WzDZ2tlX;n3m?xGpZ4P1L GU;_a8j0qh8 diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.default.323.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.default.323.ttf index 34cef3845097b27dcf13f11edec3b7b18ff33985..9d8035e8c9d82956ce52bdee429896a629fcaba2 100644 GIT binary patch delta 72 zcmZ3%zk*+gfsuiMK?q2&FetdYxVkZzZWKDrsK^Ht1pzUjJP0y_Nd^WEAk73~PyWYP M%vig*h{=o<05Bd1(f|Me delta 72 zcmZ3%zk*+gfsuiMK?q2&FetdYxVkaeZWKDrs3->%1pz*wJV*rxkYob0L3~CA=E?sU Niy3n_7crT!0su1x2+{xm diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.1E00,303.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.drop-hints.1E00,303.ttf index 4800d6d387c4511344dfbb30b6d0dfacf99a6919..0c9b8f4964aef1b6f39aedd029f27916b4dc8b14 100644 GIT binary patch delta 78 zcmZ3%wSr58fsuiMfsdhqftew}-Nn_7!Gu9{qev;EG9OSJ1SEheSQwaq@{C}}z`y~d WnSf#}lh-iXGT)Xq*!+gkh8X~HSqbw1 delta 78 zcmZ3%wSr58fsuiMfsdhqftew}-Nn_7!I^<)qev;EvK&wx1o(g|Kx#OEBohM*5HbQW W6Hq;EIDj-0h&_1| N<7`He&3;Ua7y)cy33mVh delta 72 zcmeys{()VHfsuiMfsdhqftew}-Nn_7!FHoiJ)@!=P!t6Cfbt*}96*u@%m(op8JH(; OVw}y$ve}Pm5hDO^NeOoV diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.1E00,303.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.1E00,303.ttf index dcd48b2e2379dba7e99e42c466f98623948441a3..f0a4b602a0963f2104f0a0607e4a6f786d95bef3 100644 GIT binary patch delta 78 zcmZ1=yg*olfsuiMK?q2&FetdYxVkZzFo-j` V2`I)g`46Kl^CyN6n{Aj<*a29!3KReU delta 78 zcmZ1=yg*olfsuiMK?q2&FetdYxVkYoGw^H_Im)Ok2NVYZKA;Ma8V(@I1XRTWq*;J0 VW(LN|e;93%1pz*wJV*rxkYoZw5Y5QIJeiHD Mm{DwV71JzM03XK(*8l(j diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.309,20,30F.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.309,20,30F.ttf index 1d4d5d0d93b4db99834befd827c7b8aabfc83380..17e765012398d7e308166dd794769a2ed0179090 100644 GIT binary patch delta 74 zcmca3a7RFdfsuiMK?q2&FetdYxVkYIGe~U|xydNc2NVYZ37`rlAY=wYMzCrQAjvYB Qhsl+BcgdU0Axs=>0A9KYp#T5? delta 55 zcmca3a7RFdfsuiMK?q2&FetdYxVkZTFz{~_xyi_>1QZ7WzDZ2tlX;n3m?xGpZ4P1L GU;_a8j0qh8 diff --git a/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.323.ttf b/test/subset/data/expected/layout.gdef/Roboto-Regular.keep-gdef-gpos.323.ttf index 34cef3845097b27dcf13f11edec3b7b18ff33985..9d8035e8c9d82956ce52bdee429896a629fcaba2 100644 GIT binary patch delta 72 zcmZ3%zk*+gfsuiMK?q2&FetdYxVkZzZWKDrsK^Ht1pzUjJP0y_Nd^WEAk73~PyWYP M%vig*h{=o<05Bd1(f|Me delta 72 zcmZ3%zk*+gfsuiMK?q2&FetdYxVkaeZWKDrs3->%1pz*wJV*rxkYob0L3~CA=E?sU Niy3n_7crT!0su1x2+{xm diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,623,62D,644,627,645,2E.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,623,62D,644,627,645,2E.ttf index 55893d0f48c4af297901951e5cdd109b277d4e82..121caa0c46c91add50a40ecda03065c1d05a2069 100644 GIT binary patch delta 75 zcmbQx$vB~tQG|h!fq_8~NU$&nxVyNzF{&`^-YBwwk)`0-g!0Kd7!5fkfC?BG_!z7v WGcoD%GlDg607)hg-mJ%zbi delta 75 zcmbQx$vB~tQG|h!fq_8~NU$&nxVyNzF>)}R-YBwwk)=>>LipqzjE0gLKm`m8atwSx Wr69!|K#~cBCx2qp-K@`)=mY@l?F?=J diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,62D,628.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.default.627,644,62D,628.ttf index 70db5820f52502ebc98c69e98245039fb4fd775a..15d86ccc833288904c92dd2af8bc17d40a92ea5b 100644 GIT binary patch delta 74 zcmX@HpYgEaj8~$}=$VF<4D@ VW76ek1gqx&l1w1Hxriw&764Z*4e$T} delta 74 zcmX@HpYgqFeota0ab$3 YasWwY21y1f2Iqe0Uj4Xf6ly-04!Pvsg#rOuOgn@yN tY1`&4Y%7^IyR+soHpgZjI1pvEB8^izr delta 99 zcmey-qxhpoQG|h!fq_8~NU$&nxVyNzUF5yQxKU&QBMZwjsl}UjFt#vrF-HNFFfi6I s@NIs_p3k`1opl9Mb1Y|jEGHunGXXI(5VHU=D-g2*G5hvdP7Y~X0Q%b*0RR91 diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,623,62D,644,627,645,2E.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,623,62D,644,627,645,2E.ttf index 6acf0c1a53ba6a65bc2a881063d34ef36e9d0f31..d71a950506995bd8a2972f477c92c3f25e927fd3 100644 GIT binary patch delta 76 zcmbQTmvPEoMiB-^1_lN}Ai=^Q;O^q;W*1{Cw^3vPBa5uX=Gx6W7<(BxrGP3J82A`o aO^#!}%g+eb!2u+h7!(ttV31?r a1F8k7<^YmR42lfOll_?QZnkELi~;~wj1IN{ diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,62D,628.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.627,644,62D,628.ttf index b3f15ed378e0422b87878f07e74bc938c427594a..f278d3442661efd4806f75d8703e13bf12707e7c 100644 GIT binary patch delta 76 zcmccemhsA4MiB-^1_lN}Ai=^Q;O^q;W-D*gv{7UMBMaZvW3xB!V60{2Q~|1BVBlk9 anC!>=nV%7?g9Au1G4L@IZFXRpQUn0AG7vNX delta 76 zcmccemhsA4MiB-^1_lN}Ai=^Q;O^q;X0yshb)(1vMi&14$3r*oV60`7Gy$q$V31?r Z1F8k7<^YmRKwi;gJLb=u9a$z90RWik5G4Qr diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.633,6D2.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.633,6D2.ttf index 51c6c9517761c7a1ee0deb50746c30794d26b94d..89a186ae4cfd4fc3afc7d4f44a3f8f9a23ae1206 100644 GIT binary patch delta 77 zcmbO+mvP2iMiB-^1_lN}Ai=^Q;O^q;ru|RfXrssiMwTx%H+d)TU_8qy2UNhoz{k)u bc>z-?P$ftM2asfDzQ%l=`Nn1u<`!=NuGkUC delta 77 zcmbO+mvP2iMiB-^1_lN}Ai=^Q;O^q;raeX9XQRjhMwYJuH*QYe!FX2M0H}b0L4kn} bs1&4_14uG6Ut_+`d}DGSQ|V?==4NjIobwU4 diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.63A,64A,631.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.63A,64A,631.ttf index 87f712da0d23888b316d19146a0c7398ca493700..cba2f55e9c7d047cb299532d28dadf7d8a1d302e 100644 GIT binary patch delta 65 zcmaFylkvq*MiB-^1_lN}Ai=^Q;O^q;X8*%ZWuwRfMwV|19J4p?V60{2Gytk#VBljE T+8o8q$~f7cS!Q!QOJ@ZDFgFl1 delta 89 zcmaFylkvq*MiB-^1_lN}Ai=^Q;O^q;W-nmpuu)_IBg^*>9Lbw^FxE1v`T$ihFlaIG g0o5`ASt3Bp17`Cx6oYAQhS1G+%&d%?<5@Z@08_3IP5=M^ diff --git a/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/layout.notonastaliqurdu/NotoNastaliqUrdu-Regular.retain-gids.retain-all-codepoint.ttf index 4458d5fbfa3b8418b130c41fbaa5e2c2b1b6155c..2b453f06810b5d16084c64eee771452b90d8fdce 100644 GIT binary patch delta 99 zcmbQyt2m=qQG|h!fq_8~NU$&nxVyNz-I{t?ZllNoMwZv&j~F-aU~FOLVtfNs!oa}C tv}f}cw)IS#-C6S(o0B=)lQ|iImRBg^N&o7tOpFt#vrF-HNFFfi6I s@NNFWp3k`1opl{kb24XpGAAPtGXXI(5VHU=D-g2*G5hvpP7YIB05i54T>t<8 From 6e87481731e0945f71e8cb9556f30ffcd2388fcf Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 27 Mar 2024 17:47:57 +0000 Subject: [PATCH 2/5] [subset] add virtual links to keep the gdef varstore last. --- src/OT/Layout/GDEF/GDEF.hh | 19 ++++-- src/hb-serialize.hh | 60 +++++++++++++++--- ....default.retain-all-codepoint.wght=300.ttf | Bin 131708 -> 131708 bytes ...gular-new.default.retain-all-codepoint.ttf | Bin 222684 -> 222684 bytes ...hints-retain-gids.retain-all-codepoint.ttf | Bin 191560 -> 191560 bytes ...ar-new.drop-hints.retain-all-codepoint.ttf | Bin 191512 -> 191512 bytes ...-Regular-new.gids.retain-all-codepoint.ttf | Bin 222684 -> 222684 bytes ...r-new.glyph-names.retain-all-codepoint.ttf | Bin 229676 -> 229676 bytes ...l-layout-features.retain-all-codepoint.ttf | Bin 223380 -> 223380 bytes ...w.layout-features.retain-all-codepoint.ttf | Bin 220876 -> 220876 bytes ...ular-new.name-ids.retain-all-codepoint.ttf | Bin 222424 -> 222424 bytes ...ew.name-languages.retain-all-codepoint.ttf | Bin 222684 -> 222684 bytes ...r-new.name-legacy.retain-all-codepoint.ttf | Bin 222684 -> 222684 bytes ...ne-unicode-ranges.retain-all-codepoint.ttf | Bin 222684 -> 222684 bytes ...ew.notdef-outline.retain-all-codepoint.ttf | Bin 223280 -> 223280 bytes ...r-new.retain-gids.retain-all-codepoint.ttf | Bin 222732 -> 222732 bytes ...oint.wght=200-300,opsz=14.iup_optimize.ttf | Bin 9988 -> 9988 bytes ...ain-all-codepoint.wght=200-300,opsz=14.ttf | Bin 10136 -> 10136 bytes ...iable-Roman.default.1FC,21,41,20,62,63.ttf | Bin 3888 -> 3888 bytes ...fault.61,62,63,64,65,66,67,68,69,6A,6B.ttf | Bin 9704 -> 9704 bytes ...ceSerifVariable-Roman.default.61,62,63.ttf | Bin 3784 -> 3784 bytes ...fVariable-Roman.default.D7,D8,D9,DA,DE.ttf | Bin 4324 -> 4324 bytes ...le-Roman.drop-hints.1FC,21,41,20,62,63.ttf | Bin 3864 -> 3864 bytes ...hints.61,62,63,64,65,66,67,68,69,6A,6B.ttf | Bin 9704 -> 9704 bytes ...erifVariable-Roman.drop-hints.61,62,63.ttf | Bin 3784 -> 3784 bytes ...riable-Roman.drop-hints.D7,D8,D9,DA,DE.ttf | Bin 4324 -> 4324 bytes ...oman.filter-scripts.1FC,21,41,20,62,63.ttf | Bin 3856 -> 3856 bytes ...ripts.61,62,63,64,65,66,67,68,69,6A,6B.ttf | Bin 9548 -> 9548 bytes ...Variable-Roman.filter-scripts.61,62,63.ttf | Bin 3752 -> 3752 bytes ...le-Roman.filter-scripts.D7,D8,D9,DA,DE.ttf | Bin 4292 -> 4292 bytes ...in-all-codepoint.wght=300.iup_optimize.ttf | Bin 3276 -> 3228 bytes ....default.retain-all-codepoint.wght=300.ttf | Bin 3300 -> 3252 bytes ...ht=200-300-500,wdth=80-90.iup_optimize.ttf | Bin 8684 -> 8684 bytes ...-codepoint.wght=200-300-500,wdth=80-90.ttf | Bin 8708 -> 8708 bytes ...oint.wght=300-600,wdth=85.iup_optimize.ttf | Bin 7592 -> 7592 bytes ...ain-all-codepoint.wght=300-600,wdth=85.ttf | Bin 7592 -> 7592 bytes ...ll-codepoint.wght=300-600.iup_optimize.ttf | Bin 303960 -> 303960 bytes ...ault.retain-all-codepoint.wght=300-600.ttf | Bin 305092 -> 305092 bytes ...ll-codepoint.wght=500-800.iup_optimize.ttf | Bin 249808 -> 249808 bytes ...ault.retain-all-codepoint.wght=500-800.ttf | Bin 250164 -> 250164 bytes test/subset/data/fonts/AnekBangla-subset.ttf | Bin 5456 -> 5276 bytes 41 files changed, 66 insertions(+), 13 deletions(-) diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index 03c83a5149e..afec61c4149 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -663,14 +663,15 @@ struct GDEFVersion1_2 auto *out = c->serializer->start_embed (*this); if (unlikely (!c->serializer->extend_min (out))) return_trace (false); - // Serialize var store first (if it's needed) so that it's serialized last. Some font parsers assume - // that varstore runs to the end of the GDEF table. - // TODO(garretrieger): add a virtual link from all non-var store sub tables to the var store. + // Push var store first (if it's needed) so that it's last in the + // serialization order. Some font consumers assume that varstore runs to + // the end of the GDEF table. auto snapshot_version0 = c->serializer->snapshot (); if (unlikely (version.to_int () >= 0x00010002u && !c->serializer->embed (markGlyphSetsDef))) return_trace (false); bool subset_varstore = false; + unsigned varstore_index = -1; auto snapshot_version2 = c->serializer->snapshot (); if (version.to_int () >= 0x00010003u) { @@ -683,21 +684,25 @@ struct GDEFVersion1_2 { item_variations_t item_vars; if (item_vars.instantiate (this+varStore, c->plan, true, true, - c->plan->gdef_varstore_inner_maps.as_array ())) + c->plan->gdef_varstore_inner_maps.as_array ())) { subset_varstore = out->varStore.serialize_serialize (c->serializer, item_vars.has_long_word (), c->plan->axis_tags, item_vars.get_region_list (), item_vars.get_vardata_encodings ()); + varstore_index = c->serializer->last_added_child_index(); + } remap_varidx_after_instantiation (item_vars.get_varidx_map (), c->plan->layout_variation_idx_delta_map); } } else + { subset_varstore = out->varStore.serialize_subset (c, varStore, this, c->plan->gdef_varstore_inner_maps.as_array ()); + varstore_index = c->serializer->last_added_child_index(); + } } - out->version.major = version.major; out->version.minor = version.minor; @@ -727,6 +732,10 @@ struct GDEFVersion1_2 bool subset_markattachclassdef = out->markAttachClassDef.serialize_subset (c, markAttachClassDef, this, nullptr, false, true); bool subset_ligcaretlist = out->ligCaretList.serialize_subset (c, ligCaretList, this); + if (subset_varstore && varstore_index != (unsigned) -1) { + c->serializer->repack_last(varstore_index); + } + return_trace (subset_glyphclassdef || subset_attachlist || subset_ligcaretlist || subset_markattachclassdef || (out->version.to_int () >= 0x00010002u && subset_markglyphsetsdef) || diff --git a/src/hb-serialize.hh b/src/hb-serialize.hh index 73634e6b933..e988451eb36 100644 --- a/src/hb-serialize.hh +++ b/src/hb-serialize.hh @@ -91,6 +91,26 @@ struct hb_serialize_context_t } #endif + bool add_virtual_link (objidx_t objidx) + { + if (!objidx) + return false; + + auto& link = *virtual_links.push (); + if (virtual_links.in_error ()) + return false; + + link.objidx = objidx; + // Remaining fields were previously zero'd by push(): + // link.width = 0; + // link.is_signed = 0; + // link.whence = 0; + // link.position = 0; + // link.bias = 0; + + return true; + } + friend void swap (object_t& a, object_t& b) noexcept { hb_swap (a.head, b.head); @@ -469,16 +489,40 @@ struct hb_serialize_context_t assert (current); - auto& link = *current->virtual_links.push (); - if (current->virtual_links.in_error ()) + if (!current->add_virtual_link(objidx)) err (HB_SERIALIZE_ERROR_OTHER); + } - link.width = 0; - link.objidx = objidx; - link.is_signed = 0; - link.whence = 0; - link.position = 0; - link.bias = 0; + objidx_t last_added_child_index() const { + if (unlikely (in_error ())) return (objidx_t) -1; + + assert (current); + if (!bool(current->real_links)) { + return (objidx_t) -1; + } + + return current->real_links[current->real_links.length - 1].objidx; + } + + // For the current object ensure that the sub-table bytes for child objidx are always placed + // after the subtable bytes for any other existing children. This only ensures that the + // repacker will not move the target subtable before the other children + // (by adding virtual links). It is up to the caller to ensure the initial serialization + // order is correct. + void repack_last(objidx_t objidx) { + if (unlikely (in_error ())) return; + + if (!objidx) + return; + + assert (current); + for (auto& l : current->real_links) { + if (l.objidx == objidx) { + continue; + } + + packed[l.objidx]->add_virtual_link(objidx); + } } template diff --git a/test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=300.ttf b/test/subset/data/expected/apply_cvar_delta/Comfortaa-Regular-new.default.retain-all-codepoint.wght=300.ttf index 18b352e45e1320aa5019bca0a85ef9e4cec4d407..3b17439316b27bbb7c56b4ab524e504eca20b23b 100644 GIT binary patch delta 69 zcmeyZMcVEo9)=>=2)0(_Hm VSZz0-W?sbDypnbMN>;|pe*lEg6n+2z diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.default.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.default.retain-all-codepoint.ttf index 749ef45e722e58e3a61cd943ae9c7d5012e51d10..77658843e7c7a62982505a90e69b058fe63e8fb1 100644 GIT binary patch delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniDkOfn`fI{m||G@7=(aIfPire l5P#Ur&AFIy@&yi?&Fk3}8JpK}wXfr11Y)M`>$sTpq5;R#7bXAz delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYCiKnF}_%FvYO)G3Eo600E;h lkPzD3!>PnLIgrz4^LqA0jLqw~+ShS00x{F}bzIDP(Ez!17D@mB diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints-retain-gids.retain-all-codepoint.ttf index 8a7e8281c26a7fa750fa8fb8567e6ffbf31c4cdb..b752b3c6f54b16c01c8612fb27519892f7ac42a0 100644 GIT binary patch delta 83 zcmX?cgZsn{ZV?7X1_lNpAi=_*;O^q;=4u@nyiw#0BMV1V5AS9cCIx0b1|gslAYj}D i#NRgev#n&D9KvR^*_c(4vDt#7-GYO0y9Ec6z!Lxqy%O92 delta 83 zcmX?cgZsn{ZV?7X1_lNpAi=_*;O^q;mb2|B&qk3qj4V5om(1SG!lb~=$CwXP0tAf4 jKtgD<7`qbV1 diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.drop-hints.retain-all-codepoint.ttf index 711c070aa6693ba35699eab425d70f5ac6c9818f..d5603862761a5eb919cf5a02e51721867ea2e5c7 100644 GIT binary patch delta 83 zcmbPngL}peZV?7X1_lNpAi=_*;O^q;7HnvjzER{2Ba8kgrJ0*qm=u`#7=(aIfPire j5P#U*&$gIxatNEvW@A=G#%3dqb|VhP?M56-&mIE+7|#?F delta 83 zcmbPngL}peZV?7X1_lNpAi=_*;O^q;c4A8d*G7>yj4Up%=Lc_QVNzh`W6TFC0Rl#2 jAR)9_fL)1k@>MpQ&Bm;Y7@Lha+Ko6Ew;ORVJ$noQIkXfu diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.gids.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.gids.retain-all-codepoint.ttf index 749ef45e722e58e3a61cd943ae9c7d5012e51d10..77658843e7c7a62982505a90e69b058fe63e8fb1 100644 GIT binary patch delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniDkOfn`fI{m||G@7=(aIfPire l5P#Ur&AFIy@&yi?&Fk3}8JpK}wXfr11Y)M`>$sTpq5;R#7bXAz delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYCiKnF}_%FvYO)G3Eo600E;h lkPzD3!>PnLIgrz4^LqA0jLqw~+ShS00x{F}bzIDP(Ez!17D@mB diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.glyph-names.retain-all-codepoint.ttf index 56cba1bd0f098fe41c2df8454320b42c9c91692a..3a16f49c769ea1cf94fce8592d4ddaaf1f582b2a 100644 GIT binary patch delta 87 zcmZ3}#J8r2PlSPyfq_8`NU$&@xVyNz1smF>ZxrESV$quD7_eD|DTbAgK?tY>2pG2j l@rTW?ITkZc-oRnAxu0E;vAK_{y^o6#h?%zcaWT&;0{}XQ6=?tf delta 87 zcmZ3}#J8r2PlSPyfq_8`NU$&@xVyNzo!HXAwNZqJiN(HaAJ=9TrWjT}#(ba>AYe2G l5<;7EIF%SD8*K qh(B!R=3LA;`2vT{=Jo7~jFaW~*_*d=wQuEO1Y)M`Te+C;#{vNFP#7Kn delta 87 zcmbPok$1{PUJ(XH1_lN(Ai=_r;O^q;_Ik@gu8kr(Oe|}HjxXKp!W6^G$CwXP0tAf4 mKtgD952q62TELJ?C7;$zGgho3%OQ8JlIe+hw>JftYE#3^((JU;w|U6+{34 delta 87 zcmX@Jm-ozGUJ(XH1_lN(Ai=_r;O^q;*0VS1_eK#NCKiz^vK5JftYE#3^((JU;xF+6<+`V diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.name-ids.retain-all-codepoint.ttf index 660c052bf23e04cfc4d7ba544fca82ab000b7f51..3aad013e1a460c451cc3625028be30f08ae8f43e 100644 GIT binary patch delta 87 zcmca{lJ~|*UJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniRGB44a;U1rU({31|gslAYj}A l#2+@Zb1Y_@e1_d-^J+Fl#^zO=?W;H$ftYFgDo$p-XaIYK6`lY9 delta 87 zcmca{lJ~|*UJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYIYuJN9jMVTxekW6TFC0Rl#2 lAR)B5gF}gNvM-0t=GAPA7@Jpdwy)x31Y)M`t2mkUq5;*s7Qg@i diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.name-languages.retain-all-codepoint.ttf index 749ef45e722e58e3a61cd943ae9c7d5012e51d10..77658843e7c7a62982505a90e69b058fe63e8fb1 100644 GIT binary patch delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniDkOfn`fI{m||G@7=(aIfPire l5P#Ur&AFIy@&yi?&Fk3}8JpK}wXfr11Y)M`>$sTpq5;R#7bXAz delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYCiKnF}_%FvYO)G3Eo600E;h lkPzD3!>PnLIgrz4^LqA0jLqw~+ShS00x{F}bzIDP(Ez!17D@mB diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.name-legacy.retain-all-codepoint.ttf index 749ef45e722e58e3a61cd943ae9c7d5012e51d10..77658843e7c7a62982505a90e69b058fe63e8fb1 100644 GIT binary patch delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniDkOfn`fI{m||G@7=(aIfPire l5P#Ur&AFIy@&yi?&Fk3}8JpK}wXfr11Y)M`>$sTpq5;R#7bXAz delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYCiKnF}_%FvYO)G3Eo600E;h lkPzD3!>PnLIgrz4^LqA0jLqw~+ShS00x{F}bzIDP(Ez!17D@mB diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.no-prune-unicode-ranges.retain-all-codepoint.ttf index 749ef45e722e58e3a61cd943ae9c7d5012e51d10..77658843e7c7a62982505a90e69b058fe63e8fb1 100644 GIT binary patch delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniDkOfn`fI{m||G@7=(aIfPire l5P#Ur&AFIy@&yi?&Fk3}8JpK}wXfr11Y)M`>$sTpq5;R#7bXAz delta 87 zcmca}n)l9WUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYCiKnF}_%FvYO)G3Eo600E;h lkPzD3!>PnLIgrz4^LqA0jLqw~+ShS00x{F}bzIDP(Ez!17D@mB diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.notdef-outline.retain-all-codepoint.ttf index e33f66c27a6dbdcd25199b492061ca1625a4fbd3..2f4b98715dcf22af09c43de972e3dcef6fd3c7ff 100644 GIT binary patch delta 87 zcmdmRfp^0NUJ(XH1_lN(Ai=_r;O^q;7HnvjzEMPniN)dD?yAi$Ofjr{3_?I9K)|>K lh(B!R=3LA;`2vT{=Jo7~jLqw~+ShS00x{F}bzIC%u>h(F7Zv~j delta 87 zcmdmRfp^0NUJ(XH1_lN(Ai=_r;O^q;c4A8d*G3T?CYI0-7ABirm||G@81sQjfPm2$ lNC<82;Z$Or9LQ<2c|H3g#^!Zg?d!N0ftYFgIxgm>SOA-<7CHa` diff --git a/test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.retain-all-codepoint.ttf b/test/subset/data/expected/basics/Comfortaa-Regular-new.retain-gids.retain-all-codepoint.ttf index 93aa9829b8f554c156aac986577b9e8e335cb681..b19ee0fc845db97f57dd3467f2bb5170e20e548f 100644 GIT binary patch delta 87 zcmeAC)fq_8`NU$&@xVyNzxmpJXZxqpCV$uF6q_f$DDTbAgK?tY>2pD$( l@wd&~oGTe8U*NFWyq;Z=v3Uzu`xY)nAZFUWg^M{N8UR?T6|MjP delta 87 zcmeAC)fq_8`NU$&@xVyNz^# diff --git a/test/subset/data/expected/full-font/SourceSerifVariable-Roman.default.1FC,21,41,20,62,63.ttf b/test/subset/data/expected/full-font/SourceSerifVariable-Roman.default.1FC,21,41,20,62,63.ttf index 43edc2cc8f77f6470f200610c32b358254cb2032..9d6fc9d3001f4118ea77152035df3195349689fc 100644 GIT binary patch delta 71 zcmdlWw?R&XfsuiMK^RD|Fc`SIxVo`eit%m~kzisezZ!dKvH{apaUq}r7?5FL0%~9a QDrTJgiOF)aDf4e`0IWz1NB{r; delta 71 zcmdlWw?R&XfsuiMK^RD|Fc`SIxVnjDu<&dYkzis8E^oXt*??&)uNP1O3fsuiMK^RD|Fc`SIxVnj~eKC2XhzJwQrPqxYHtR6uGKvcURltA@0~1gO TBLg=BfsuiMK^RD|Fc`SIxVpVm5GmOxBErO?#jeG-S%)c?k+%q_0tSR8Z(vU3 SWCH49WZ-6C+$_LyLlFSyTnrNc diff --git a/test/subset/data/expected/full-font/SourceSerifVariable-Roman.default.61,62,63.ttf b/test/subset/data/expected/full-font/SourceSerifVariable-Roman.default.61,62,63.ttf index d049757ef27b6cf82697b2cd049222fd2fd6659b..07411395d41f59a054ee259e473a31ba345856e6 100644 GIT binary patch delta 71 zcmX>hdqP%(fsuiMK^RD|Fc`SIxVkZ0am#NMabRMZC;R-@E+Y delta 71 zcmX>hdqP%(fsuiMK^RD|Fc`SIxVmwdF!OE{abRNUUHL<9as*Q@uM1EC3fsuiMK^RD|Fc`SIxVnj~eKC2XhzJwQrPqxYHtR6uGKvcURltA@0~1gO TBLg=BfsuiMK^RD|Fc`SIxVpVm5GmOxBErO?#jeG-S%)c?k+%q_0tSR8Z(vU3 SWCH49WZ-6C+$_LyLlFSyTnrNc diff --git a/test/subset/data/expected/full-font/SourceSerifVariable-Roman.drop-hints.61,62,63.ttf b/test/subset/data/expected/full-font/SourceSerifVariable-Roman.drop-hints.61,62,63.ttf index d049757ef27b6cf82697b2cd049222fd2fd6659b..07411395d41f59a054ee259e473a31ba345856e6 100644 GIT binary patch delta 71 zcmX>hdqP%(fsuiMK^RD|Fc`SIxVkZ0am#NMabRMZC;R-@E+Y delta 71 zcmX>hdqP%(fsuiMK^RD|Fc`SIxVmwdF!OE{abRNUUHL<9as*Q@uM1EC3fsuiMK^RD|Fc`SIxVo`eit%m~VPRsKU;FRTWErNd;zB?LFd)Og1k}I; QRLnT}9+Tx}MdtV10H+TOEdT%j delta 71 zcmbOrH$hH>fsuiMK^RD|Fc`SIxVnjDu<&dYVPRsaR#18}S%zsVuNP1O3q`AiJRZD#47**J4X(( delta 72 zcmX@(b;e7CfsuiMK^RD|Fc`SIxVpVm5GmOxBEZC=_}=5*W(_7^Cf*{T3K$TY+{2Q{ S$pqBJ$iU6OxcLoBf&u^;=MBFA diff --git a/test/subset/data/expected/full-font/SourceSerifVariable-Roman.filter-scripts.61,62,63.ttf b/test/subset/data/expected/full-font/SourceSerifVariable-Roman.filter-scripts.61,62,63.ttf index 590ccb9720827710b5a34bd8fff88db925a059da..bc71acff5376ec4389895cbfda800b1ff90c3b3b 100644 GIT binary patch delta 71 zcmZ1>yFylkfsuiMK^RD|Fc`SIxVkZ0am#NM(P3gadaRRcvI|qLxDZeQ49GAr0W~l( RFf%Yt-p6FT`8U&AZUC7O3;O^7 delta 71 zcmZ1>yFylkfsuiMK^RD|Fc`SIxVmwdF!OE{(P3iQ8Z=XHvI|o#uM1EC3jIY&~5fsuiMK?F#!FgUooxVm+=@!w)#U_ApA{ox+qADnsg&U~Qc9U%Y1M4fKg zBMc0Te(7b2MIlRsPcSfWh%hiPab=_?rl>yCPMLTmm{DP~2BQq4jH*UzLp;CDR|aPG z3qZXLcmG@M0@07OmtNkSz*NsP`8sP*G7|#_&;c9_ObiYTE>~v delta 337 zcmbOuc}7x)fsuiMK?F#!FgUooxVm+o=z)zFTE_WC}fH72?hoZpd=GlMrvY;;;TmgiC2Od12$_g$}q~Pd+nYR&u{aUftmdR z&@6_#|E+d`=zIFV_iavKs%PS7W_SVQ3xNcIVA|w+tgVxa*@7k~vx!W8$P!S`$-u$D z#8AY*1#}`4Pz8u*zyP$5A%I~Xkj(1Dyf`Obkgt zehiEYW{Wa}f%yNYG6ekp%isl;V*;82G6w`W8bBl$m}GBYn0$s!SsfzF1QZ8(ml0?m qh-3tsHx0-V0%8zYHu)V(D?bxZ79_(6bO+F7lZ#k`H-BY&&k6uYuR03= delta 337 zcmdlY`9xBOfsuiMK?F#!FgUooxVm+o=z)zFTE_W=;HqK(F_b6KuIQ*jMT&w#aE5~6R!j_W^C4Alwp+76?Son=ePOFz|4LD zXcoiW|5m#|^gaFG`!**q)id!kGrR!ug+PKpFm3WZ*4D|zY(bNg*+eEkWC^I}WZ+<6 zVklzZ0y>cir~7ZspV9|kj^Ai^S$1DF}KfMU#G2e40` P!m7*y(zN+7+ecOa3>rGG diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=200-300-500,wdth=80-90.iup_optimize.ttf index 5d138ef29e7212e9420d2cdf4c74556f0b8806c6..a447b7ba556287ae285868250e3ba91976d3b4a3 100644 GIT binary patch delta 71 zcmaFk{Ki>?fsuiMK@3Q+FeJFUxVlx|vlZPaQp3dZHas?U@)V{_aUq}r7?5FL0%~An RU}j*P%*AZF*^_y(8~`WJ4Q~Jd delta 71 zcmaFk{Ki>?fsuiMK@3Q+FeJFUxVqWqRBqTPQp3cOX7xmW@)V{_UN@iu7!aB)!feXP R1k}XHz|6q7*@JnB8~`pk4R`k!@U}Rum5Cak{3<>Tou5Ok0Y(+PU)G)Es7d=*;JcTJ!TnMND24onRfEpMX Rm>C!+b1|E4_GI2I2LSCJ46FbE delta 71 zcmZp1X>k!@U}Rum5Cak{3<>Tou5PwDl^ZsS)G)F92+Mpwc?we|uNzPS3oHlh-gAiVFc1z<>+`6Ho&q S12Y5T delta 71 zcmZ2sy~0|AfsuiMK@3Q+FeJFUxVo`U{1?4ZWC|0@!BzVtCa+;Kz`O>kaS# diff --git a/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=300-600,wdth=85.ttf b/test/subset/data/expected/glyf_partial_instancing/Roboto-Variable.ABC.default.retain-all-codepoint.wght=300-600,wdth=85.ttf index 2447337a4bab459574e4a7876518cc8a5d102999..4f5c057613895730c745e4917fefa847b89b2046 100644 GIT binary patch delta 71 zcmZ2sy~0|AfsuiMK@3Q+FeJFUxVru7W(?UVGKGod`i>oHlh-gAiVFc1z<>+`6Ho&q S12Y5T delta 71 zcmZ2sy~0|AfsuiMK@3Q+FeJFUxVo`U{1?4ZWC|0@!BzVtCa+;Kz`O>kaS# diff --git a/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=300-600.iup_optimize.ttf b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=300-600.iup_optimize.ttf index 46885af6856d7cb8af797c29d93dec7ccfe32180..b20d328638898112e4867b9a3ee4e2f7875ba252 100644 GIT binary patch delta 87 zcmca{Oz6fjArS^f1_lOUAi=_5;O^q;rpI9Guu)_KBg?(=2Jy`&7(F=o7*c>r7#M^= l1mmgAA9;5&ZkFf1%+$P!zkL-yBM>tIG4u9S{4DDx0|2_!7u5g& delta 87 zcmca{Oz6fjArS^f1_lOUAi=_5;O^q;=D;;&#zv71j4Zp7E~alj!RW!s$7~K%!oc(t lL^23%zQ%KfX|p`{4#wtH{Ozmw8G)Dyh?%#q;%8Ym836x37~TK? diff --git a/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=300-600.ttf b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=300-600.ttf index 22ea1db7b83eb2add9af6c9d293f851be2420c20..781934111656e7906fc00e943cd06790e656523b 100644 GIT binary patch delta 87 zcmX?dUg*eqArS^f1_lOUAi=_5;O^q;rpI9Guu)_KBa6^4;q#kMFnVzEF{A*MFfa&# l2*y*JKl1Km+$_(1nW=ddfBPzaMj&PaV&?6u_*tZ8006M$7cu|< delta 87 zcmX?dUg*eqArS^f1_lOUAi=_5;O^q;=D;;&#zv71j4bb-rpj+V!RW!s$7~K%!oc(t lL^23%zQ%KfX|p`{4#wtH{Ozmw8G)Dyh?%#q;%AYX0RZ@e7(4&~ diff --git a/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=500-800.iup_optimize.ttf b/test/subset/data/expected/update_def_wght/SourceSerifVariable-Roman.default.retain-all-codepoint.wght=500-800.iup_optimize.ttf index f9435b588658cd2f3639c33d8076a7dbc3b407c8..edbda6a43795b375ab1e57a356386ac6c9ab4a71 100644 GIT binary patch delta 80 zcmcaGpZ~&qeh~&n1_lOUAi=_5;O^q;mTs@mwo&8-Ba4$C%bHD0f{eT=Km`m8LLh?i e)aDt?I~ga-GgmbSvbG1ZG6FHv_CQwV`cnYeR1)X_ delta 80 zcmcaGpZ~&qeh~&n1_lOUAi=_5;O^q;mgcIkXQRjqMiv(*7Kcqtf{eWPfC?BGdcdU6 deh~&n1_lOUAi=_5;O^q;mTs@mwo&8-Bg?f6wpE*$1Q~f#fC?BGgg^x2 fsm(K(cQQ_vXRc}vWNi;*WdvfT?SZV!k52;t>q-;J delta 80 zcmdn8h=0o>eh~&n1_lOUAi=_5;O^q;mgcIkXQRjqMwS~fY<8QN1Q~hn0TnPX^ngjB e$=6t_H_J2cU~CR#Z4YE+1Y)M`fvn7rPXhq=niL2C diff --git a/test/subset/data/fonts/AnekBangla-subset.ttf b/test/subset/data/fonts/AnekBangla-subset.ttf index e8228d76045f57a82b73627805a9ed6101bafd25..3595d2525c218f18e59cd761d1e013292339a093 100644 GIT binary patch delta 1356 zcmZ8gYiJx*6#nMU?9A*V+q4bXXlY}Kacx75A=Ey?HZ5sVV%lgnO|%Aey4mc8WH(E) zhNMb2fr@`bkWuW9P>WO)1g#_@NU9brGzwDnkBBYe&laUr6MW!azk4S>@D6kC`Of+7 zdECd%&5?}YGyonnReIEj< zV#K@Cd9Pet-E3a~L^loH!z8RPT$d!Y6Q9X?lSR%9?#y#`vtu*E$6ndjO8z2~9LwnY7aGpd zP?Ptji`aydT<{igUBSy|CO>+6AGgN>%&Fq|WJ$h;W)}3U@)svE#hm@Zb6kIh*wMRb z;PTE$e)!3Ctt&8{tF+^q-20)Lf7tQH*I3U|mqKbsZS)9b=HLm0KmCK9I6FzGwU>0L zz!%7{wuG?_Ci>z2&uQx)EGrNdA%&>GkQJk1NU1l5m_x208o#{~jjo_h-i)uV zR^R$jhuDlbBGeiohDIh!Xd2B-6wm~#y`#GijVCgNED|RQ*=8ihyi!5&^u{$Xs4B$e zuWn))Qffmm8>Bq}bpvxa#ogx7uML4V`a1rGT8~5BHOLpy%QhZe^SQH132PbAGODFR zDVWR9$%9#x5!9m+D=jc9q>lC9k5`tDAwqi#T4AQs`67~9c8!f>J(e7Fp46Qub>~Ul z`N6fwEo??zo%*$mK{n>s+l@PEuG6jtlG^w;(NmA@>`!VAd0JD&1%;_uXrzi2Oc3I? z1r6NV4SYf4x-uaCv3(+Gw-pK8*9691FDETd(YfmQV?h{Z4< zwlN@I$K&#MSnsY%OjJHF`sMrb^9vgj=$GekT>gsCdp{c(rza&B_!AEyW&l*97$a!D?mcioFb<*0E@7G$}mBMA{h7;!fej;@PUVPUFj PtKlzOFE6|l|JeQuTS6?^0o|4Xx<3TxSm;&|X56uL?Xc~dZCSP$ zZHf5BDAAlGn3zcXiqXL!Bsj>3@WBiX`hgG=7EDY`G#G<+K^lAhp7+LPY?#{f3Uqz_koU)Ww)e=I+qFc&N#F%*!W#YcrJEk2 z&|cu@1~OJYx46zb4TCu_I)|X}Kz6}FHkW{pC9Sa>?n)%Y0gYsOYN+>U6O!}vAz)V$ z`h}fSo8a&RBJW%(VGTb1OCb;XCiFL_z^F=zdH9D7)uuAzlhH?I5O_7?^hno$CB6`U z!QcuQ;fytzqgwGY@aMphtd&WOT{zK%V4XzTL~dkk-1(FmkV}~5xzR)}<$doRV03_d zGrB&d*=@mNGiPMCsNvrFsYt6RP6jbrc{CFCarw{|<_fy}cGDa0zqYEmNSf~|E8TD! z&+)ymv2>v{U;5a*W-I`DNivtnj>`3Qu=QUmp?vd5Y5uNeUi)7Rj;?#w+E+xM-6?zR zH+|{6B(1;^b<$*?@+X(^d4;{e5>yp5Qi|gNN7KJoH2p_9tT?)o{-9_9nkx#EhLfj$ z81FgwGv;Uxq}^}qe~~q~4k63P1I=R^91X|=KfbaoOGnDG;Gg5j(CuPHv7(|FT8#X* zSoy~-^4YV-K6iNo)J)x^x3+io(1rtvY?7)EWRne4owmlav_SfD!JwlQu6kVrY^4gKW8cwL7 zTB%NV(9B^Tp{8w=TIy8weVvLfcZ#d#GVq{p90Mf`3}kW?R%dm3IBC&i5VKczlza;w z2yf1lI9bTm2S8WRY9-<6y6*VoX|o2uo7L?h6PvRRuA}H7cMW@^ZVg`9M#m|YmzAD! zXnc+0RjOl>AI>WR6LKPJAcB4 z$I4s5OU+5ROL|tsr$^5`7@aSl6|vJJr$f>2oJZ(yZO!c3x^JMTE!l7DLVdd%Gg0PO#phM7UbdncawjNs2a6b&+Jul@hal^?v`Eazo1sZ+|=pMr# Qt~6)r%^ETDQ}8SAzgB|w#{d8T From 96f0038e3969d175e131daee6f47e77876f3837d Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 28 Mar 2024 23:11:16 +0000 Subject: [PATCH 3/5] [subset] cast. --- src/OT/Layout/GDEF/GDEF.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index afec61c4149..e9fd3152989 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -671,7 +671,7 @@ struct GDEFVersion1_2 return_trace (false); bool subset_varstore = false; - unsigned varstore_index = -1; + unsigned varstore_index = (unsigned) -1; auto snapshot_version2 = c->serializer->snapshot (); if (version.to_int () >= 0x00010003u) { From 992953fd3e9b721e8ef5ebf3cb0044b92833e510 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Thu, 28 Mar 2024 23:12:21 +0000 Subject: [PATCH 4/5] [subset] updated comment. --- src/OT/Layout/GDEF/GDEF.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/src/OT/Layout/GDEF/GDEF.hh b/src/OT/Layout/GDEF/GDEF.hh index e9fd3152989..317b96c714b 100644 --- a/src/OT/Layout/GDEF/GDEF.hh +++ b/src/OT/Layout/GDEF/GDEF.hh @@ -666,6 +666,7 @@ struct GDEFVersion1_2 // Push var store first (if it's needed) so that it's last in the // serialization order. Some font consumers assume that varstore runs to // the end of the GDEF table. + // See: https://github.com/harfbuzz/harfbuzz/issues/4636 auto snapshot_version0 = c->serializer->snapshot (); if (unlikely (version.to_int () >= 0x00010002u && !c->serializer->embed (markGlyphSetsDef))) return_trace (false); From 69f9c29ec1bff4411f46be63f1b887f42cc74d24 Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Fri, 29 Mar 2024 00:19:16 +0000 Subject: [PATCH 5/5] [repacker] add tests of serializer repack_last(). --- src/test-repacker.cc | 112 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 11 deletions(-) diff --git a/src/test-repacker.cc b/src/test-repacker.cc index 7f57d8eac1d..7f89fbfa32a 100644 --- a/src/test-repacker.cc +++ b/src/test-repacker.cc @@ -433,16 +433,13 @@ struct MarkBasePosBuffers } }; - - - - static void run_resolve_overflow_test (const char* name, hb_serialize_context_t& overflowing, hb_serialize_context_t& expected, unsigned num_iterations = 0, bool recalculate_extensions = false, - hb_tag_t tag = HB_TAG ('G', 'S', 'U', 'B')) + hb_tag_t tag = HB_TAG ('G', 'S', 'U', 'B'), + bool check_binary_equivalence = false) { printf (">>> Testing overflowing resolution for %s\n", name); @@ -452,6 +449,10 @@ static void run_resolve_overflow_test (const char* name, graph_t expected_graph (expected.object_graph ()); if (graph::will_overflow (expected_graph)) { + if (check_binary_equivalence) { + printf("when binary equivalence checking is enabled, the expected graph cannot overflow."); + assert(!check_binary_equivalence); + } expected_graph.assign_spaces (); expected_graph.sort_shortest_distance (); } @@ -464,12 +465,27 @@ static void run_resolve_overflow_test (const char* name, graph)); // Check the graphs can be serialized. - hb_blob_t* out = graph::serialize (graph); - assert (out); - hb_blob_destroy (out); - out = graph::serialize (expected_graph); - assert (out); - hb_blob_destroy (out); + hb_blob_t* out1 = graph::serialize (graph); + assert (out1); + hb_blob_t* out2 = graph::serialize (expected_graph); + assert (out2); + if (check_binary_equivalence) { + unsigned l1, l2; + const char* d1 = hb_blob_get_data(out1, &l1); + const char* d2 = hb_blob_get_data(out2, &l2); + + bool match = (l1 == l2) && (memcmp(d1, d2, l1) == 0); + if (!match) { + printf("## Result:\n"); + graph.print(); + printf("## Expected:\n"); + expected_graph.print(); + assert(match); + } + } + + hb_blob_destroy (out1); + hb_blob_destroy (out2); // Check the graphs are equivalent graph.normalize (); @@ -779,6 +795,54 @@ populate_serializer_with_isolation_overflow_spaces (hb_serialize_context_t* c) c->end_serialize(); } +static void +populate_serializer_with_repack_last (hb_serialize_context_t* c, bool with_overflow) +{ + std::string large_string(70000, 'c'); + c->start_serialize (); + c->push(); + + // Obj E + unsigned obj_e_1, obj_e_2; + if (with_overflow) { + obj_e_1 = add_object("a", 1, c); + obj_e_2 = obj_e_1; + } else { + obj_e_2 = add_object("a", 1, c); + } + + // Obj D + c->push(); + add_offset(obj_e_2, c); + extend(large_string.c_str(), 30000, c); + unsigned obj_d = c->pop_pack(false); + + add_offset(obj_d, c); + assert(c->last_added_child_index() == obj_d); + + if (!with_overflow) { + obj_e_1 = add_object("a", 1, c); + } + + // Obj C + c->push(); + add_offset(obj_e_1, c); + extend(large_string.c_str(), 40000, c); + unsigned obj_c = c->pop_pack(false); + + add_offset(obj_c, c); + + // Obj B + unsigned obj_b = add_object("b", 1, c); + add_offset(obj_b, c); + + // Obj A + c->repack_last(obj_d); + c->pop_pack(false); + + c->end_serialize(); +} + static void populate_serializer_spaces (hb_serialize_context_t* c, bool with_overflow) { @@ -2167,6 +2231,31 @@ test_shared_node_with_virtual_links () free(buffer); } +static void +test_repack_last () +{ + size_t buffer_size = 200000; + void* buffer = malloc (buffer_size); + assert (buffer); + hb_serialize_context_t c (buffer, buffer_size); + populate_serializer_with_repack_last (&c, true); + + void* expected_buffer = malloc (buffer_size); + assert (expected_buffer); + hb_serialize_context_t e (expected_buffer, buffer_size); + populate_serializer_with_repack_last (&e, false); + + run_resolve_overflow_test ("test_repack_last", + c, + e, + 20, + false, + HB_TAG('a', 'b', 'c', 'd'), + true); + + free (buffer); + free (expected_buffer); +} // TODO(garretrieger): update will_overflow tests to check the overflows array. // TODO(garretrieger): add tests for priority raising. @@ -2195,6 +2284,7 @@ main (int argc, char **argv) test_duplicate_leaf (); test_duplicate_interior (); test_virtual_link (); + test_repack_last(); test_shared_node_with_virtual_links (); test_resolve_with_extension_promotion (); test_resolve_with_shared_extension_promotion ();