From 9228db06f46908afd0e62f5964470c37c66ba91f Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Sat, 13 Oct 2018 17:25:09 -0700 Subject: [PATCH] added CFF1 Expert Encoding subset test & bug fixes --- src/hb-ot-cff1-table.hh | 8 +++++++- src/hb-subset-cff1.cc | 10 ++++++++-- test/api/fonts/cff1_expert.2D,F6E9,FB00.otf | Bin 0 -> 3096 bytes test/api/fonts/cff1_expert.otf | Bin 0 -> 3656 bytes test/api/test-subset-cff1.c | 21 +++++++++++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 test/api/fonts/cff1_expert.2D,F6E9,FB00.otf create mode 100644 test/api/fonts/cff1_expert.otf diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index 71e6953..9b913e0 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -1121,7 +1121,13 @@ struct cff1 const OT::cff1 *cff = this->blob->as (); encoding = &Null(Encoding); - charset = &StructAtOffsetOrNull (cff, topDict.CharsetOffset); + if (is_predef_charset ()) + charset = &Null(Charset); + else + { + charset = &StructAtOffsetOrNull (cff, topDict.CharsetOffset); + if (unlikely ((charset == &Null (Charset)) || !charset->sanitize (&sc))) { fini (); return; } + } if (is_CID ()) { if (unlikely (charset == &Null(Charset))) { fini (); return; } diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 42b47f1..d2d65ed 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -615,12 +615,18 @@ struct cff_subset_plan { final_size += offsets.globalSubrsInfo.size; /* Encoding */ - offsets.encodingOffset = final_size; + if (!subset_encoding && acc.is_predef_charset ()) + offsets.encodingOffset = acc.topDict.EncodingOffset; + else + offsets.encodingOffset = final_size; if (subset_encoding) final_size += plan_subset_encoding (acc, plan); /* Charset */ - offsets.charsetInfo.offset = final_size; + if (!subset_charset && acc.is_predef_charset ()) + offsets.charsetInfo.offset = acc.topDict.CharsetOffset; + else + offsets.charsetInfo.offset = final_size; final_size += offsets.charsetInfo.size; /* FDSelect */ diff --git a/test/api/fonts/cff1_expert.2D,F6E9,FB00.otf b/test/api/fonts/cff1_expert.2D,F6E9,FB00.otf new file mode 100644 index 0000000000000000000000000000000000000000..8c198b767af89581394d900f6d2e9b0ff5653961 GIT binary patch literal 3096 zcmbVOU1%It6h3!mcau%FNn315A(jiZf7;A$wn-sP!KP`0p&=WyY3mPKC%co~CE1yE zX11FY!GeOeMNp9DMW`=Aeel^wqfnnpKv1ktRS;=k6cKAB*!Z2fv)%1df7)5@z31ni zbI;FrFPoW}$xximkxm;&$HwGSD|tag9}tO4nQSus!fz`d5orsMy^<@Nl|MFqUjTm% z{JElK=DV(HSHKT|KTw1~|L*RuMEV5yCyHf%5i35uf~liyE>n{u7LX{%6OFkRN9dc|ARE8Z5p z;(P+c1^sYBe;lzt-Hn;V#$Gzi?8(hMk8Pre5K-%!AJaxUrJTx=Cr#q7{0JD+r1=|JPkoKv-Zw`6(7 zs8d;TONF8@)2aT{KAzLTJn(NP>?!(w1t(BMC zT4e2z#kYSrdpZ%nnCM*XxY49)pertkKxHCkV9Q0rgE zw?&l=g!mG{%(&){{q}_eesAAWgMF<*%tM{1U%&ecGvUWEG=D8Ta^zfzdc>|EUaoC7 zc(qTXHgJm8X%}q`=}6O_DDKOlP#&W#WOE#mIDC9bZ-lgwEkj9Z_uUwPDpprKtRE196M>bUdgeg z+Ff+~oMWGn{YJ{@PYn&1&3Vi5=d48w8wQO7gM&l+ALxueCW&&Vs2@WD5Or<<)ClFt zp;@v(XK9H%@#+v3?Er@^|^OkfqBRr zocX97E(N)A$2j5>;JAOPUs+HJ3+i+m=O%HQ8=R?Zm}cx$Vac(TVCy00N5R_^PUFr> zbke~5Oz8FhW6%e(D~MnQ`KX#TFvk_0LyWbcZk(;!v49oWL;Q?Z#wq8*73SRPmC53k zOn}b>{uv()&lC4~;9Jm&CB_R6*%aCR=hmY!fiDyO7~iv)InKtNVg!t#w$Eba&K$&g ze|0?M!d<99%Y9%xFJR@a70|s5>?c|xX=L(GHOj*azZmR!7WJtkMBNm=p?s4^fNy?H zvbe_*cZzv%!Mkt@)C@YB0mf#aJq7JFej|7bW}rJ3*k&M+G>To5zyMo}2Q>TT$Qk96 z^gPz%(C{9vwuPt~Xyn^hL8OdB#;w9@3HPOfN-#e2LH=1#T-}H7ump~j*Sf72pdttF za~L^z<^I{Icok~_=Wv{iOc!x*E$i=0<7Tl9N6EQxZ`C`*`T|blH`IkkzOMzymLTI- zlhMk!t-k^s(SIS|cqGhZgPc6rs#|h4h{!?T)SFa7T#QA|V+4aS!V#+%gz@?yX#w`U Xk1MDAj`Keb{zrpveHD-B1HQijZ@D^w literal 0 HcmV?d00001 diff --git a/test/api/fonts/cff1_expert.otf b/test/api/fonts/cff1_expert.otf new file mode 100644 index 0000000000000000000000000000000000000000..970ed6796d37aece743eec35a30163120951e280 GIT binary patch literal 3656 zcmdT`Yitx%6h5=FyM4ESQd=J7mQo%{cehK6X^W9kC^l3U*g_=)%5-f4nVqsN zhJYc4V6A{6jWGt$7$r(H`oowQQ4@T`1fq#i6G9~+hWJBbjI;*B`kk5S15zLGOJ_3o zo_o$c=bp!R@7zFJTYz$DKglGTnwv%8#*SG;d2@&y#_C|pS|XB&3Rj}f4g|ga?dQHe z4c0V_cZT9h@>=V&0iv8M;1x$zC0uyU@j7I0;#(dCL;n8eFQ6f(1<|_rlH_fC3>`BfXXn#rvY+9l+sl}!pR47GkTBcU1 z*QTA5=C~*Jq$DdW~Wre++nCA1V8X^LTf6x1fzPvO&PH(IvV4C@I<1+9mLIJiQTz#ENv zF)Ku>C?(J2F=hraGhuqU0dq9dY6SCpz}FG22eER@4Tx|xt)c*^NfyWTE$yn?^ewFb z^w!W8)7KRIXD>OE6Skw^8D^vjL?e)4mU+xf*I~styy=EM&+0t!Vu5$T?O0;G@FymDcI&!h z-YCGA0(*?_PPFXj#GYaVG$Xeg(Q{?$(chY#6k_2jBq8NGFrItR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