[CFF] Whitespace
This commit is contained in:
parent
a2e8d1d455
commit
592f39b3c4
|
@ -350,10 +350,10 @@ struct UnsizedByteStr : UnsizedArrayOf <HBUINT8>
|
||||||
|
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static bool serialize_int4 (hb_serialize_context_t *c, int value)
|
inline static bool serialize_int4 (hb_serialize_context_t *c, int value)
|
||||||
{ return serialize_int<HBUINT32, 0, 0x7FFFFFFF> (c, OpCode_longintdict, value); }
|
{ return serialize_int<HBUINT32, 0, 0x7FFFFFFF> (c, OpCode_longintdict, value); }
|
||||||
|
|
||||||
inline static bool serialize_int2 (hb_serialize_context_t *c, int value)
|
inline static bool serialize_int2 (hb_serialize_context_t *c, int value)
|
||||||
{ return serialize_int<HBUINT16, 0, 0x7FFF> (c, OpCode_shortint, value); }
|
{ return serialize_int<HBUINT16, 0, 0x7FFF> (c, OpCode_shortint, value); }
|
||||||
|
|
||||||
|
@ -591,7 +591,6 @@ struct ArgStack : Stack<ARG, 513>
|
||||||
|
|
||||||
inline unsigned int pop_uint (void)
|
inline unsigned int pop_uint (void)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = pop_int ();
|
int i = pop_int ();
|
||||||
if (unlikely (i < 0))
|
if (unlikely (i < 0))
|
||||||
{
|
{
|
||||||
|
@ -775,7 +774,7 @@ struct OpSet
|
||||||
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108));
|
env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108));
|
||||||
env.substr.inc ();
|
env.substr.inc ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
|
case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1:
|
||||||
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
|
case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3:
|
||||||
env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108));
|
env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108));
|
||||||
|
|
|
@ -237,7 +237,7 @@ template <typename ARG, typename OPSET, typename ENV, typename PARAM, typename P
|
||||||
struct CSOpSet : OpSet<ARG>
|
struct CSOpSet : OpSet<ARG>
|
||||||
{
|
{
|
||||||
static inline void process_op (OpCode op, ENV &env, PARAM& param)
|
static inline void process_op (OpCode op, ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
|
||||||
case OpCode_return:
|
case OpCode_return:
|
||||||
|
@ -480,7 +480,7 @@ struct PathProcs
|
||||||
PATH::line (env, param, pt1);
|
PATH::line (env, param, pt1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void hlineto (ENV &env, PARAM& param)
|
static inline void hlineto (ENV &env, PARAM& param)
|
||||||
{
|
{
|
||||||
Point pt1;
|
Point pt1;
|
||||||
|
@ -879,7 +879,7 @@ struct CSInterpreter : Interpreter<ENV>
|
||||||
if (SUPER::env.is_endchar ())
|
if (SUPER::env.is_endchar ())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ struct DictOpSet : OpSet<Number>
|
||||||
case EXP_NEG:
|
case EXP_NEG:
|
||||||
exp_neg = true;
|
exp_neg = true;
|
||||||
HB_FALLTHROUGH;
|
HB_FALLTHROUGH;
|
||||||
|
|
||||||
case EXP_POS:
|
case EXP_POS:
|
||||||
if (part == EXP_PART)
|
if (part == EXP_PART)
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ struct DictOpSet : OpSet<Number>
|
||||||
case INT_PART:
|
case INT_PART:
|
||||||
int_part = (int_part * 10) + d;
|
int_part = (int_part * 10) + d;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAC_PART:
|
case FRAC_PART:
|
||||||
frac_part = (frac_part * 10) + d;
|
frac_part = (frac_part * 10) + d;
|
||||||
frac_count++;
|
frac_count++;
|
||||||
|
@ -268,7 +268,7 @@ struct DictInterpreter : Interpreter<ENV>
|
||||||
if (unlikely (SUPER::env.in_error ()))
|
if (unlikely (SUPER::env.in_error ()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ struct CFF2CSInterpEnv : CSInterpEnv<BlendArg, CFF2Subrs>
|
||||||
const int *coords_=nullptr, unsigned int num_coords_=0)
|
const int *coords_=nullptr, unsigned int num_coords_=0)
|
||||||
{
|
{
|
||||||
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
|
SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs);
|
||||||
|
|
||||||
coords = coords_;
|
coords = coords_;
|
||||||
num_coords = num_coords_;
|
num_coords = num_coords_;
|
||||||
varStore = acc.varStore;
|
varStore = acc.varStore;
|
||||||
|
|
|
@ -137,7 +137,7 @@ struct CFFIndex
|
||||||
this->offSize.set (offSize_);
|
this->offSize.set (offSize_);
|
||||||
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.len + 1))))
|
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (byteArray.len + 1))))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
/* serialize indices */
|
/* serialize indices */
|
||||||
unsigned int offset = 1;
|
unsigned int offset = 1;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
@ -276,7 +276,7 @@ struct CFFIndexOf : CFFIndex<COUNT>
|
||||||
this->offSize.set (offSize_);
|
this->offSize.set (offSize_);
|
||||||
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (dataArrayLen + 1))))
|
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (dataArrayLen + 1))))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
/* serialize indices */
|
/* serialize indices */
|
||||||
unsigned int offset = 1;
|
unsigned int offset = 1;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
|
@ -481,7 +481,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
this->offSize.set (offSize_);
|
this->offSize.set (offSize_);
|
||||||
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.len + 1))))
|
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fontDicts.len + 1))))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
/* serialize font dict offsets */
|
/* serialize font dict offsets */
|
||||||
unsigned int offset = 1;
|
unsigned int offset = 1;
|
||||||
unsigned int fid = 0;
|
unsigned int fid = 0;
|
||||||
|
@ -501,7 +501,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
}
|
}
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* used by CFF2 */
|
/* used by CFF2 */
|
||||||
template <typename DICTVAL, typename OP_SERIALIZER>
|
template <typename DICTVAL, typename OP_SERIALIZER>
|
||||||
inline bool serialize (hb_serialize_context_t *c,
|
inline bool serialize (hb_serialize_context_t *c,
|
||||||
|
@ -518,7 +518,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
this->offSize.set (offSize_);
|
this->offSize.set (offSize_);
|
||||||
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fdCount + 1))))
|
if (!unlikely (c->allocate_size<HBUINT8> (offSize_ * (fdCount + 1))))
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
/* serialize font dict offsets */
|
/* serialize font dict offsets */
|
||||||
unsigned int offset = 1;
|
unsigned int offset = 1;
|
||||||
unsigned int fid = 0;
|
unsigned int fid = 0;
|
||||||
|
@ -540,7 +540,7 @@ struct FDArray : CFFIndexOf<COUNT, FontDict>
|
||||||
}
|
}
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in parallel to above */
|
/* in parallel to above */
|
||||||
template <typename OP_SERIALIZER, typename DICTVAL>
|
template <typename OP_SERIALIZER, typename DICTVAL>
|
||||||
inline static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
|
inline static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */,
|
||||||
|
|
|
@ -388,7 +388,7 @@ struct Charset1_2 {
|
||||||
return (hb_codepoint_t)ranges[i].first + glyph;
|
return (hb_codepoint_t)ranges[i].first + glyph;
|
||||||
glyph -= (ranges[i].nLeft + 1);
|
glyph -= (ranges[i].nLeft + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ struct Charset1_2 {
|
||||||
return glyph + (sid - ranges[i].first);
|
return glyph + (sid - ranges[i].first);
|
||||||
glyph += (ranges[i].nLeft + 1);
|
glyph += (ranges[i].nLeft + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ struct Charset1_2 {
|
||||||
{
|
{
|
||||||
unsigned int size = HBUINT8::static_size;
|
unsigned int size = HBUINT8::static_size;
|
||||||
int glyph = (int)num_glyphs;
|
int glyph = (int)num_glyphs;
|
||||||
|
|
||||||
assert (glyph > 0);
|
assert (glyph > 0);
|
||||||
glyph--;
|
glyph--;
|
||||||
for (unsigned int i = 0; glyph > 0; i++)
|
for (unsigned int i = 0; glyph > 0; i++)
|
||||||
|
@ -577,7 +577,7 @@ struct CFF1StringIndex : CFF1Index
|
||||||
count.set (0);
|
count.set (0);
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteStrArray bytesArray;
|
ByteStrArray bytesArray;
|
||||||
bytesArray.init ();
|
bytesArray.init ();
|
||||||
if (!bytesArray.resize (sidmap.get_count ()))
|
if (!bytesArray.resize (sidmap.get_count ()))
|
||||||
|
@ -593,7 +593,7 @@ struct CFF1StringIndex : CFF1Index
|
||||||
bytesArray.fini ();
|
bytesArray.fini ();
|
||||||
return_trace (result);
|
return_trace (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* in parallel to above */
|
/* in parallel to above */
|
||||||
inline unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const
|
inline unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const
|
||||||
{
|
{
|
||||||
|
@ -754,7 +754,7 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
case OpCode_BaseFontBlend:
|
case OpCode_BaseFontBlend:
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_CIDCount:
|
case OpCode_CIDCount:
|
||||||
dictval.cidCount = env.argStack.pop_uint ();
|
dictval.cidCount = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
|
@ -783,13 +783,13 @@ struct CFF1TopDictOpSet : TopDictOpSet<CFF1TopDictVal>
|
||||||
dictval.FDSelectOffset = env.argStack.pop_uint ();
|
dictval.FDSelectOffset = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_Private:
|
case OpCode_Private:
|
||||||
dictval.privateDictInfo.offset = env.argStack.pop_uint ();
|
dictval.privateDictInfo.offset = env.argStack.pop_uint ();
|
||||||
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
env.last_offset = env.substr.offset;
|
env.last_offset = env.substr.offset;
|
||||||
TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval);
|
TopDictOpSet<CFF1TopDictVal>::process_op (op, env, dictval);
|
||||||
|
@ -840,7 +840,7 @@ struct CFF1FontDictOpSet : DictOpSet
|
||||||
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DictOpSet::process_op (op, env);
|
DictOpSet::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ()) return;
|
if (!env.argStack.is_empty ()) return;
|
||||||
|
@ -1007,13 +1007,13 @@ struct cff1
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
fontDicts.init ();
|
fontDicts.init ();
|
||||||
privateDicts.init ();
|
privateDicts.init ();
|
||||||
|
|
||||||
this->blob = sc.reference_table<cff1> (face);
|
this->blob = sc.reference_table<cff1> (face);
|
||||||
|
|
||||||
/* setup for run-time santization */
|
/* setup for run-time santization */
|
||||||
sc.init (this->blob);
|
sc.init (this->blob);
|
||||||
sc.start_processing ();
|
sc.start_processing ();
|
||||||
|
|
||||||
const OT::cff1 *cff = this->blob->template as<OT::cff1> ();
|
const OT::cff1 *cff = this->blob->template as<OT::cff1> ();
|
||||||
|
|
||||||
if (cff == &Null(OT::cff1))
|
if (cff == &Null(OT::cff1))
|
||||||
|
@ -1035,7 +1035,7 @@ struct cff1
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_predef_charset ())
|
if (is_predef_charset ())
|
||||||
charset = &Null(Charset);
|
charset = &Null(Charset);
|
||||||
else
|
else
|
||||||
|
@ -1113,7 +1113,7 @@ struct cff1
|
||||||
{
|
{
|
||||||
CFF1TopDictValues *font = &topDict;
|
CFF1TopDictValues *font = &topDict;
|
||||||
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);
|
||||||
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; }
|
||||||
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
DictInterpreter<PRIVOPSET, PRIVDICTVAL> priv_interp;
|
||||||
|
@ -1148,7 +1148,7 @@ struct cff1
|
||||||
hb_codepoint_t sid = lookup_standard_encoding_for_sid (code);
|
hb_codepoint_t sid = lookup_standard_encoding_for_sid (code);
|
||||||
if (unlikely (sid == CFF_UNDEF_SID))
|
if (unlikely (sid == CFF_UNDEF_SID))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (charset != &Null(Charset))
|
if (charset != &Null(Charset))
|
||||||
return charset->get_glyph (sid, num_glyphs);
|
return charset->get_glyph (sid, num_glyphs);
|
||||||
else if ((topDict.CharsetOffset == ISOAdobeCharset)
|
else if ((topDict.CharsetOffset == ISOAdobeCharset)
|
||||||
|
@ -1190,7 +1190,7 @@ struct cff1
|
||||||
{
|
{
|
||||||
SUPER::init (face);
|
SUPER::init (face);
|
||||||
if (blob == nullptr) return;
|
if (blob == nullptr) return;
|
||||||
|
|
||||||
const OT::cff1 *cff = this->blob->as<OT::cff1> ();
|
const OT::cff1 *cff = this->blob->as<OT::cff1> ();
|
||||||
encoding = &Null(Encoding);
|
encoding = &Null(Encoding);
|
||||||
if (is_CID ())
|
if (is_CID ())
|
||||||
|
|
|
@ -196,7 +196,7 @@ struct CFF2TopDictOpSet : TopDictOpSet<>
|
||||||
dictval.FDSelectOffset = env.argStack.pop_uint ();
|
dictval.FDSelectOffset = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SUPER::process_op (op, env, dictval);
|
SUPER::process_op (op, env, dictval);
|
||||||
/* Record this operand below if stack is empty, otherwise done */
|
/* Record this operand below if stack is empty, otherwise done */
|
||||||
|
@ -237,7 +237,7 @@ struct CFF2FontDictOpSet : DictOpSet
|
||||||
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
dictval.privateDictInfo.size = env.argStack.pop_uint ();
|
||||||
env.clear_args ();
|
env.clear_args ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SUPER::process_op (op, env);
|
SUPER::process_op (op, env);
|
||||||
if (!env.argStack.is_empty ())
|
if (!env.argStack.is_empty ())
|
||||||
|
@ -437,13 +437,13 @@ struct cff2
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
fontDicts.init ();
|
fontDicts.init ();
|
||||||
privateDicts.init ();
|
privateDicts.init ();
|
||||||
|
|
||||||
this->blob = sc.reference_table<cff2> (face);
|
this->blob = sc.reference_table<cff2> (face);
|
||||||
|
|
||||||
/* setup for run-time santization */
|
/* setup for run-time santization */
|
||||||
sc.init (this->blob);
|
sc.init (this->blob);
|
||||||
sc.start_processing ();
|
sc.start_processing ();
|
||||||
|
|
||||||
const OT::cff2 *cff2 = this->blob->template as<OT::cff2> ();
|
const OT::cff2 *cff2 = this->blob->template as<OT::cff2> ();
|
||||||
|
|
||||||
if (cff2 == &Null(OT::cff2))
|
if (cff2 == &Null(OT::cff2))
|
||||||
|
@ -457,13 +457,13 @@ struct cff2
|
||||||
topDict.init ();
|
topDict.init ();
|
||||||
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
if (unlikely (!top_interp.interpret (topDict))) { fini (); return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
globalSubrs = &StructAtOffset<CFF2Subrs> (cff2, cff2->topDict + cff2->topDictSize);
|
globalSubrs = &StructAtOffset<CFF2Subrs> (cff2, cff2->topDict + cff2->topDictSize);
|
||||||
varStore = &StructAtOffsetOrNull<CFF2VariationStore> (cff2, topDict.vstoreOffset);
|
varStore = &StructAtOffsetOrNull<CFF2VariationStore> (cff2, topDict.vstoreOffset);
|
||||||
charStrings = &StructAtOffsetOrNull<CFF2CharStrings> (cff2, topDict.charStringsOffset);
|
charStrings = &StructAtOffsetOrNull<CFF2CharStrings> (cff2, topDict.charStringsOffset);
|
||||||
fdArray = &StructAtOffsetOrNull<CFF2FDArray> (cff2, topDict.FDArrayOffset);
|
fdArray = &StructAtOffsetOrNull<CFF2FDArray> (cff2, topDict.FDArrayOffset);
|
||||||
fdSelect = &StructAtOffsetOrNull<CFF2FDSelect> (cff2, topDict.FDSelectOffset);
|
fdSelect = &StructAtOffsetOrNull<CFF2FDSelect> (cff2, topDict.FDSelectOffset);
|
||||||
|
|
||||||
if (((varStore != &Null(CFF2VariationStore)) && unlikely (!varStore->sanitize (&sc))) ||
|
if (((varStore != &Null(CFF2VariationStore)) && unlikely (!varStore->sanitize (&sc))) ||
|
||||||
(charStrings == &Null(CFF2CharStrings)) || unlikely (!charStrings->sanitize (&sc)) ||
|
(charStrings == &Null(CFF2CharStrings)) || unlikely (!charStrings->sanitize (&sc)) ||
|
||||||
(fdArray == &Null(CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) ||
|
(fdArray == &Null(CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) ||
|
||||||
|
|
|
@ -71,7 +71,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t<hb_codepoint_t> &glyphs,
|
||||||
{
|
{
|
||||||
hb_codepoint_t fd = src.get_fd (glyphs[i]);
|
hb_codepoint_t fd = src.get_fd (glyphs[i]);
|
||||||
set->add (fd);
|
set->add (fd);
|
||||||
|
|
||||||
if (fd != prev_fd)
|
if (fd != prev_fd)
|
||||||
{
|
{
|
||||||
num_ranges++;
|
num_ranges++;
|
||||||
|
@ -201,14 +201,14 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* CFF_SERIALIZE_FDSELECT_0 */
|
#endif /* CFF_SERIALIZE_FDSELECT_0 */
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
return serialize_fdselect_3_4<FDSelect3> (c,
|
return serialize_fdselect_3_4<FDSelect3> (c,
|
||||||
num_glyphs,
|
num_glyphs,
|
||||||
src,
|
src,
|
||||||
size,
|
size,
|
||||||
fdselect_ranges);
|
fdselect_ranges);
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return serialize_fdselect_3_4<FDSelect4> (c,
|
return serialize_fdselect_3_4<FDSelect4> (c,
|
||||||
num_glyphs,
|
num_glyphs,
|
||||||
|
@ -219,6 +219,6 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return_trace (true);
|
return_trace (true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ struct StrEncoder
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline void set_error (void) { error = true; }
|
inline void set_error (void) { error = true; }
|
||||||
|
|
||||||
StrBuff &buff;
|
StrBuff &buff;
|
||||||
bool error;
|
bool error;
|
||||||
};
|
};
|
||||||
|
@ -135,7 +135,7 @@ struct StrEncoder
|
||||||
struct CFFSubTableOffsets {
|
struct CFFSubTableOffsets {
|
||||||
inline CFFSubTableOffsets (void)
|
inline CFFSubTableOffsets (void)
|
||||||
: privateDictsOffset (0)
|
: privateDictsOffset (0)
|
||||||
|
|
||||||
{
|
{
|
||||||
topDictInfo.init ();
|
topDictInfo.init ();
|
||||||
FDSelectInfo.init ();
|
FDSelectInfo.init ();
|
||||||
|
@ -321,7 +321,7 @@ struct SubrFlattener
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ACC &acc;
|
const ACC &acc;
|
||||||
const hb_vector_t<hb_codepoint_t> &glyphs;
|
const hb_vector_t<hb_codepoint_t> &glyphs;
|
||||||
bool drop_hints;
|
bool drop_hints;
|
||||||
|
@ -428,7 +428,7 @@ struct ParsedCStr : ParsedValues<ParsedCSOp>
|
||||||
unsigned int parsed_len = get_count ();
|
unsigned int parsed_len = get_count ();
|
||||||
if (likely (parsed_len > 0))
|
if (likely (parsed_len > 0))
|
||||||
values[parsed_len-1].set_skip ();
|
values[parsed_len-1].set_skip ();
|
||||||
|
|
||||||
ParsedCSOp val;
|
ParsedCSOp val;
|
||||||
val.init (subr_num);
|
val.init (subr_num);
|
||||||
SUPER::add_op (op, substr, val);
|
SUPER::add_op (op, substr, val);
|
||||||
|
@ -511,12 +511,12 @@ struct SubrSubsetParam
|
||||||
{
|
{
|
||||||
case CSType_CharString:
|
case CSType_CharString:
|
||||||
return parsed_charstring;
|
return parsed_charstring;
|
||||||
|
|
||||||
case CSType_LocalSubr:
|
case CSType_LocalSubr:
|
||||||
if (likely (context.subr_num < parsed_local_subrs->len))
|
if (likely (context.subr_num < parsed_local_subrs->len))
|
||||||
return &(*parsed_local_subrs)[context.subr_num];
|
return &(*parsed_local_subrs)[context.subr_num];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CSType_GlobalSubr:
|
case CSType_GlobalSubr:
|
||||||
if (likely (context.subr_num < parsed_global_subrs->len))
|
if (likely (context.subr_num < parsed_global_subrs->len))
|
||||||
return &(*parsed_global_subrs)[context.subr_num];
|
return &(*parsed_global_subrs)[context.subr_num];
|
||||||
|
@ -558,7 +558,7 @@ struct SubrRemap : Remap
|
||||||
if (hb_set_has (closure, old_num))
|
if (hb_set_has (closure, old_num))
|
||||||
add (old_num);
|
add (old_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_count () < 1240)
|
if (get_count () < 1240)
|
||||||
bias = 107;
|
bias = 107;
|
||||||
else if (get_count () < 33900)
|
else if (get_count () < 33900)
|
||||||
|
@ -677,7 +677,7 @@ struct SubrSubsetter
|
||||||
hb_codepoint_t glyph = glyphs[i];
|
hb_codepoint_t glyph = glyphs[i];
|
||||||
const ByteStr str = (*acc.charStrings)[glyph];
|
const ByteStr str = (*acc.charStrings)[glyph];
|
||||||
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
unsigned int fd = acc.fdSelect->get_fd (glyph);
|
||||||
|
|
||||||
CSInterpreter<ENV, OPSET, SubrSubsetParam> interp;
|
CSInterpreter<ENV, OPSET, SubrSubsetParam> interp;
|
||||||
interp.env.init (str, acc, fd);
|
interp.env.init (str, acc, fd);
|
||||||
|
|
||||||
|
@ -693,7 +693,7 @@ struct SubrSubsetter
|
||||||
/* finalize parsed string esp. copy CFF1 width or CFF2 vsindex to the parsed charstring for encoding */
|
/* finalize parsed string esp. copy CFF1 width or CFF2 vsindex to the parsed charstring for encoding */
|
||||||
SUBSETTER::finalize_parsed_str (interp.env, param, parsed_charstrings[i]);
|
SUBSETTER::finalize_parsed_str (interp.env, param, parsed_charstrings[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drop_hints)
|
if (drop_hints)
|
||||||
{
|
{
|
||||||
/* mark hint ops and arguments for drop */
|
/* mark hint ops and arguments for drop */
|
||||||
|
@ -728,9 +728,9 @@ struct SubrSubsetter
|
||||||
collect_subr_refs_in_str (parsed_charstrings[i], param);
|
collect_subr_refs_in_str (parsed_charstrings[i], param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remaps.create (closures);
|
remaps.create (closures);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -750,7 +750,7 @@ struct SubrSubsetter
|
||||||
inline bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const
|
inline bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const
|
||||||
{
|
{
|
||||||
unsigned int count = remap.get_count ();
|
unsigned int count = remap.get_count ();
|
||||||
|
|
||||||
if (unlikely (!buffArray.resize (count)))
|
if (unlikely (!buffArray.resize (count)))
|
||||||
return false;
|
return false;
|
||||||
for (unsigned int old_num = 0; old_num < subrs.len; old_num++)
|
for (unsigned int old_num = 0; old_num < subrs.len; old_num++)
|
||||||
|
@ -782,12 +782,12 @@ struct SubrSubsetter
|
||||||
: seen_moveto (false),
|
: seen_moveto (false),
|
||||||
ends_in_hint (false),
|
ends_in_hint (false),
|
||||||
vsindex_dropped (false) {}
|
vsindex_dropped (false) {}
|
||||||
|
|
||||||
bool seen_moveto;
|
bool seen_moveto;
|
||||||
bool ends_in_hint;
|
bool ends_in_hint;
|
||||||
bool vsindex_dropped;
|
bool vsindex_dropped;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos,
|
inline bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos,
|
||||||
ParsedCStrs &subrs, unsigned int subr_num,
|
ParsedCStrs &subrs, unsigned int subr_num,
|
||||||
const SubrSubsetParam ¶m, DropHintsParam &drop)
|
const SubrSubsetParam ¶m, DropHintsParam &drop)
|
||||||
|
@ -805,7 +805,7 @@ struct SubrSubsetter
|
||||||
if (!str.at_end (pos))
|
if (!str.at_end (pos))
|
||||||
drop.ends_in_hint = false;
|
drop.ends_in_hint = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return has_hint;
|
return has_hint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ struct SubrSubsetter
|
||||||
has_hint = drop_hints_in_subr (str, pos,
|
has_hint = drop_hints_in_subr (str, pos,
|
||||||
*param.parsed_local_subrs, str.values[pos].subr_num,
|
*param.parsed_local_subrs, str.values[pos].subr_num,
|
||||||
param, drop);
|
param, drop);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_callgsubr:
|
case OpCode_callgsubr:
|
||||||
|
@ -942,7 +942,7 @@ struct SubrSubsetter
|
||||||
encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num));
|
encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num));
|
||||||
encoder.encode_op (OpCode_callsubr);
|
encoder.encode_op (OpCode_callsubr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_callgsubr:
|
case OpCode_callgsubr:
|
||||||
encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num));
|
encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num));
|
||||||
encoder.encode_op (OpCode_callgsubr);
|
encoder.encode_op (OpCode_callgsubr);
|
||||||
|
|
|
@ -195,10 +195,10 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer<CFF1TopDictVal>
|
||||||
case OpCode_charset:
|
case OpCode_charset:
|
||||||
case OpCode_Encoding:
|
case OpCode_Encoding:
|
||||||
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
|
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op);
|
||||||
|
|
||||||
case OpCode_Private:
|
case OpCode_Private:
|
||||||
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
|
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private);
|
||||||
|
|
||||||
case OpCode_version:
|
case OpCode_version:
|
||||||
case OpCode_Notice:
|
case OpCode_Notice:
|
||||||
case OpCode_Copyright:
|
case OpCode_Copyright:
|
||||||
|
@ -290,7 +290,7 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet<CFF1CSOpSet_Flatten, FlattenParam>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HB_FALLTHROUGH;
|
HB_FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SUPER::flush_args_and_op (op, env, param);
|
SUPER::flush_args_and_op (op, env, param);
|
||||||
break;
|
break;
|
||||||
|
@ -576,7 +576,7 @@ struct cff_subset_plan {
|
||||||
{
|
{
|
||||||
if (unlikely (!sidmap.reset (acc.stringIndex->count)))
|
if (unlikely (!sidmap.reset (acc.stringIndex->count)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < NameDictValues::ValCount; i++)
|
for (unsigned int i = 0; i < NameDictValues::ValCount; i++)
|
||||||
{
|
{
|
||||||
unsigned int sid = acc.topDict.nameSIDs[i];
|
unsigned int sid = acc.topDict.nameSIDs[i];
|
||||||
|
@ -591,7 +591,7 @@ struct cff_subset_plan {
|
||||||
for (unsigned int i = 0; i < orig_fdcount; i++)
|
for (unsigned int i = 0; i < orig_fdcount; i++)
|
||||||
if (fdmap.includes (i))
|
if (fdmap.includes (i))
|
||||||
(void)sidmap.add (acc.fontDicts[i].fontName);
|
(void)sidmap.add (acc.fontDicts[i].fontName);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +622,7 @@ struct cff_subset_plan {
|
||||||
|
|
||||||
/* CFF header */
|
/* CFF header */
|
||||||
final_size += OT::cff1::static_size;
|
final_size += OT::cff1::static_size;
|
||||||
|
|
||||||
/* Name INDEX */
|
/* Name INDEX */
|
||||||
offsets.nameIndexOffset = final_size;
|
offsets.nameIndexOffset = final_size;
|
||||||
final_size += acc.nameIndex->get_size ();
|
final_size += acc.nameIndex->get_size ();
|
||||||
|
@ -683,7 +683,7 @@ struct cff_subset_plan {
|
||||||
offsets.stringIndexInfo.size = acc.stringIndex->calculate_serialized_size (offsets.stringIndexInfo.offSize, sidmap);
|
offsets.stringIndexInfo.size = acc.stringIndex->calculate_serialized_size (offsets.stringIndexInfo.offSize, sidmap);
|
||||||
final_size += offsets.stringIndexInfo.size;
|
final_size += offsets.stringIndexInfo.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desubroutinize)
|
if (desubroutinize)
|
||||||
{
|
{
|
||||||
/* Flatten global & local subrs */
|
/* Flatten global & local subrs */
|
||||||
|
@ -691,7 +691,7 @@ struct cff_subset_plan {
|
||||||
flattener(acc, plan->glyphs, plan->drop_hints);
|
flattener(acc, plan->glyphs, plan->drop_hints);
|
||||||
if (!flattener.flatten (subset_charstrings))
|
if (!flattener.flatten (subset_charstrings))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* no global/local subroutines */
|
/* no global/local subroutines */
|
||||||
offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (1, 0, 0);
|
offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (1, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -926,7 +926,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
{
|
{
|
||||||
assert (plan.offsets.globalSubrsInfo.offset != 0);
|
assert (plan.offsets.globalSubrsInfo.offset != 0);
|
||||||
assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start);
|
assert (plan.offsets.globalSubrsInfo.offset == c.head - c.start);
|
||||||
|
|
||||||
CFF1Subrs *dest = c.start_embed <CFF1Subrs> ();
|
CFF1Subrs *dest = c.start_embed <CFF1Subrs> ();
|
||||||
if (unlikely (dest == nullptr)) return false;
|
if (unlikely (dest == nullptr)) return false;
|
||||||
if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs)))
|
if (unlikely (!dest->serialize (&c, plan.offsets.globalSubrsInfo.offSize, plan.subset_globalsubrs)))
|
||||||
|
@ -973,7 +973,7 @@ static inline bool _write_cff1 (const cff_subset_plan &plan,
|
||||||
if (acc.fdSelect != &Null(CFF1FDSelect))
|
if (acc.fdSelect != &Null(CFF1FDSelect))
|
||||||
{
|
{
|
||||||
assert (plan.offsets.FDSelectInfo.offset == c.head - c.start);
|
assert (plan.offsets.FDSelectInfo.offset == c.head - c.start);
|
||||||
|
|
||||||
if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *acc.fdSelect, acc.fdCount,
|
if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *acc.fdSelect, acc.fdCount,
|
||||||
plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size,
|
plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size,
|
||||||
plan.subset_fdselect_ranges)))
|
plan.subset_fdselect_ranges)))
|
||||||
|
|
|
@ -68,7 +68,7 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<>
|
||||||
{
|
{
|
||||||
case OpCode_vstore:
|
case OpCode_vstore:
|
||||||
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
|
return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr);
|
return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
case OpCode_endchar:
|
case OpCode_endchar:
|
||||||
/* dummy opcodes in CFF2. ignore */
|
/* dummy opcodes in CFF2. ignore */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OpCode_hstem:
|
case OpCode_hstem:
|
||||||
case OpCode_hstemhm:
|
case OpCode_hstemhm:
|
||||||
case OpCode_vstem:
|
case OpCode_vstem:
|
||||||
|
@ -98,7 +98,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HB_FALLTHROUGH;
|
HB_FALLTHROUGH;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SUPER::flush_args_and_op (op, env, param);
|
SUPER::flush_args_and_op (op, env, param);
|
||||||
break;
|
break;
|
||||||
|
@ -148,7 +148,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet<CFF2CSOpSet_Flatten, FlattenParam>
|
||||||
encoder.encode_int (arg.numValues);
|
encoder.encode_int (arg.numValues);
|
||||||
encoder.encode_op (OpCode_blendcs);
|
encoder.encode_op (OpCode_blendcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param)
|
static inline void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param)
|
||||||
{
|
{
|
||||||
switch (op)
|
switch (op)
|
||||||
|
@ -267,7 +267,7 @@ struct cff2_subset_plan {
|
||||||
|
|
||||||
/* CFF2 header */
|
/* CFF2 header */
|
||||||
final_size += OT::cff2::static_size;
|
final_size += OT::cff2::static_size;
|
||||||
|
|
||||||
/* top dict */
|
/* top dict */
|
||||||
{
|
{
|
||||||
CFF2TopDict_OpSerializer topSzr;
|
CFF2TopDict_OpSerializer topSzr;
|
||||||
|
@ -282,7 +282,7 @@ struct cff2_subset_plan {
|
||||||
flattener(acc, plan->glyphs, plan->drop_hints);
|
flattener(acc, plan->glyphs, plan->drop_hints);
|
||||||
if (!flattener.flatten (subset_charstrings))
|
if (!flattener.flatten (subset_charstrings))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* no global/local subroutines */
|
/* no global/local subroutines */
|
||||||
offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (1, 0, 0);
|
offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (1, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ struct cff2_subset_plan {
|
||||||
subset_fdselect_ranges,
|
subset_fdselect_ranges,
|
||||||
fdmap)))
|
fdmap)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
final_size += offsets.FDSelectInfo.size;
|
final_size += offsets.FDSelectInfo.size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -467,7 +467,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* variation store */
|
/* variation store */
|
||||||
if (acc.varStore != &Null(CFF2VariationStore))
|
if (acc.varStore != &Null(CFF2VariationStore))
|
||||||
{
|
{
|
||||||
|
@ -484,7 +484,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan,
|
||||||
if (acc.fdSelect != &Null(CFF2FDSelect))
|
if (acc.fdSelect != &Null(CFF2FDSelect))
|
||||||
{
|
{
|
||||||
assert (plan.offsets.FDSelectInfo.offset == c.head - c.start);
|
assert (plan.offsets.FDSelectInfo.offset == c.head - c.start);
|
||||||
|
|
||||||
if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *(const FDSelect *)acc.fdSelect, acc.fdArray->count,
|
if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *(const FDSelect *)acc.fdSelect, acc.fdArray->count,
|
||||||
plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size,
|
plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size,
|
||||||
plan.subset_fdselect_ranges)))
|
plan.subset_fdselect_ranges)))
|
||||||
|
|
Loading…
Reference in New Issue