From fdbfa1848b2f279c0f7a885bc1a985fa3375cfcd Mon Sep 17 00:00:00 2001 From: Michiharu Ariza Date: Thu, 16 Aug 2018 00:13:09 -0700 Subject: [PATCH] renamed CFF version 1 structs and sources to CFF1 from CFF "CFF" is used for shared structs & sources between CFF1 & CFF2 except OT:cff is for CFF version 1 table --- src/Makefile.sources | 8 +- ...-cff-interp-cs.hh => hb-cff1-interp-cs.hh} | 22 +-- ...hb-ot-cff-table.hh => hb-ot-cff1-table.hh} | 150 +++++++++--------- src/hb-ot-font.cc | 2 +- src/{hb-subset-cff.cc => hb-subset-cff1.cc} | 86 +++++----- src/{hb-subset-cff.hh => hb-subset-cff1.hh} | 8 +- src/hb-subset.cc | 2 +- 7 files changed, 139 insertions(+), 139 deletions(-) rename src/{hb-cff-interp-cs.hh => hb-cff1-interp-cs.hh} (93%) rename src/{hb-ot-cff-table.hh => hb-ot-cff1-table.hh} (81%) rename src/{hb-subset-cff.cc => hb-subset-cff1.cc} (87%) rename src/{hb-subset-cff.hh => hb-subset-cff1.hh} (91%) diff --git a/src/Makefile.sources b/src/Makefile.sources index edd9c6516..f5e1a6d43 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -26,7 +26,7 @@ HB_BASE_sources = \ hb-ot-color-cbdt-table.hh \ hb-ot-cmap-table.hh \ hb-ot-glyf-table.hh \ - hb-ot-cff-table.hh \ + hb-ot-cff1-table.hh \ hb-ot-cff2-table.hh \ hb-ot-hdmx-table.hh \ hb-ot-head-table.hh \ @@ -154,7 +154,7 @@ HB_OT_sources = \ hb-ot-var-mvar-table.hh \ hb-cff-interp-common-private.hh \ hb-cff-interp-cs-common-private.hh \ - hb-cff-interp-cs.hh \ + hb-cff1-interp-cs.hh \ hb-cff-interp-dict-common-private.hh \ $(NULL) @@ -215,7 +215,7 @@ HB_SUBSET_sources = \ hb-static.cc \ hb-subset.cc \ hb-subset-glyf.cc \ - hb-subset-cff.cc \ + hb-subset-cff1.cc \ hb-subset-cff2.cc \ hb-subset-cff-common-private.cc \ hb-subset-input.cc \ @@ -225,7 +225,7 @@ HB_SUBSET_sources = \ HB_SUBSET_headers = \ hb-subset.h \ hb-subset-glyf.hh \ - hb-subset-cff.hh \ + hb-subset-cff1.hh \ hb-subset-cff2.hh \ hb-subset-cff-common-private.hh \ hb-subset-plan.hh \ diff --git a/src/hb-cff-interp-cs.hh b/src/hb-cff1-interp-cs.hh similarity index 93% rename from src/hb-cff-interp-cs.hh rename to src/hb-cff1-interp-cs.hh index 867ef24a2..33a63cca0 100644 --- a/src/hb-cff-interp-cs.hh +++ b/src/hb-cff1-interp-cs.hh @@ -23,21 +23,21 @@ * * Adobe Author(s): Michiharu Ariza */ -#ifndef HB_CFF_INTERP_CS_HH -#define HB_CFF_INTERP_CS_HH +#ifndef HB_CFF1_INTERP_CS_HH +#define HB_CFF1_INTERP_CS_HH #include "hb-private.hh" -#include "hb-cff-interp-cs.hh" +#include "hb-cff-interp-cs-common-private.hh" namespace CFF { using namespace OT; -struct CFFCSInterpEnv : CSInterpEnv +struct CFF1CSInterpEnv : CSInterpEnv { - inline void init (const ByteStr &str, const CFFSubrs &globalSubrs, const CFFSubrs &localSubrs) + inline void init (const ByteStr &str, const CFF1Subrs &globalSubrs, const CFF1Subrs &localSubrs) { - CSInterpEnv::init (str, globalSubrs, localSubrs); + CSInterpEnv::init (str, globalSubrs, localSubrs); seen_width = false; seen_moveto = true; seen_hintmask = false; @@ -101,9 +101,9 @@ struct CFFCSInterpEnv : CSInterpEnv }; template -struct CFFCSOpSet : CSOpSet +struct CFF1CSOpSet : CSOpSet { - static inline bool process_op (OpCode op, CFFCSInterpEnv &env, PARAM& param) + static inline bool process_op (OpCode op, CFF1CSInterpEnv &env, PARAM& param) { Number n1, n2; @@ -265,7 +265,7 @@ struct CFFCSOpSet : CSOpSet env.clear_stack (); break; default: - typedef CSOpSet SUPER; + typedef CSOpSet SUPER; if (unlikely (!SUPER::process_op (op, env, param))) return false; env.process_width (); @@ -276,8 +276,8 @@ struct CFFCSOpSet : CSOpSet }; template -struct CFFCSInterpreter : CSInterpreter {}; +struct CFF1CSInterpreter : CSInterpreter {}; } /* namespace CFF */ -#endif /* HB_CFF_INTERP_CS_HH */ +#endif /* HB_CFF1_INTERP_CS_HH */ diff --git a/src/hb-ot-cff-table.hh b/src/hb-ot-cff1-table.hh similarity index 81% rename from src/hb-ot-cff-table.hh rename to src/hb-ot-cff1-table.hh index 7b17ef122..10a95998e 100644 --- a/src/hb-ot-cff-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -24,11 +24,11 @@ * Adobe Author(s): Michiharu Ariza */ -#ifndef HB_OT_CFF_TABLE_HH -#define HB_OT_CFF_TABLE_HH +#ifndef HB_OT_CFF1_TABLE_HH +#define HB_OT_CFF1_TABLE_HH #include "hb-ot-cff-common-private.hh" -#include "hb-subset-cff.hh" +#include "hb-subset-cff1.hh" namespace CFF { @@ -38,15 +38,15 @@ namespace CFF { */ #define HB_OT_TAG_cff HB_TAG('C','F','F',' ') -typedef Index CFFIndex; -template struct CFFIndexOf : IndexOf {}; +typedef Index CFF1Index; +template struct CFF1IndexOf : IndexOf {}; -typedef Index CFFIndex; -typedef CFFIndex CFFCharStrings; -typedef FDArray CFFFDArray; -typedef Subrs CFFSubrs; +typedef Index CFF1Index; +typedef CFF1Index CFF1CharStrings; +typedef FDArray CFF1FDArray; +typedef Subrs CFF1Subrs; -struct CFFFDSelect : FDSelect {}; +struct CFF1FDSelect : FDSelect {}; /* Encoding */ struct Encoding0 { @@ -133,7 +133,7 @@ struct EncSupplement { DEFINE_SIZE_STATIC (3); }; -struct CFFSuppEncData { +struct CFF1SuppEncData { inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -207,12 +207,12 @@ struct Encoding { return false; } - inline const CFFSuppEncData &suppEncData (void) const + inline const CFF1SuppEncData &suppEncData (void) const { if ((format & 0x7F) == 0) - return StructAfter (u.format0.codes[u.format0.nCodes-1]); + return StructAfter (u.format0.codes[u.format0.nCodes-1]); else - return StructAfter (u.format1.ranges[u.format1.nRanges-1]); + return StructAfter (u.format1.ranges[u.format1.nRanges-1]); } HBUINT8 format; @@ -220,7 +220,7 @@ struct Encoding { Encoding0 format0; Encoding1 format1; } u; - /* CFFSuppEncData suppEncData; */ + /* CFF1SuppEncData suppEncData; */ DEFINE_SIZE_MIN (1); }; @@ -356,7 +356,7 @@ struct Charset { DEFINE_SIZE_MIN (1); }; -struct CFFTopDictValues : TopDictValues +struct CFF1TopDictValues : TopDictValues { inline void init (void) { @@ -407,9 +407,9 @@ struct CFFTopDictValues : TopDictValues TableInfo privateDictInfo; }; -struct CFFTopDictOpSet : TopDictOpSet +struct CFF1TopDictOpSet : TopDictOpSet { - static inline bool process_op (OpCode op, InterpEnv& env, CFFTopDictValues& dictval) + static inline bool process_op (OpCode op, InterpEnv& env, CFF1TopDictValues& dictval) { switch (op) { @@ -493,7 +493,7 @@ struct CFFTopDictOpSet : TopDictOpSet } }; -struct CFFFontDictValues : DictValues +struct CFF1FontDictValues : DictValues { inline void init (void) { @@ -509,9 +509,9 @@ struct CFFFontDictValues : DictValues TableInfo privateDictInfo; }; -struct CFFFontDictOpSet : DictOpSet +struct CFF1FontDictOpSet : DictOpSet { - static inline bool process_op (OpCode op, InterpEnv& env, CFFFontDictValues& dictval) + static inline bool process_op (OpCode op, InterpEnv& env, CFF1FontDictValues& dictval) { switch (op) { case OpCode_FontName: @@ -540,13 +540,13 @@ struct CFFFontDictOpSet : DictOpSet }; template -struct CFFPrivateDictValues_Base : DictValues +struct CFF1PrivateDictValues_Base : DictValues { inline void init (void) { DictValues::init (); subrsOffset = 0; - localSubrs = &Null(CFFSubrs); + localSubrs = &Null(CFF1Subrs); } inline void fini (void) @@ -566,15 +566,15 @@ struct CFFPrivateDictValues_Base : DictValues } unsigned int subrsOffset; - const CFFSubrs *localSubrs; + const CFF1Subrs *localSubrs; }; -typedef CFFPrivateDictValues_Base CFFPrivateDictValues_Subset; -typedef CFFPrivateDictValues_Base CFFPrivateDictValues; +typedef CFF1PrivateDictValues_Base CFF1PrivateDictValues_Subset; +typedef CFF1PrivateDictValues_Base CFF1PrivateDictValues; -struct CFFPrivateDictOpSet : DictOpSet +struct CFF1PrivateDictOpSet : DictOpSet { - static inline bool process_op (OpCode op, InterpEnv& env, CFFPrivateDictValues& dictval) + static inline bool process_op (OpCode op, InterpEnv& env, CFF1PrivateDictValues& dictval) { DictVal val; val.init (); @@ -622,9 +622,9 @@ struct CFFPrivateDictOpSet : DictOpSet } }; -struct CFFPrivateDictOpSet_Subset : DictOpSet +struct CFF1PrivateDictOpSet_Subset : DictOpSet { - static inline bool process_op (OpCode op, InterpEnv& env, CFFPrivateDictValues_Subset& dictval) + static inline bool process_op (OpCode op, InterpEnv& env, CFF1PrivateDictValues_Subset& dictval) { switch (op) { case OpCode_BlueValues: @@ -665,13 +665,13 @@ struct CFFPrivateDictOpSet_Subset : DictOpSet } }; -typedef DictInterpreter CFFTopDict_Interpreter; -typedef DictInterpreter CFFFontDict_Interpreter; -typedef DictInterpreter CFFPrivateDict_Interpreter; +typedef DictInterpreter CFF1TopDict_Interpreter; +typedef DictInterpreter CFF1FontDict_Interpreter; +typedef DictInterpreter CFF1PrivateDict_Interpreter; -typedef CFFIndex NameIndex; -typedef CFFIndexOf TopDictIndex; -typedef CFFIndex StringIndex; +typedef CFF1Index CFF1NameIndex; +typedef CFF1IndexOf CFF1TopDictIndex; +typedef CFF1Index CFF1StringIndex; }; /* namespace CFF */ @@ -713,17 +713,17 @@ struct cff { fini (); return; } nameIndex = &cff->nameIndex (cff); - if ((nameIndex == &Null (NameIndex)) || !nameIndex->sanitize (&sc)) + if ((nameIndex == &Null (CFF1NameIndex)) || !nameIndex->sanitize (&sc)) { fini (); return; } - topDictIndex = &StructAtOffset (nameIndex, nameIndex->get_size ()); - if ((topDictIndex == &Null (TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0)) + topDictIndex = &StructAtOffset (nameIndex, nameIndex->get_size ()); + if ((topDictIndex == &Null (CFF1TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0)) { fini (); return; } { /* parse top dict */ const ByteStr topDictStr = (*topDictIndex)[0]; if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } - CFFTopDict_Interpreter top_interp; + CFF1TopDict_Interpreter top_interp; top_interp.env.init (topDictStr); if (unlikely (!top_interp.interpret (topDicts[0]))) { fini (); return; } } @@ -734,20 +734,20 @@ struct cff fdCount = 1; if (is_CID ()) { - fdArray = &StructAtOffsetOrNull (cff, topDicts[0].FDArrayOffset); - fdSelect = &StructAtOffsetOrNull (cff, topDicts[0].FDSelectOffset); - if (unlikely ((fdArray == &Null(CFFFDArray)) || !fdArray->sanitize (&sc) || - (fdSelect == &Null(CFFFDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) + fdArray = &StructAtOffsetOrNull (cff, topDicts[0].FDArrayOffset); + fdSelect = &StructAtOffsetOrNull (cff, topDicts[0].FDSelectOffset); + if (unlikely ((fdArray == &Null(CFF1FDArray)) || !fdArray->sanitize (&sc) || + (fdSelect == &Null(CFF1FDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) { fini (); return; } fdCount = fdArray->count; } else { - fdArray = &Null(CFFFDArray); - fdSelect = &Null(CFFFDSelect); - if (topDicts[0].EncodingOffset != CFFTopDictValues::StandardEncoding && - topDicts[0].EncodingOffset != CFFTopDictValues::ExpertEncoding) + fdArray = &Null(CFF1FDArray); + fdSelect = &Null(CFF1FDSelect); + if (topDicts[0].EncodingOffset != CFF1TopDictValues::StandardEncoding && + topDicts[0].EncodingOffset != CFF1TopDictValues::ExpertEncoding) { encoding = &StructAtOffsetOrNull (cff, topDicts[0].EncodingOffset); if ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc)) @@ -755,17 +755,17 @@ struct cff } } - stringIndex = &StructAtOffset (topDictIndex, topDictIndex->get_size ()); - if ((stringIndex == &Null (StringIndex)) || !stringIndex->sanitize (&sc)) + stringIndex = &StructAtOffset (topDictIndex, topDictIndex->get_size ()); + if ((stringIndex == &Null (CFF1StringIndex)) || !stringIndex->sanitize (&sc)) { fini (); return; } - globalSubrs = &StructAtOffset (stringIndex, stringIndex->get_size ()); - if ((globalSubrs != &Null (CFFSubrs)) && !stringIndex->sanitize (&sc)) + globalSubrs = &StructAtOffset (stringIndex, stringIndex->get_size ()); + if ((globalSubrs != &Null (CFF1Subrs)) && !stringIndex->sanitize (&sc)) { fini (); return; } - charStrings = &StructAtOffsetOrNull (cff, topDicts[0].charStringsOffset); + charStrings = &StructAtOffsetOrNull (cff, topDicts[0].charStringsOffset); - if ((charStrings == &Null(CFFCharStrings)) || unlikely (!charStrings->sanitize (&sc))) + if ((charStrings == &Null(CFF1CharStrings)) || unlikely (!charStrings->sanitize (&sc))) { fini (); return; } num_glyphs = charStrings->count; @@ -783,8 +783,8 @@ struct cff { ByteStr fontDictStr = (*fdArray)[i]; if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } - CFFFontDictValues *font; - CFFFontDict_Interpreter font_interp; + CFF1FontDictValues *font; + CFF1FontDict_Interpreter font_interp; font_interp.env.init (fontDictStr); font = fontDicts.push (); if (unlikely (!font_interp.interpret (*font))) { fini (); return; } @@ -795,15 +795,15 @@ struct cff priv_interp.env.init (privDictStr); if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); - if (priv->localSubrs != &Null(CFFSubrs) && + priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && unlikely (!priv->localSubrs->sanitize (&sc))) { fini (); return; } } } else /* non-CID */ { - CFFTopDictValues *font = &topDicts[0]; + CFF1TopDictValues *font = &topDicts[0]; PrivDictVal *priv = &privateDicts[0]; const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); @@ -812,8 +812,8 @@ struct cff priv_interp.env.init (privDictStr); if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); - if (priv->localSubrs != &Null(CFFSubrs) && + priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && unlikely (!priv->localSubrs->sanitize (&sc))) { fini (); return; } } @@ -848,33 +848,33 @@ struct cff hb_sanitize_context_t sc; public: - const NameIndex *nameIndex; - const TopDictIndex *topDictIndex; - const StringIndex *stringIndex; + const CFF1NameIndex *nameIndex; + const CFF1TopDictIndex *topDictIndex; + const CFF1StringIndex *stringIndex; const Encoding *encoding; const Charset *charset; - const CFFSubrs *globalSubrs; - const CFFCharStrings *charStrings; - const CFFFDArray *fdArray; - const CFFFDSelect *fdSelect; + const CFF1Subrs *globalSubrs; + const CFF1CharStrings *charStrings; + const CFF1FDArray *fdArray; + const CFF1FDSelect *fdSelect; unsigned int fdCount; - hb_vector_t topDicts; - hb_vector_t fontDicts; + hb_vector_t topDicts; + hb_vector_t fontDicts; hb_vector_t privateDicts; unsigned int num_glyphs; }; - typedef accelerator_templ_t accelerator_t; - typedef accelerator_templ_t accelerator_subset_t; + typedef accelerator_templ_t accelerator_t; + typedef accelerator_templ_t accelerator_subset_t; inline bool subset (hb_subset_plan_t *plan) const { hb_blob_t *cff_prime = nullptr; bool success = true; - if (hb_subset_cff (plan, &cff_prime)) { + if (hb_subset_cff1 (plan, &cff_prime)) { success = success && plan->add_table (HB_OT_TAG_cff, cff_prime); } else { success = false; @@ -886,7 +886,7 @@ struct cff public: FixedVersion version; /* Version of CFF table. set to 0x0100u */ - OffsetTo nameIndex; /* headerSize = Offset to Name INDEX. */ + OffsetTo nameIndex; /* headerSize = Offset to Name INDEX. */ HBUINT8 offSize; /* offset size (unused?) */ public: @@ -895,4 +895,4 @@ struct cff } /* namespace OT */ -#endif /* HB_OT_CFF_TABLE_HH */ +#endif /* HB_OT_CFF1_TABLE_HH */ diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 8c37acda6..01c4b833d 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -33,7 +33,7 @@ #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" -#include "hb-ot-cff-table.hh" +#include "hb-ot-cff1-table.hh" #include "hb-ot-cff2-table.hh" #include "hb-ot-hmtx-table.hh" #include "hb-ot-kern-table.hh" diff --git a/src/hb-subset-cff.cc b/src/hb-subset-cff1.cc similarity index 87% rename from src/hb-subset-cff.cc rename to src/hb-subset-cff1.cc index 3d47e22ed..228687a70 100644 --- a/src/hb-subset-cff.cc +++ b/src/hb-subset-cff1.cc @@ -25,23 +25,23 @@ */ #include "hb-open-type-private.hh" -#include "hb-ot-cff-table.hh" +#include "hb-ot-cff1-table.hh" #include "hb-set.h" -#include "hb-subset-cff.hh" +#include "hb-subset-cff1.hh" #include "hb-subset-plan.hh" #include "hb-subset-cff-common-private.hh" -#include "hb-cff-interp-cs.hh" +#include "hb-cff1-interp-cs.hh" using namespace CFF; -struct CFFSubTableOffsets { - inline CFFSubTableOffsets (void) +struct CFF1SubTableOffsets { + inline CFF1SubTableOffsets (void) { memset (this, 0, sizeof(*this)); localSubrsInfos.init (); } - inline ~CFFSubTableOffsets (void) + inline ~CFF1SubTableOffsets (void) { localSubrsInfos.fini (); } @@ -59,11 +59,11 @@ struct CFFSubTableOffsets { hb_vector_t localSubrsInfos; }; -struct CFFTopDict_OpSerializer : OpSerializer +struct CFF1TopDict_OpSerializer : OpSerializer { inline bool serialize (hb_serialize_context_t *c, const OpStr &opstr, - const CFFSubTableOffsets &offsets) const + const CFF1SubTableOffsets &offsets) const { TRACE_SERIALIZE (this); @@ -122,7 +122,7 @@ struct CFFTopDict_OpSerializer : OpSerializer } }; -struct CFFFontDict_OpSerializer : OpSerializer +struct CFF1FontDict_OpSerializer : OpSerializer { inline bool serialize (hb_serialize_context_t *c, const OpStr &opstr, @@ -165,7 +165,7 @@ struct CFFFontDict_OpSerializer : OpSerializer } }; -struct CFFPrivateDict_OpSerializer : OpSerializer +struct CFF1PrivateDict_OpSerializer : OpSerializer { inline bool serialize (hb_serialize_context_t *c, const OpStr &opstr, @@ -188,9 +188,9 @@ struct CFFPrivateDict_OpSerializer : OpSerializer } }; -struct CFFCSOpSet_SubrSubset : CFFCSOpSet +struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet { - static inline bool process_op (OpCode op, CFFCSInterpEnv &env, SubrRefMapPair& refMapPair) + static inline bool process_op (OpCode op, CFF1CSInterpEnv &env, SubrRefMapPair& refMapPair) { unsigned int subr_num; switch (op) { @@ -209,7 +209,7 @@ struct CFFCSOpSet_SubrSubset : CFFCSOpSet default: break; } - return CFFCSOpSet::process_op (op, env, refMapPair); + return CFF1CSOpSet::process_op (op, env, refMapPair); } }; @@ -255,10 +255,10 @@ struct cff_subset_plan { /* top dict INDEX */ { offsets.topDictInfo.offset = final_size; - CFFTopDict_OpSerializer topSzr; + CFF1TopDict_OpSerializer topSzr; unsigned int topDictSize = TopDict::calculate_serialized_size (acc.topDicts[0], topSzr); offsets.topDictInfo.offSize = calcOffSize(topDictSize); - final_size += CFFIndexOf::calculate_serialized_size (offsets.topDictInfo.offSize, acc.topDicts, topdict_sizes, topSzr); + final_size += CFF1IndexOf::calculate_serialized_size (offsets.topDictInfo.offSize, acc.topDicts, topdict_sizes, topSzr); } /* String INDEX */ @@ -267,7 +267,7 @@ struct cff_subset_plan { /* Subset global & local subrs */ { - SubrSubsetter subsetter(acc, plan->glyphs); + SubrSubsetter subsetter(acc, plan->glyphs); if (!subsetter.collect_refs (subrRefMaps)) return false; @@ -293,7 +293,7 @@ struct cff_subset_plan { final_size += acc.charset->get_size (acc.num_glyphs); /* FDSelect */ - if (acc.fdSelect != &Null(CFFFDSelect)) + if (acc.fdSelect != &Null(CFF1FDSelect)) { offsets.FDSelectInfo.offset = final_size; if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, @@ -312,10 +312,10 @@ struct cff_subset_plan { } /* FDArray (FDIndex) */ - if (acc.fdArray != &Null(CFFFDArray)) { + if (acc.fdArray != &Null(CFF1FDArray)) { offsets.FDArrayInfo.offset = final_size; - CFFFontDict_OpSerializer fontSzr; - final_size += CFFFDArray::calculate_serialized_size(offsets.FDArrayInfo.offSize/*OUT*/, acc.fontDicts, subst_fdcount, fdmap, fontSzr); + CFF1FontDict_OpSerializer fontSzr; + final_size += CFF1FDArray::calculate_serialized_size(offsets.FDArrayInfo.offSize/*OUT*/, acc.fontDicts, subst_fdcount, fdmap, fontSzr); } /* CharStrings */ @@ -329,7 +329,7 @@ struct cff_subset_plan { dataSize += str.len; } offsets.charStringsInfo.offSize = calcOffSize (dataSize + 1); - final_size += CFFCharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize); + final_size += CFF1CharStrings::calculate_serialized_size (offsets.charStringsInfo.offSize, plan->glyphs.len, dataSize); } /* private dicts & local subrs */ @@ -338,7 +338,7 @@ struct cff_subset_plan { { if (!fdmap.excludes (i)) { - CFFPrivateDict_OpSerializer privSzr; + CFF1PrivateDict_OpSerializer privSzr; TableInfo privInfo = { final_size, PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr), 0 }; privateDictInfos.push (privInfo); final_size += privInfo.size + offsets.localSubrsInfos[i].size; @@ -355,7 +355,7 @@ struct cff_subset_plan { unsigned int final_size; hb_vector_t topdict_sizes; - CFFSubTableOffsets offsets; + CFF1SubTableOffsets offsets; unsigned int orig_fdcount; unsigned int subst_fdcount; @@ -373,7 +373,7 @@ struct cff_subset_plan { SubrRefMaps subrRefMaps; }; -static inline bool _write_cff (const cff_subset_plan &plan, +static inline bool _write_cff1 (const cff_subset_plan &plan, const OT::cff::accelerator_subset_t &acc, const hb_vector_t& glyphs, unsigned int dest_sz, @@ -397,7 +397,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, /* name INDEX */ { assert (cff->nameIndex == c.head - c.start); - NameIndex *dest = c.start_embed (); + CFF1NameIndex *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, *acc.nameIndex))) { @@ -409,9 +409,9 @@ static inline bool _write_cff (const cff_subset_plan &plan, /* top dict INDEX */ { assert (plan.offsets.topDictInfo.offset == c.head - c.start); - CFFIndexOf *dest = c.start_embed< CFFIndexOf > (); + CFF1IndexOf *dest = c.start_embed< CFF1IndexOf > (); if (dest == nullptr) return false; - CFFTopDict_OpSerializer topSzr; + CFF1TopDict_OpSerializer topSzr; if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize, acc.topDicts, plan.topdict_sizes, topSzr, plan.offsets))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF top dict"); @@ -422,7 +422,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, /* String INDEX */ { assert (plan.offsets.stringIndexOffset == c.head - c.start); - StringIndex *dest = c.start_embed (); + CFF1StringIndex *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, *acc.stringIndex))) { @@ -434,7 +434,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, /* global subrs */ { assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start); - CFFSubrs *dest = c.start_embed (); + CFF1Subrs *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, *acc.globalSubrs, plan.offsets.globalSubrsInfo.offSize, plan.subrRefMaps.global_map, NULL_SUBR))) { @@ -469,7 +469,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, } /* FDSelect */ - if (acc.fdSelect != &Null(CFFFDSelect)) + if (acc.fdSelect != &Null(CFF1FDSelect)) { assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); @@ -486,7 +486,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, } else { - CFFFDSelect *dest = c.start_embed (); + CFF1FDSelect *dest = c.start_embed (); if (unlikely (!dest->serialize (&c, *acc.fdSelect, acc.num_glyphs))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF FDSelect"); @@ -496,12 +496,12 @@ static inline bool _write_cff (const cff_subset_plan &plan, } /* FDArray (FD Index) */ - if (acc.fdArray != &Null(CFFFDArray)) + if (acc.fdArray != &Null(CFF1FDArray)) { assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); - CFFFDArray *fda = c.start_embed (); + CFF1FDArray *fda = c.start_embed (); if (unlikely (fda == nullptr)) return false; - CFFFontDict_OpSerializer fontSzr; + CFF1FontDict_OpSerializer fontSzr; if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, acc.fontDicts, plan.subst_fdcount, plan.fdmap, fontSzr, plan.privateDictInfos))) @@ -514,7 +514,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, /* CharStrings */ { assert (plan.offsets.charStringsInfo.offset == c.head - c.start); - CFFCharStrings *cs = c.start_embed (); + CFF1CharStrings *cs = c.start_embed (); if (unlikely (cs == nullptr)) return false; if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) { @@ -531,7 +531,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, { PrivateDict *pd = c.start_embed (); if (unlikely (pd == nullptr)) return false; - CFFPrivateDict_OpSerializer privSzr; + CFF1PrivateDict_OpSerializer privSzr; /* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */ if (unlikely (!pd->serialize (&c, acc.privateDicts[i], privSzr, plan.privateDictInfos[plan.fdmap[i]].size))) { @@ -540,8 +540,8 @@ static inline bool _write_cff (const cff_subset_plan &plan, } if (acc.privateDicts[i].subrsOffset != 0) { - CFFSubrs *subrs = c.start_embed (); - if (unlikely (subrs == nullptr) || acc.privateDicts[i].localSubrs == &Null(CFFSubrs)) + CFF1Subrs *subrs = c.start_embed (); + if (unlikely (subrs == nullptr) || acc.privateDicts[i].localSubrs == &Null(CFF1Subrs)) { DEBUG_MSG (SUBSET, nullptr, "CFF subset: local subrs unexpectedly null [%d]", i); return false; @@ -561,7 +561,7 @@ static inline bool _write_cff (const cff_subset_plan &plan, } static bool -_hb_subset_cff (const OT::cff::accelerator_subset_t &acc, +_hb_subset_cff1 (const OT::cff::accelerator_subset_t &acc, const char *data, hb_subset_plan_t *plan, hb_blob_t **prime /* OUT */) @@ -577,7 +577,7 @@ _hb_subset_cff (const OT::cff::accelerator_subset_t &acc, unsigned int cff_prime_size = cff_plan.get_final_size (); char *cff_prime_data = (char *) calloc (1, cff_prime_size); - if (unlikely (!_write_cff (cff_plan, acc, plan->glyphs, + if (unlikely (!_write_cff1 (cff_plan, acc, plan->glyphs, cff_prime_size, cff_prime_data))) { DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff."); free (cff_prime_data); @@ -593,13 +593,13 @@ _hb_subset_cff (const OT::cff::accelerator_subset_t &acc, } /** - * hb_subset_cff: + * hb_subset_cff1: * Subsets the CFF table according to a provided plan. * * Return value: subsetted cff table. **/ bool -hb_subset_cff (hb_subset_plan_t *plan, +hb_subset_cff1 (hb_subset_plan_t *plan, hb_blob_t **prime /* OUT */) { hb_blob_t *cff_blob = hb_sanitize_context_t().reference_table (plan->source); @@ -608,7 +608,7 @@ hb_subset_cff (hb_subset_plan_t *plan, OT::cff::accelerator_subset_t acc; acc.init(plan->source); bool result = likely (acc.is_valid ()) && - _hb_subset_cff (acc, data, plan, prime); + _hb_subset_cff1 (acc, data, plan, prime); hb_blob_destroy (cff_blob); acc.fini (); diff --git a/src/hb-subset-cff.hh b/src/hb-subset-cff1.hh similarity index 91% rename from src/hb-subset-cff.hh rename to src/hb-subset-cff1.hh index 6c9660316..729bc12b0 100644 --- a/src/hb-subset-cff.hh +++ b/src/hb-subset-cff1.hh @@ -24,15 +24,15 @@ * Adobe Author(s): Michiharu Ariza */ -#ifndef HB_SUBSET_CFF_HH -#define HB_SUBSET_CFF_HH +#ifndef HB_SUBSET_CFF1_HH +#define HB_SUBSET_CFF1_HH #include "hb-private.hh" #include "hb-subset-plan.hh" HB_INTERNAL bool -hb_subset_cff (hb_subset_plan_t *plan, +hb_subset_cff1 (hb_subset_plan_t *plan, hb_blob_t **cff_prime /* OUT */); -#endif /* HB_SUBSET_CFF_HH */ +#endif /* HB_SUBSET_CFF1_HH */ diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 0512597fc..98401a431 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -41,7 +41,7 @@ #include "hb-ot-maxp-table.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-post-table.hh" -#include "hb-ot-cff-table.hh" +#include "hb-ot-cff1-table.hh" #include "hb-ot-cff2-table.hh"