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:
parent
867f68bd8a
commit
fdbfa1848b
|
@ -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 \
|
||||
|
|
|
@ -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<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_moveto = true;
|
||||
seen_hintmask = false;
|
||||
|
@ -101,9 +101,9 @@ struct CFFCSInterpEnv : CSInterpEnv<CFFSubrs>
|
|||
};
|
||||
|
||||
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;
|
||||
|
||||
|
@ -265,7 +265,7 @@ struct CFFCSOpSet : CSOpSet<CFFSubrs, PARAM>
|
|||
env.clear_stack ();
|
||||
break;
|
||||
default:
|
||||
typedef CSOpSet<CFFSubrs, PARAM> SUPER;
|
||||
typedef CSOpSet<CFF1Subrs, PARAM> SUPER;
|
||||
if (unlikely (!SUPER::process_op (op, env, param)))
|
||||
return false;
|
||||
env.process_width ();
|
||||
|
@ -276,8 +276,8 @@ struct CFFCSOpSet : CSOpSet<CFFSubrs, PARAM>
|
|||
};
|
||||
|
||||
template <typename OPSET, typename PARAM>
|
||||
struct CFFCSInterpreter : CSInterpreter<CFFCSInterpEnv, OPSET, PARAM> {};
|
||||
struct CFF1CSInterpreter : CSInterpreter<CFF1CSInterpEnv, OPSET, PARAM> {};
|
||||
|
||||
} /* namespace CFF */
|
||||
|
||||
#endif /* HB_CFF_INTERP_CS_HH */
|
||||
#endif /* HB_CFF1_INTERP_CS_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<HBUINT16> CFFIndex;
|
||||
template <typename Type> struct CFFIndexOf : IndexOf<HBUINT16, Type> {};
|
||||
typedef Index<HBUINT16> CFF1Index;
|
||||
template <typename Type> struct CFF1IndexOf : IndexOf<HBUINT16, Type> {};
|
||||
|
||||
typedef Index<HBUINT16> CFFIndex;
|
||||
typedef CFFIndex CFFCharStrings;
|
||||
typedef FDArray<HBUINT16> CFFFDArray;
|
||||
typedef Subrs<HBUINT16> CFFSubrs;
|
||||
typedef Index<HBUINT16> CFF1Index;
|
||||
typedef CFF1Index CFF1CharStrings;
|
||||
typedef FDArray<HBUINT16> CFF1FDArray;
|
||||
typedef Subrs<HBUINT16> 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<CFFSuppEncData> (u.format0.codes[u.format0.nCodes-1]);
|
||||
return StructAfter<CFF1SuppEncData> (u.format0.codes[u.format0.nCodes-1]);
|
||||
else
|
||||
return StructAfter<CFFSuppEncData> (u.format1.ranges[u.format1.nRanges-1]);
|
||||
return StructAfter<CFF1SuppEncData> (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<OpStr>
|
||||
struct CFF1FontDictValues : DictValues<OpStr>
|
||||
{
|
||||
inline void init (void)
|
||||
{
|
||||
|
@ -509,9 +509,9 @@ struct CFFFontDictValues : DictValues<OpStr>
|
|||
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 <typename VAL>
|
||||
struct CFFPrivateDictValues_Base : DictValues<VAL>
|
||||
struct CFF1PrivateDictValues_Base : DictValues<VAL>
|
||||
{
|
||||
inline void init (void)
|
||||
{
|
||||
DictValues<VAL>::init ();
|
||||
subrsOffset = 0;
|
||||
localSubrs = &Null(CFFSubrs);
|
||||
localSubrs = &Null(CFF1Subrs);
|
||||
}
|
||||
|
||||
inline void fini (void)
|
||||
|
@ -566,15 +566,15 @@ struct CFFPrivateDictValues_Base : DictValues<VAL>
|
|||
}
|
||||
|
||||
unsigned int subrsOffset;
|
||||
const CFFSubrs *localSubrs;
|
||||
const CFF1Subrs *localSubrs;
|
||||
};
|
||||
|
||||
typedef CFFPrivateDictValues_Base<OpStr> CFFPrivateDictValues_Subset;
|
||||
typedef CFFPrivateDictValues_Base<DictVal> CFFPrivateDictValues;
|
||||
typedef CFF1PrivateDictValues_Base<OpStr> CFF1PrivateDictValues_Subset;
|
||||
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;
|
||||
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<CFFTopDictOpSet, CFFTopDictValues> CFFTopDict_Interpreter;
|
||||
typedef DictInterpreter<CFFFontDictOpSet, CFFFontDictValues> CFFFontDict_Interpreter;
|
||||
typedef DictInterpreter<CFFPrivateDictOpSet, CFFPrivateDictValues> CFFPrivateDict_Interpreter;
|
||||
typedef DictInterpreter<CFF1TopDictOpSet, CFF1TopDictValues> CFF1TopDict_Interpreter;
|
||||
typedef DictInterpreter<CFF1FontDictOpSet, CFF1FontDictValues> CFF1FontDict_Interpreter;
|
||||
typedef DictInterpreter<CFF1PrivateDictOpSet, CFF1PrivateDictValues> CFF1PrivateDict_Interpreter;
|
||||
|
||||
typedef CFFIndex NameIndex;
|
||||
typedef CFFIndexOf<TopDict> TopDictIndex;
|
||||
typedef CFFIndex StringIndex;
|
||||
typedef CFF1Index CFF1NameIndex;
|
||||
typedef CFF1IndexOf<TopDict> 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<TopDictIndex> (nameIndex, nameIndex->get_size ());
|
||||
if ((topDictIndex == &Null (TopDictIndex)) || !topDictIndex->sanitize (&sc) || (topDictIndex->count == 0))
|
||||
topDictIndex = &StructAtOffset<CFF1TopDictIndex> (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<CFFFDArray> (cff, topDicts[0].FDArrayOffset);
|
||||
fdSelect = &StructAtOffsetOrNull<CFFFDSelect> (cff, topDicts[0].FDSelectOffset);
|
||||
if (unlikely ((fdArray == &Null(CFFFDArray)) || !fdArray->sanitize (&sc) ||
|
||||
(fdSelect == &Null(CFFFDSelect)) || !fdSelect->sanitize (&sc, fdArray->count)))
|
||||
fdArray = &StructAtOffsetOrNull<CFF1FDArray> (cff, topDicts[0].FDArrayOffset);
|
||||
fdSelect = &StructAtOffsetOrNull<CFF1FDSelect> (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<Encoding> (cff, topDicts[0].EncodingOffset);
|
||||
if ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc))
|
||||
|
@ -755,17 +755,17 @@ struct cff
|
|||
}
|
||||
}
|
||||
|
||||
stringIndex = &StructAtOffset<StringIndex> (topDictIndex, topDictIndex->get_size ());
|
||||
if ((stringIndex == &Null (StringIndex)) || !stringIndex->sanitize (&sc))
|
||||
stringIndex = &StructAtOffset<CFF1StringIndex> (topDictIndex, topDictIndex->get_size ());
|
||||
if ((stringIndex == &Null (CFF1StringIndex)) || !stringIndex->sanitize (&sc))
|
||||
{ fini (); return; }
|
||||
|
||||
globalSubrs = &StructAtOffset<CFFSubrs> (stringIndex, stringIndex->get_size ());
|
||||
if ((globalSubrs != &Null (CFFSubrs)) && !stringIndex->sanitize (&sc))
|
||||
globalSubrs = &StructAtOffset<CFF1Subrs> (stringIndex, stringIndex->get_size ());
|
||||
if ((globalSubrs != &Null (CFF1Subrs)) && !stringIndex->sanitize (&sc))
|
||||
{ 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; }
|
||||
|
||||
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<CFFSubrs> (privDictStr.str, priv->subrsOffset);
|
||||
if (priv->localSubrs != &Null(CFFSubrs) &&
|
||||
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (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<UnsizedByteStr> (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<CFFSubrs> (privDictStr.str, priv->subrsOffset);
|
||||
if (priv->localSubrs != &Null(CFFSubrs) &&
|
||||
priv->localSubrs = &StructAtOffsetOrNull<CFF1Subrs> (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<CFFTopDictValues> topDicts;
|
||||
hb_vector_t<CFFFontDictValues> fontDicts;
|
||||
hb_vector_t<CFF1TopDictValues> topDicts;
|
||||
hb_vector_t<CFF1FontDictValues> fontDicts;
|
||||
hb_vector_t<PrivDictVal> privateDicts;
|
||||
|
||||
unsigned int num_glyphs;
|
||||
};
|
||||
|
||||
typedef accelerator_templ_t<CFFPrivateDictOpSet, CFFPrivateDictValues> accelerator_t;
|
||||
typedef accelerator_templ_t<CFFPrivateDictOpSet_Subset, CFFPrivateDictValues_Subset> accelerator_subset_t;
|
||||
typedef accelerator_templ_t<CFF1PrivateDictOpSet, CFF1PrivateDictValues> accelerator_t;
|
||||
typedef accelerator_templ_t<CFF1PrivateDictOpSet_Subset, CFF1PrivateDictValues_Subset> 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<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?) */
|
||||
|
||||
public:
|
||||
|
@ -895,4 +895,4 @@ struct cff
|
|||
|
||||
} /* namespace OT */
|
||||
|
||||
#endif /* HB_OT_CFF_TABLE_HH */
|
||||
#endif /* HB_OT_CFF1_TABLE_HH */
|
|
@ -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"
|
||||
|
|
|
@ -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<TableInfo> 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<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;
|
||||
switch (op) {
|
||||
|
@ -209,7 +209,7 @@ struct CFFCSOpSet_SubrSubset : CFFCSOpSet<SubrRefMapPair>
|
|||
default:
|
||||
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 */
|
||||
{
|
||||
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<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 */
|
||||
|
@ -267,7 +267,7 @@ struct cff_subset_plan {
|
|||
|
||||
/* 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))
|
||||
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<unsigned int> 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<hb_codepoint_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<NameIndex> ();
|
||||
CFF1NameIndex *dest = c.start_embed<CFF1NameIndex> ();
|
||||
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<TopDict> *dest = c.start_embed< CFFIndexOf<TopDict> > ();
|
||||
CFF1IndexOf<TopDict> *dest = c.start_embed< CFF1IndexOf<TopDict> > ();
|
||||
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<StringIndex> ();
|
||||
CFF1StringIndex *dest = c.start_embed<CFF1StringIndex> ();
|
||||
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<CFFSubrs> ();
|
||||
CFF1Subrs *dest = c.start_embed<CFF1Subrs> ();
|
||||
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<CFFFDSelect> ();
|
||||
CFF1FDSelect *dest = c.start_embed<CFF1FDSelect> ();
|
||||
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<CFFFDArray> ();
|
||||
CFF1FDArray *fda = c.start_embed<CFF1FDArray> ();
|
||||
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<CFFCharStrings> ();
|
||||
CFF1CharStrings *cs = c.start_embed<CFF1CharStrings> ();
|
||||
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<PrivateDict> ();
|
||||
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<CFFSubrs> ();
|
||||
if (unlikely (subrs == nullptr) || acc.privateDicts[i].localSubrs == &Null(CFFSubrs))
|
||||
CFF1Subrs *subrs = c.start_embed<CFF1Subrs> ();
|
||||
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<CFF::cff> (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 ();
|
||||
|
|
@ -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 */
|
|
@ -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"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue