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
This commit is contained in:
Michiharu Ariza 2018-08-16 00:13:09 -07:00
parent 867f68bd8a
commit fdbfa1848b
7 changed files with 139 additions and 139 deletions

View File

@ -26,7 +26,7 @@ HB_BASE_sources = \
hb-ot-color-cbdt-table.hh \ hb-ot-color-cbdt-table.hh \
hb-ot-cmap-table.hh \ hb-ot-cmap-table.hh \
hb-ot-glyf-table.hh \ hb-ot-glyf-table.hh \
hb-ot-cff-table.hh \ hb-ot-cff1-table.hh \
hb-ot-cff2-table.hh \ hb-ot-cff2-table.hh \
hb-ot-hdmx-table.hh \ hb-ot-hdmx-table.hh \
hb-ot-head-table.hh \ hb-ot-head-table.hh \
@ -154,7 +154,7 @@ HB_OT_sources = \
hb-ot-var-mvar-table.hh \ hb-ot-var-mvar-table.hh \
hb-cff-interp-common-private.hh \ hb-cff-interp-common-private.hh \
hb-cff-interp-cs-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 \ hb-cff-interp-dict-common-private.hh \
$(NULL) $(NULL)
@ -215,7 +215,7 @@ HB_SUBSET_sources = \
hb-static.cc \ hb-static.cc \
hb-subset.cc \ hb-subset.cc \
hb-subset-glyf.cc \ hb-subset-glyf.cc \
hb-subset-cff.cc \ hb-subset-cff1.cc \
hb-subset-cff2.cc \ hb-subset-cff2.cc \
hb-subset-cff-common-private.cc \ hb-subset-cff-common-private.cc \
hb-subset-input.cc \ hb-subset-input.cc \
@ -225,7 +225,7 @@ HB_SUBSET_sources = \
HB_SUBSET_headers = \ HB_SUBSET_headers = \
hb-subset.h \ hb-subset.h \
hb-subset-glyf.hh \ hb-subset-glyf.hh \
hb-subset-cff.hh \ hb-subset-cff1.hh \
hb-subset-cff2.hh \ hb-subset-cff2.hh \
hb-subset-cff-common-private.hh \ hb-subset-cff-common-private.hh \
hb-subset-plan.hh \ hb-subset-plan.hh \

View File

@ -23,21 +23,21 @@
* *
* Adobe Author(s): Michiharu Ariza * Adobe Author(s): Michiharu Ariza
*/ */
#ifndef HB_CFF_INTERP_CS_HH #ifndef HB_CFF1_INTERP_CS_HH
#define HB_CFF_INTERP_CS_HH #define HB_CFF1_INTERP_CS_HH
#include "hb-private.hh" #include "hb-private.hh"
#include "hb-cff-interp-cs.hh" #include "hb-cff-interp-cs-common-private.hh"
namespace CFF { namespace CFF {
using namespace OT; using namespace OT;
struct CFFCSInterpEnv : CSInterpEnv<CFFSubrs> struct CFF1CSInterpEnv : CSInterpEnv<CFF1Subrs>
{ {
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<CFFSubrs>::init (str, globalSubrs, localSubrs); CSInterpEnv<CFF1Subrs>::init (str, globalSubrs, localSubrs);
seen_width = false; seen_width = false;
seen_moveto = true; seen_moveto = true;
seen_hintmask = false; seen_hintmask = false;
@ -101,9 +101,9 @@ struct CFFCSInterpEnv : CSInterpEnv<CFFSubrs>
}; };
template <typename PARAM> template <typename PARAM>
struct CFFCSOpSet : CSOpSet<CFFSubrs, PARAM> struct CFF1CSOpSet : CSOpSet<CFF1Subrs, PARAM>
{ {
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; Number n1, n2;
@ -265,7 +265,7 @@ struct CFFCSOpSet : CSOpSet<CFFSubrs, PARAM>
env.clear_stack (); env.clear_stack ();
break; break;
default: default:
typedef CSOpSet<CFFSubrs, PARAM> SUPER; typedef CSOpSet<CFF1Subrs, PARAM> SUPER;
if (unlikely (!SUPER::process_op (op, env, param))) if (unlikely (!SUPER::process_op (op, env, param)))
return false; return false;
env.process_width (); env.process_width ();
@ -276,8 +276,8 @@ struct CFFCSOpSet : CSOpSet<CFFSubrs, PARAM>
}; };
template <typename OPSET, typename PARAM> template <typename OPSET, typename PARAM>
struct CFFCSInterpreter : CSInterpreter<CFFCSInterpEnv, OPSET, PARAM> {}; struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {};
} /* namespace CFF */ } /* namespace CFF */
#endif /* HB_CFF_INTERP_CS_HH */ #endif /* HB_CFF1_INTERP_CS_HH */

View File

@ -24,11 +24,11 @@
* Adobe Author(s): Michiharu Ariza * Adobe Author(s): Michiharu Ariza
*/ */
#ifndef HB_OT_CFF_TABLE_HH #ifndef HB_OT_CFF1_TABLE_HH
#define HB_OT_CFF_TABLE_HH #define HB_OT_CFF1_TABLE_HH
#include "hb-ot-cff-common-private.hh" #include "hb-ot-cff-common-private.hh"
#include "hb-subset-cff.hh" #include "hb-subset-cff1.hh"
namespace CFF { namespace CFF {
@ -38,15 +38,15 @@ namespace CFF {
*/ */
#define HB_OT_TAG_cff HB_TAG('C','F','F',' ') #define HB_OT_TAG_cff HB_TAG('C','F','F',' ')
typedef Index<HBUINT16> CFFIndex; typedef Index<HBUINT16> CFF1Index;
template <typename Type> struct CFFIndexOf : IndexOf<HBUINT16, Type> {}; template <typename Type> struct CFF1IndexOf : IndexOf<HBUINT16, Type> {};
typedef Index<HBUINT16> CFFIndex; typedef Index<HBUINT16> CFF1Index;
typedef CFFIndex CFFCharStrings; typedef CFF1Index CFF1CharStrings;
typedef FDArray<HBUINT16> CFFFDArray; typedef FDArray<HBUINT16> CFF1FDArray;
typedef Subrs<HBUINT16> CFFSubrs; typedef Subrs<HBUINT16> CFF1Subrs;
struct CFFFDSelect : FDSelect {}; struct CFF1FDSelect : FDSelect {};
/* Encoding */ /* Encoding */
struct Encoding0 { struct Encoding0 {
@ -133,7 +133,7 @@ struct EncSupplement {
DEFINE_SIZE_STATIC (3); DEFINE_SIZE_STATIC (3);
}; };
struct CFFSuppEncData { struct CFF1SuppEncData {
inline bool sanitize (hb_sanitize_context_t *c) const inline bool sanitize (hb_sanitize_context_t *c) const
{ {
TRACE_SANITIZE (this); TRACE_SANITIZE (this);
@ -207,12 +207,12 @@ struct Encoding {
return false; return false;
} }
inline const CFFSuppEncData &suppEncData (void) const inline const CFF1SuppEncData &suppEncData (void) const
{ {
if ((format & 0x7F) == 0) if ((format & 0x7F) == 0)
return StructAfter<CFFSuppEncData> (u.format0.codes[u.format0.nCodes-1]); return StructAfter<CFF1SuppEncData> (u.format0.codes[u.format0.nCodes-1]);
else else
return StructAfter<CFFSuppEncData> (u.format1.ranges[u.format1.nRanges-1]); return StructAfter<CFF1SuppEncData> (u.format1.ranges[u.format1.nRanges-1]);
} }
HBUINT8 format; HBUINT8 format;
@ -220,7 +220,7 @@ struct Encoding {
Encoding0 format0; Encoding0 format0;
Encoding1 format1; Encoding1 format1;
} u; } u;
/* CFFSuppEncData suppEncData; */ /* CFF1SuppEncData suppEncData; */
DEFINE_SIZE_MIN (1); DEFINE_SIZE_MIN (1);
}; };
@ -356,7 +356,7 @@ struct Charset {
DEFINE_SIZE_MIN (1); DEFINE_SIZE_MIN (1);
}; };
struct CFFTopDictValues : TopDictValues struct CFF1TopDictValues : TopDictValues
{ {
inline void init (void) inline void init (void)
{ {
@ -407,9 +407,9 @@ struct CFFTopDictValues : TopDictValues
TableInfo privateDictInfo; 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) { switch (op) {
@ -493,7 +493,7 @@ struct CFFTopDictOpSet : TopDictOpSet
} }
}; };
struct CFFFontDictValues : DictValues<OpStr> struct CFF1FontDictValues : DictValues<OpStr>
{ {
inline void init (void) inline void init (void)
{ {
@ -509,9 +509,9 @@ struct CFFFontDictValues : DictValues<OpStr>
TableInfo privateDictInfo; 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) { switch (op) {
case OpCode_FontName: case OpCode_FontName:
@ -540,13 +540,13 @@ struct CFFFontDictOpSet : DictOpSet
}; };
template <typename VAL> template <typename VAL>
struct CFFPrivateDictValues_Base : DictValues<VAL> struct CFF1PrivateDictValues_Base : DictValues<VAL>
{ {
inline void init (void) inline void init (void)
{ {
DictValues<VAL>::init (); DictValues<VAL>::init ();
subrsOffset = 0; subrsOffset = 0;
localSubrs = &Null(CFFSubrs); localSubrs = &Null(CFF1Subrs);
} }
inline void fini (void) inline void fini (void)
@ -566,15 +566,15 @@ struct CFFPrivateDictValues_Base : DictValues<VAL>
} }
unsigned int subrsOffset; unsigned int subrsOffset;
const CFFSubrs *localSubrs; const CFF1Subrs *localSubrs;
}; };
typedef CFFPrivateDictValues_Base<OpStr> CFFPrivateDictValues_Subset; typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset;
typedef CFFPrivateDictValues_Base<DictVal> CFFPrivateDictValues; typedef CFF1PrivateDictValues_Base<DictVal> 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; DictVal val;
val.init (); 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) { switch (op) {
case OpCode_BlueValues: case OpCode_BlueValues:
@ -665,13 +665,13 @@ struct CFFPrivateDictOpSet_Subset : DictOpSet
} }
}; };
typedef DictInterpreter<CFFTopDictOpSet, CFFTopDictValues> CFFTopDict_Interpreter; typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues> CFF1TopDict_Interpreter;
typedef DictInterpreter<CFFFontDictOpSet, CFFFontDictValues> CFFFontDict_Interpreter; typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter;
typedef DictInterpreter<CFFPrivateDictOpSet, CFFPrivateDictValues> CFFPrivateDict_Interpreter; typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_Interpreter;
typedef CFFIndex NameIndex; typedef CFF1Index CFF1NameIndex;
typedef CFFIndexOf<TopDict> TopDictIndex; typedef CFF1IndexOf<TopDict> CFF1TopDictIndex;
typedef CFFIndex StringIndex; typedef CFF1Index CFF1StringIndex;
}; /* namespace CFF */ }; /* namespace CFF */
@ -713,17 +713,17 @@ struct cff
{ fini (); return; } { fini (); return; }
nameIndex = &cff->nameIndex (cff); nameIndex = &cff->nameIndex (cff);
if ((nameIndex == &Null (NameIndex)) || !nameIndex->sanitize (&sc)) if ((nameIndex == &Null (CFF1NameIndex)) || !nameIndex->sanitize (&sc))
{ fini (); return; } { fini (); return; }
topDictIndex = &StructAtOffset<TopDictIndex> (nameIndex, nameIndex->get_size ()); topDictIndex = &StructAtOffset<CFF1TopDictIndex> (nameIndex, nameIndex->get_size ());
if ((topDictIndex == &Null (TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0)) if ((topDictIndex == &Null (CFF1TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0))
{ fini (); return; } { fini (); return; }
{ /* parse top dict */ { /* parse top dict */
const ByteStr topDictStr = (*topDictIndex)[0]; const ByteStr topDictStr = (*topDictIndex)[0];
if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; }
CFFTopDict_Interpreter top_interp; CFF1TopDict_Interpreter top_interp;
top_interp.env.init (topDictStr); top_interp.env.init (topDictStr);
if (unlikely (!top_interp.interpret (topDicts[0]))) { fini (); return; } if (unlikely (!top_interp.interpret (topDicts[0]))) { fini (); return; }
} }
@ -734,20 +734,20 @@ struct cff
fdCount = 1; fdCount = 1;
if (is_CID ()) if (is_CID ())
{ {
fdArray = &StructAtOffsetOrNull<CFFFDArray> (cff, topDicts[0].FDArrayOffset); fdArray = &StructAtOffsetOrNull<CFF1FDArray> (cff, topDicts[0].FDArrayOffset);
fdSelect = &StructAtOffsetOrNull<CFFFDSelect> (cff, topDicts[0].FDSelectOffset); fdSelect = &StructAtOffsetOrNull<CFF1FDSelect> (cff, topDicts[0].FDSelectOffset);
if (unlikely ((fdArray == &Null(CFFFDArray)) || !fdArray->sanitize (&sc) || if (unlikely ((fdArray == &Null(CFF1FDArray)) || !fdArray->sanitize (&sc) ||
(fdSelect == &Null(CFFFDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) (fdSelect == &Null(CFF1FDSelect)) || !fdSelect->sanitize (&sc, fdArray->count)))
{ fini (); return; } { fini (); return; }
fdCount = fdArray->count; fdCount = fdArray->count;
} }
else else
{ {
fdArray = &Null(CFFFDArray); fdArray = &Null(CFF1FDArray);
fdSelect = &Null(CFFFDSelect); fdSelect = &Null(CFF1FDSelect);
if (topDicts[0].EncodingOffset != CFFTopDictValues::StandardEncoding && if (topDicts[0].EncodingOffset != CFF1TopDictValues::StandardEncoding &&
topDicts[0].EncodingOffset != CFFTopDictValues::ExpertEncoding) topDicts[0].EncodingOffset != CFF1TopDictValues::ExpertEncoding)
{ {
encoding = &StructAtOffsetOrNull<Encoding> (cff, topDicts[0].EncodingOffset); encoding = &StructAtOffsetOrNull<Encoding> (cff, topDicts[0].EncodingOffset);
if ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc)) if ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc))
@ -755,17 +755,17 @@ struct cff
} }
} }
stringIndex = &StructAtOffset<StringIndex> (topDictIndex, topDictIndex->get_size ()); stringIndex = &StructAtOffset<CFF1StringIndex> (topDictIndex, topDictIndex->get_size ());
if ((stringIndex == &Null (StringIndex)) || !stringIndex->sanitize (&sc)) if ((stringIndex == &Null (CFF1StringIndex)) || !stringIndex->sanitize (&sc))
{ fini (); return; } { fini (); return; }
globalSubrs = &StructAtOffset<CFFSubrs> (stringIndex, stringIndex->get_size ()); globalSubrs = &StructAtOffset<CFF1Subrs> (stringIndex, stringIndex->get_size ());
if ((globalSubrs != &Null (CFFSubrs)) && !stringIndex->sanitize (&sc)) if ((globalSubrs != &Null (CFF1Subrs)) && !stringIndex->sanitize (&sc))
{ fini (); return; } { fini (); return; }
charStrings = &StructAtOffsetOrNull<CFFCharStrings> (cff, topDicts[0].charStringsOffset); charStrings = &StructAtOffsetOrNull<CFF1CharStrings> (cff, topDicts[0].charStringsOffset);
if ((charStrings == &Null(CFFCharStrings)) || unlikely (!charStrings->sanitize (&sc))) if ((charStrings == &Null(CFF1CharStrings)) || unlikely (!charStrings->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
num_glyphs = charStrings->count; num_glyphs = charStrings->count;
@ -783,8 +783,8 @@ struct cff
{ {
ByteStr fontDictStr = (*fdArray)[i]; ByteStr fontDictStr = (*fdArray)[i];
if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; }
CFFFontDictValues *font; CFF1FontDictValues *font;
CFFFontDict_Interpreter font_interp; CFF1FontDict_Interpreter font_interp;
font_interp.env.init (fontDictStr); font_interp.env.init (fontDictStr);
font = fontDicts.push (); font = fontDicts.push ();
if (unlikely (!font_interp.interpret (*font))) { fini (); return; } if (unlikely (!font_interp.interpret (*font))) { fini (); return; }
@ -795,15 +795,15 @@ struct cff
priv_interp.env.init (privDictStr); priv_interp.env.init (privDictStr);
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFFSubrs> (privDictStr.str, priv->subrsOffset); priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset);
if (priv->localSubrs != &Null(CFFSubrs) && if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc))) unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
} }
} }
else /* non-CID */ else /* non-CID */
{ {
CFFTopDictValues *font = &topDicts[0]; CFF1TopDictValues *font = &topDicts[0];
PrivDictVal *priv = &privateDicts[0]; PrivDictVal *priv = &privateDicts[0];
const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size); const ByteStr privDictStr (StructAtOffset<UnsizedByteStr> (cff, font->privateDictInfo.offset), font->privateDictInfo.size);
@ -812,8 +812,8 @@ struct cff
priv_interp.env.init (privDictStr); priv_interp.env.init (privDictStr);
if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; }
priv->localSubrs = &StructAtOffsetOrNull<CFFSubrs> (privDictStr.str, priv->subrsOffset); priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (privDictStr.str, priv->subrsOffset);
if (priv->localSubrs != &Null(CFFSubrs) && if (priv->localSubrs != &Null(CFF1Subrs) &&
unlikely (!priv->localSubrs->sanitize (&sc))) unlikely (!priv->localSubrs->sanitize (&sc)))
{ fini (); return; } { fini (); return; }
} }
@ -848,33 +848,33 @@ struct cff
hb_sanitize_context_t sc; hb_sanitize_context_t sc;
public: public:
const NameIndex *nameIndex; const CFF1NameIndex *nameIndex;
const TopDictIndex *topDictIndex; const CFF1TopDictIndex *topDictIndex;
const StringIndex *stringIndex; const CFF1StringIndex *stringIndex;
const Encoding *encoding; const Encoding *encoding;
const Charset *charset; const Charset *charset;
const CFFSubrs *globalSubrs; const CFF1Subrs *globalSubrs;
const CFFCharStrings *charStrings; const CFF1CharStrings *charStrings;
const CFFFDArray *fdArray; const CFF1FDArray *fdArray;
const CFFFDSelect *fdSelect; const CFF1FDSelect *fdSelect;
unsigned int fdCount; unsigned int fdCount;
hb_vector_t<CFFTopDictValues> topDicts; hb_vector_t<CFF1TopDictValues> topDicts;
hb_vector_t<CFFFontDictValues> fontDicts; hb_vector_t<CFF1FontDictValues> fontDicts;
hb_vector_t<PrivDictVal> privateDicts; hb_vector_t<PrivDictVal> privateDicts;
unsigned int num_glyphs; unsigned int num_glyphs;
}; };
typedef accelerator_templ_t<CFFPrivateDictOpSet, CFFPrivateDictValues> accelerator_t; typedef accelerator_templ_t<CFF1PrivateDictOpSet, CFF1PrivateDictValues> accelerator_t;
typedef accelerator_templ_t<CFFPrivateDictOpSet_Subset, CFFPrivateDictValues_Subset> accelerator_subset_t; typedef accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> accelerator_subset_t;
inline bool subset (hb_subset_plan_t *plan) const inline bool subset (hb_subset_plan_t *plan) const
{ {
hb_blob_t *cff_prime = nullptr; hb_blob_t *cff_prime = nullptr;
bool success = true; 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); success = success && plan->add_table (HB_OT_TAG_cff, cff_prime);
} else { } else {
success = false; success = false;
@ -886,7 +886,7 @@ struct cff
public: public:
FixedVersion<HBUINT8> version; /* Version of CFF table. set to 0x0100u */ FixedVersion<HBUINT8> version; /* Version of CFF table. set to 0x0100u */
OffsetTo<NameIndex, HBUINT8> nameIndex; /* headerSize = Offset to Name INDEX. */ OffsetTo<CFF1NameIndex, HBUINT8> nameIndex; /* headerSize = Offset to Name INDEX. */
HBUINT8 offSize; /* offset size (unused?) */ HBUINT8 offSize; /* offset size (unused?) */
public: public:
@ -895,4 +895,4 @@ struct cff
} /* namespace OT */ } /* namespace OT */
#endif /* HB_OT_CFF_TABLE_HH */ #endif /* HB_OT_CFF1_TABLE_HH */

View File

@ -33,7 +33,7 @@
#include "hb-ot-cmap-table.hh" #include "hb-ot-cmap-table.hh"
#include "hb-ot-glyf-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-cff2-table.hh"
#include "hb-ot-hmtx-table.hh" #include "hb-ot-hmtx-table.hh"
#include "hb-ot-kern-table.hh" #include "hb-ot-kern-table.hh"

View File

@ -25,23 +25,23 @@
*/ */
#include "hb-open-type-private.hh" #include "hb-open-type-private.hh"
#include "hb-ot-cff-table.hh" #include "hb-ot-cff1-table.hh"
#include "hb-set.h" #include "hb-set.h"
#include "hb-subset-cff.hh" #include "hb-subset-cff1.hh"
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"
#include "hb-subset-cff-common-private.hh" #include "hb-subset-cff-common-private.hh"
#include "hb-cff-interp-cs.hh" #include "hb-cff1-interp-cs.hh"
using namespace CFF; using namespace CFF;
struct CFFSubTableOffsets { struct CFF1SubTableOffsets {
inline CFFSubTableOffsets (void) inline CFF1SubTableOffsets (void)
{ {
memset (this, 0, sizeof(*this)); memset (this, 0, sizeof(*this));
localSubrsInfos.init (); localSubrsInfos.init ();
} }
inline ~CFFSubTableOffsets (void) inline ~CFF1SubTableOffsets (void)
{ {
localSubrsInfos.fini (); localSubrsInfos.fini ();
} }
@ -59,11 +59,11 @@ struct CFFSubTableOffsets {
hb_vector_t<TableInfo> localSubrsInfos; hb_vector_t<TableInfo> localSubrsInfos;
}; };
struct CFFTopDict_OpSerializer : OpSerializer struct CFF1TopDict_OpSerializer : OpSerializer
{ {
inline bool serialize (hb_serialize_context_t *c, inline bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const OpStr &opstr,
const CFFSubTableOffsets &offsets) const const CFF1SubTableOffsets &offsets) const
{ {
TRACE_SERIALIZE (this); 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, inline bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, 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, inline bool serialize (hb_serialize_context_t *c,
const OpStr &opstr, const OpStr &opstr,
@ -188,9 +188,9 @@ struct CFFPrivateDict_OpSerializer : OpSerializer
} }
}; };
struct CFFCSOpSet_SubrSubset : CFFCSOpSet<SubrRefMapPair> struct CFF1CSOpSet_SubrSubset : CFF1CSOpSet<SubrRefMapPair>
{ {
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; unsigned int subr_num;
switch (op) { switch (op) {
@ -209,7 +209,7 @@ struct CFFCSOpSet_SubrSubset : CFFCSOpSet<SubrRefMapPair>
default: default:
break; break;
} }
return CFFCSOpSet<SubrRefMapPair>::process_op (op, env, refMapPair); return CFF1CSOpSet<SubrRefMapPair>::process_op (op, env, refMapPair);
} }
}; };
@ -255,10 +255,10 @@ struct cff_subset_plan {
/* top dict INDEX */ /* top dict INDEX */
{ {
offsets.topDictInfo.offset = final_size; offsets.topDictInfo.offset = final_size;
CFFTopDict_OpSerializer topSzr; CFF1TopDict_OpSerializer topSzr;
unsigned int topDictSize = TopDict::calculate_serialized_size (acc.topDicts[0], topSzr); unsigned int topDictSize = TopDict::calculate_serialized_size (acc.topDicts[0], topSzr);
offsets.topDictInfo.offSize = calcOffSize(topDictSize); offsets.topDictInfo.offSize = calcOffSize(topDictSize);
final_size += CFFIndexOf<TopDict>::calculate_serialized_size<CFFTopDictValues> (offsets.topDictInfo.offSize, acc.topDicts, topdict_sizes, topSzr); final_size += CFF1IndexOf<TopDict>::calculate_serialized_size<CFF1TopDictValues> (offsets.topDictInfo.offSize, acc.topDicts, topdict_sizes, topSzr);
} }
/* String INDEX */ /* String INDEX */
@ -267,7 +267,7 @@ struct cff_subset_plan {
/* Subset global & local subrs */ /* Subset global & local subrs */
{ {
SubrSubsetter<const OT::cff::accelerator_subset_t, CFFCSInterpEnv, CFFCSOpSet_SubrSubset> subsetter(acc, plan->glyphs); SubrSubsetter<const OT::cff::accelerator_subset_t, CFF1CSInterpEnv, CFF1CSOpSet_SubrSubset> subsetter(acc, plan->glyphs);
if (!subsetter.collect_refs (subrRefMaps)) if (!subsetter.collect_refs (subrRefMaps))
return false; return false;
@ -293,7 +293,7 @@ struct cff_subset_plan {
final_size += acc.charset->get_size (acc.num_glyphs); final_size += acc.charset->get_size (acc.num_glyphs);
/* FDSelect */ /* FDSelect */
if (acc.fdSelect != &Null(CFFFDSelect)) if (acc.fdSelect != &Null(CFF1FDSelect))
{ {
offsets.FDSelectInfo.offset = final_size; offsets.FDSelectInfo.offset = final_size;
if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs,
@ -312,10 +312,10 @@ struct cff_subset_plan {
} }
/* FDArray (FDIndex) */ /* FDArray (FDIndex) */
if (acc.fdArray != &Null(CFFFDArray)) { if (acc.fdArray != &Null(CFF1FDArray)) {
offsets.FDArrayInfo.offset = final_size; offsets.FDArrayInfo.offset = final_size;
CFFFontDict_OpSerializer fontSzr; CFF1FontDict_OpSerializer fontSzr;
final_size += CFFFDArray::calculate_serialized_size(offsets.FDArrayInfo.offSize/*OUT*/, acc.fontDicts, subst_fdcount, fdmap, fontSzr); final_size += CFF1FDArray::calculate_serialized_size(offsets.FDArrayInfo.offSize/*OUT*/, acc.fontDicts, subst_fdcount, fdmap, fontSzr);
} }
/* CharStrings */ /* CharStrings */
@ -329,7 +329,7 @@ struct cff_subset_plan {
dataSize += str.len; dataSize += str.len;
} }
offsets.charStringsInfo.offSize = calcOffSize (dataSize + 1); 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 */ /* private dicts & local subrs */
@ -338,7 +338,7 @@ struct cff_subset_plan {
{ {
if (!fdmap.excludes (i)) if (!fdmap.excludes (i))
{ {
CFFPrivateDict_OpSerializer privSzr; CFF1PrivateDict_OpSerializer privSzr;
TableInfo privInfo = { final_size, PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr), 0 }; TableInfo privInfo = { final_size, PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr), 0 };
privateDictInfos.push (privInfo); privateDictInfos.push (privInfo);
final_size += privInfo.size + offsets.localSubrsInfos[i].size; final_size += privInfo.size + offsets.localSubrsInfos[i].size;
@ -355,7 +355,7 @@ struct cff_subset_plan {
unsigned int final_size; unsigned int final_size;
hb_vector_t<unsigned int> topdict_sizes; hb_vector_t<unsigned int> topdict_sizes;
CFFSubTableOffsets offsets; CFF1SubTableOffsets offsets;
unsigned int orig_fdcount; unsigned int orig_fdcount;
unsigned int subst_fdcount; unsigned int subst_fdcount;
@ -373,7 +373,7 @@ struct cff_subset_plan {
SubrRefMaps subrRefMaps; 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 OT::cff::accelerator_subset_t &acc,
const hb_vector_t<hb_codepoint_t>& glyphs, const hb_vector_t<hb_codepoint_t>& glyphs,
unsigned int dest_sz, unsigned int dest_sz,
@ -397,7 +397,7 @@ static inline bool _write_cff (const cff_subset_plan &plan,
/* name INDEX */ /* name INDEX */
{ {
assert (cff->nameIndex == c.head - c.start); assert (cff->nameIndex == c.head - c.start);
NameIndex *dest = c.start_embed<NameIndex> (); CFF1NameIndex *dest = c.start_embed<CFF1NameIndex> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, *acc.nameIndex))) if (unlikely (!dest->serialize (&c, *acc.nameIndex)))
{ {
@ -409,9 +409,9 @@ static inline bool _write_cff (const cff_subset_plan &plan,
/* top dict INDEX */ /* top dict INDEX */
{ {
assert (plan.offsets.topDictInfo.offset == c.head - c.start); assert (plan.offsets.topDictInfo.offset == c.head - c.start);
CFFIndexOf<TopDict> *dest = c.start_embed< CFFIndexOf<TopDict> > (); CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
if (dest == nullptr) return false; 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))) 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"); 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 */ /* String INDEX */
{ {
assert (plan.offsets.stringIndexOffset == c.head - c.start); assert (plan.offsets.stringIndexOffset == c.head - c.start);
StringIndex *dest = c.start_embed<StringIndex> (); CFF1StringIndex *dest = c.start_embed<CFF1StringIndex> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, *acc.stringIndex))) if (unlikely (!dest->serialize (&c, *acc.stringIndex)))
{ {
@ -434,7 +434,7 @@ static inline bool _write_cff (const cff_subset_plan &plan,
/* global subrs */ /* global subrs */
{ {
assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start); assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start);
CFFSubrs *dest = c.start_embed<CFFSubrs> (); CFF1Subrs *dest = c.start_embed<CFF1Subrs> ();
if (unlikely (dest == nullptr)) return false; if (unlikely (dest == nullptr)) return false;
if (unlikely (!dest->serialize (&c, *acc.globalSubrs, plan.offsets.globalSubrsInfo.offSize, plan.subrRefMaps.global_map, NULL_SUBR))) 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 */ /* FDSelect */
if (acc.fdSelect != &Null(CFFFDSelect)) if (acc.fdSelect != &Null(CFF1FDSelect))
{ {
assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); assert (plan.offsets.FDSelectInfo.offset == c.head - c.start);
@ -486,7 +486,7 @@ static inline bool _write_cff (const cff_subset_plan &plan,
} }
else else
{ {
CFFFDSelect *dest = c.start_embed<CFFFDSelect> (); CFF1FDSelect *dest = c.start_embed<CFF1FDSelect> ();
if (unlikely (!dest->serialize (&c, *acc.fdSelect, acc.num_glyphs))) if (unlikely (!dest->serialize (&c, *acc.fdSelect, acc.num_glyphs)))
{ {
DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF FDSelect"); 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) */ /* FDArray (FD Index) */
if (acc.fdArray != &Null(CFFFDArray)) if (acc.fdArray != &Null(CFF1FDArray))
{ {
assert (plan.offsets.FDArrayInfo.offset == c.head - c.start); assert (plan.offsets.FDArrayInfo.offset == c.head - c.start);
CFFFDArray *fda = c.start_embed<CFFFDArray> (); CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
if (unlikely (fda == nullptr)) return false; if (unlikely (fda == nullptr)) return false;
CFFFontDict_OpSerializer fontSzr; CFF1FontDict_OpSerializer fontSzr;
if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize,
acc.fontDicts, plan.subst_fdcount, plan.fdmap, acc.fontDicts, plan.subst_fdcount, plan.fdmap,
fontSzr, plan.privateDictInfos))) fontSzr, plan.privateDictInfos)))
@ -514,7 +514,7 @@ static inline bool _write_cff (const cff_subset_plan &plan,
/* CharStrings */ /* CharStrings */
{ {
assert (plan.offsets.charStringsInfo.offset == c.head - c.start); assert (plan.offsets.charStringsInfo.offset == c.head - c.start);
CFFCharStrings *cs = c.start_embed<CFFCharStrings> (); CFF1CharStrings *cs = c.start_embed<CFF1CharStrings> ();
if (unlikely (cs == nullptr)) return false; if (unlikely (cs == nullptr)) return false;
if (unlikely (!cs->serialize (&c, plan.offsets.charStringsInfo.offSize, plan.subset_charstrings))) 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<PrivateDict> (); PrivateDict *pd = c.start_embed<PrivateDict> ();
if (unlikely (pd == nullptr)) return false; 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 */ /* 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))) 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) if (acc.privateDicts[i].subrsOffset != 0)
{ {
CFFSubrs *subrs = c.start_embed<CFFSubrs> (); CFF1Subrs *subrs = c.start_embed<CFF1Subrs> ();
if (unlikely (subrs == nullptr) || acc.privateDicts[i].localSubrs == &Null(CFFSubrs)) if (unlikely (subrs == nullptr) || acc.privateDicts[i].localSubrs == &Null(CFF1Subrs))
{ {
DEBUG_MSG (SUBSET, nullptr, "CFF subset: local subrs unexpectedly null [%d]", i); DEBUG_MSG (SUBSET, nullptr, "CFF subset: local subrs unexpectedly null [%d]", i);
return false; return false;
@ -561,7 +561,7 @@ static inline bool _write_cff (const cff_subset_plan &plan,
} }
static bool 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, const char *data,
hb_subset_plan_t *plan, hb_subset_plan_t *plan,
hb_blob_t **prime /* OUT */) 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 (); unsigned int cff_prime_size = cff_plan.get_final_size ();
char *cff_prime_data = (char *) calloc (1, cff_prime_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))) { cff_prime_size, cff_prime_data))) {
DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff."); DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff.");
free (cff_prime_data); 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. * Subsets the CFF table according to a provided plan.
* *
* Return value: subsetted cff table. * Return value: subsetted cff table.
**/ **/
bool 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 **prime /* OUT */)
{ {
hb_blob_t *cff_blob = hb_sanitize_context_t().reference_table<CFF::cff> (plan->source); hb_blob_t *cff_blob = hb_sanitize_context_t().reference_table<CFF::cff> (plan->source);
@ -608,7 +608,7 @@ hb_subset_cff (hb_subset_plan_t *plan,
OT::cff::accelerator_subset_t acc; OT::cff::accelerator_subset_t acc;
acc.init(plan->source); acc.init(plan->source);
bool result = likely (acc.is_valid ()) && 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); hb_blob_destroy (cff_blob);
acc.fini (); acc.fini ();

View File

@ -24,15 +24,15 @@
* Adobe Author(s): Michiharu Ariza * Adobe Author(s): Michiharu Ariza
*/ */
#ifndef HB_SUBSET_CFF_HH #ifndef HB_SUBSET_CFF1_HH
#define HB_SUBSET_CFF_HH #define HB_SUBSET_CFF1_HH
#include "hb-private.hh" #include "hb-private.hh"
#include "hb-subset-plan.hh" #include "hb-subset-plan.hh"
HB_INTERNAL bool 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 */); hb_blob_t **cff_prime /* OUT */);
#endif /* HB_SUBSET_CFF_HH */ #endif /* HB_SUBSET_CFF1_HH */

View File

@ -41,7 +41,7 @@
#include "hb-ot-maxp-table.hh" #include "hb-ot-maxp-table.hh"
#include "hb-ot-os2-table.hh" #include "hb-ot-os2-table.hh"
#include "hb-ot-post-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" #include "hb-ot-cff2-table.hh"