From 592f39b3c4ed04a6f6cf129020358e64782c7108 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Nov 2018 22:54:57 -0500 Subject: [PATCH] [CFF] Whitespace --- src/hb-cff-interp-common.hh | 7 +++---- src/hb-cff-interp-cs-common.hh | 6 +++--- src/hb-cff-interp-dict-common.hh | 6 +++--- src/hb-cff2-interp-cs.hh | 2 +- src/hb-ot-cff-common.hh | 12 ++++++------ src/hb-ot-cff1-table.hh | 30 +++++++++++++++--------------- src/hb-ot-cff2-table.hh | 12 ++++++------ src/hb-subset-cff-common.cc | 8 ++++---- src/hb-subset-cff-common.hh | 34 +++++++++++++++++----------------- src/hb-subset-cff1.cc | 20 ++++++++++---------- src/hb-subset-cff2.cc | 18 +++++++++--------- 11 files changed, 77 insertions(+), 78 deletions(-) diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 0997a3a..6bcb145 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -350,10 +350,10 @@ struct UnsizedByteStr : UnsizedArrayOf return_trace (true); } - + inline static bool serialize_int4 (hb_serialize_context_t *c, int value) { return serialize_int (c, OpCode_longintdict, value); } - + inline static bool serialize_int2 (hb_serialize_context_t *c, int value) { return serialize_int (c, OpCode_shortint, value); } @@ -591,7 +591,6 @@ struct ArgStack : Stack inline unsigned int pop_uint (void) { - int i = pop_int (); 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.substr.inc (); break; - + case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108)); diff --git a/src/hb-cff-interp-cs-common.hh b/src/hb-cff-interp-cs-common.hh index 4402539..941f1d4 100644 --- a/src/hb-cff-interp-cs-common.hh +++ b/src/hb-cff-interp-cs-common.hh @@ -237,7 +237,7 @@ template { static inline void process_op (OpCode op, ENV &env, PARAM& param) - { + { switch (op) { case OpCode_return: @@ -480,7 +480,7 @@ struct PathProcs PATH::line (env, param, pt1); } } - + static inline void hlineto (ENV &env, PARAM& param) { Point pt1; @@ -879,7 +879,7 @@ struct CSInterpreter : Interpreter if (SUPER::env.is_endchar ()) break; } - + return true; } diff --git a/src/hb-cff-interp-dict-common.hh b/src/hb-cff-interp-dict-common.hh index b3245d8..9bb278b 100644 --- a/src/hb-cff-interp-dict-common.hh +++ b/src/hb-cff-interp-dict-common.hh @@ -175,7 +175,7 @@ struct DictOpSet : OpSet case EXP_NEG: exp_neg = true; HB_FALLTHROUGH; - + case EXP_POS: if (part == EXP_PART) { @@ -191,7 +191,7 @@ struct DictOpSet : OpSet case INT_PART: int_part = (int_part * 10) + d; break; - + case FRAC_PART: frac_part = (frac_part * 10) + d; frac_count++; @@ -268,7 +268,7 @@ struct DictInterpreter : Interpreter if (unlikely (SUPER::env.in_error ())) return false; } - + return true; } diff --git a/src/hb-cff2-interp-cs.hh b/src/hb-cff2-interp-cs.hh index 3bc2720..99b34d3 100644 --- a/src/hb-cff2-interp-cs.hh +++ b/src/hb-cff2-interp-cs.hh @@ -83,7 +83,7 @@ struct CFF2CSInterpEnv : CSInterpEnv const int *coords_=nullptr, unsigned int num_coords_=0) { SUPER::init (str, *acc.globalSubrs, *acc.privateDicts[fd].localSubrs); - + coords = coords_; num_coords = num_coords_; varStore = acc.varStore; diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 0022160..3f5a85a 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -137,7 +137,7 @@ struct CFFIndex this->offSize.set (offSize_); if (!unlikely (c->allocate_size (offSize_ * (byteArray.len + 1)))) return_trace (false); - + /* serialize indices */ unsigned int offset = 1; unsigned int i = 0; @@ -276,7 +276,7 @@ struct CFFIndexOf : CFFIndex this->offSize.set (offSize_); if (!unlikely (c->allocate_size (offSize_ * (dataArrayLen + 1)))) return_trace (false); - + /* serialize indices */ unsigned int offset = 1; unsigned int i = 0; @@ -481,7 +481,7 @@ struct FDArray : CFFIndexOf this->offSize.set (offSize_); if (!unlikely (c->allocate_size (offSize_ * (fontDicts.len + 1)))) return_trace (false); - + /* serialize font dict offsets */ unsigned int offset = 1; unsigned int fid = 0; @@ -501,7 +501,7 @@ struct FDArray : CFFIndexOf } return_trace (true); } - + /* used by CFF2 */ template inline bool serialize (hb_serialize_context_t *c, @@ -518,7 +518,7 @@ struct FDArray : CFFIndexOf this->offSize.set (offSize_); if (!unlikely (c->allocate_size (offSize_ * (fdCount + 1)))) return_trace (false); - + /* serialize font dict offsets */ unsigned int offset = 1; unsigned int fid = 0; @@ -540,7 +540,7 @@ struct FDArray : CFFIndexOf } return_trace (true); } - + /* in parallel to above */ template inline static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, diff --git a/src/hb-ot-cff1-table.hh b/src/hb-ot-cff1-table.hh index 902d972..cd36941 100644 --- a/src/hb-ot-cff1-table.hh +++ b/src/hb-ot-cff1-table.hh @@ -388,7 +388,7 @@ struct Charset1_2 { return (hb_codepoint_t)ranges[i].first + glyph; glyph -= (ranges[i].nLeft + 1); } - + return 0; } @@ -402,7 +402,7 @@ struct Charset1_2 { return glyph + (sid - ranges[i].first); glyph += (ranges[i].nLeft + 1); } - + return 0; } @@ -410,7 +410,7 @@ struct Charset1_2 { { unsigned int size = HBUINT8::static_size; int glyph = (int)num_glyphs; - + assert (glyph > 0); glyph--; for (unsigned int i = 0; glyph > 0; i++) @@ -577,7 +577,7 @@ struct CFF1StringIndex : CFF1Index count.set (0); return_trace (true); } - + ByteStrArray bytesArray; bytesArray.init (); if (!bytesArray.resize (sidmap.get_count ())) @@ -593,7 +593,7 @@ struct CFF1StringIndex : CFF1Index bytesArray.fini (); return_trace (result); } - + /* in parallel to above */ inline unsigned int calculate_serialized_size (unsigned int &offSize /*OUT*/, const Remap &sidmap) const { @@ -754,7 +754,7 @@ struct CFF1TopDictOpSet : TopDictOpSet case OpCode_BaseFontBlend: env.clear_args (); break; - + case OpCode_CIDCount: dictval.cidCount = env.argStack.pop_uint (); env.clear_args (); @@ -783,13 +783,13 @@ struct CFF1TopDictOpSet : TopDictOpSet dictval.FDSelectOffset = env.argStack.pop_uint (); env.clear_args (); break; - + case OpCode_Private: dictval.privateDictInfo.offset = env.argStack.pop_uint (); dictval.privateDictInfo.size = env.argStack.pop_uint (); env.clear_args (); break; - + default: env.last_offset = env.substr.offset; TopDictOpSet::process_op (op, env, dictval); @@ -840,7 +840,7 @@ struct CFF1FontDictOpSet : DictOpSet dictval.privateDictInfo.size = env.argStack.pop_uint (); env.clear_args (); break; - + default: DictOpSet::process_op (op, env); if (!env.argStack.is_empty ()) return; @@ -1007,13 +1007,13 @@ struct cff1 topDict.init (); fontDicts.init (); privateDicts.init (); - + this->blob = sc.reference_table (face); /* setup for run-time santization */ sc.init (this->blob); sc.start_processing (); - + const OT::cff1 *cff = this->blob->template as (); if (cff == &Null(OT::cff1)) @@ -1035,7 +1035,7 @@ struct cff1 topDict.init (); if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } } - + if (is_predef_charset ()) charset = &Null(Charset); else @@ -1113,7 +1113,7 @@ struct cff1 { CFF1TopDictValues *font = &topDict; PRIVDICTVAL *priv = &privateDicts[0]; - + const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } DictInterpreter priv_interp; @@ -1148,7 +1148,7 @@ struct cff1 hb_codepoint_t sid = lookup_standard_encoding_for_sid (code); if (unlikely (sid == CFF_UNDEF_SID)) return 0; - + if (charset != &Null(Charset)) return charset->get_glyph (sid, num_glyphs); else if ((topDict.CharsetOffset == ISOAdobeCharset) @@ -1190,7 +1190,7 @@ struct cff1 { SUPER::init (face); if (blob == nullptr) return; - + const OT::cff1 *cff = this->blob->as (); encoding = &Null(Encoding); if (is_CID ()) diff --git a/src/hb-ot-cff2-table.hh b/src/hb-ot-cff2-table.hh index 0293621..aa0a0d2 100644 --- a/src/hb-ot-cff2-table.hh +++ b/src/hb-ot-cff2-table.hh @@ -196,7 +196,7 @@ struct CFF2TopDictOpSet : TopDictOpSet<> dictval.FDSelectOffset = env.argStack.pop_uint (); env.clear_args (); break; - + default: SUPER::process_op (op, env, dictval); /* Record this operand below if stack is empty, otherwise done */ @@ -237,7 +237,7 @@ struct CFF2FontDictOpSet : DictOpSet dictval.privateDictInfo.size = env.argStack.pop_uint (); env.clear_args (); break; - + default: SUPER::process_op (op, env); if (!env.argStack.is_empty ()) @@ -437,13 +437,13 @@ struct cff2 topDict.init (); fontDicts.init (); privateDicts.init (); - + this->blob = sc.reference_table (face); /* setup for run-time santization */ sc.init (this->blob); sc.start_processing (); - + const OT::cff2 *cff2 = this->blob->template as (); if (cff2 == &Null(OT::cff2)) @@ -457,13 +457,13 @@ struct cff2 topDict.init (); if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } } - + globalSubrs = &StructAtOffset (cff2, cff2->topDict + cff2->topDictSize); varStore = &StructAtOffsetOrNull (cff2, topDict.vstoreOffset); charStrings = &StructAtOffsetOrNull (cff2, topDict.charStringsOffset); fdArray = &StructAtOffsetOrNull (cff2, topDict.FDArrayOffset); fdSelect = &StructAtOffsetOrNull (cff2, topDict.FDSelectOffset); - + if (((varStore != &Null(CFF2VariationStore)) && unlikely (!varStore->sanitize (&sc))) || (charStrings == &Null(CFF2CharStrings)) || unlikely (!charStrings->sanitize (&sc)) || (fdArray == &Null(CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) || diff --git a/src/hb-subset-cff-common.cc b/src/hb-subset-cff-common.cc index b946cba..0b21009 100644 --- a/src/hb-subset-cff-common.cc +++ b/src/hb-subset-cff-common.cc @@ -71,7 +71,7 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, { hb_codepoint_t fd = src.get_fd (glyphs[i]); set->add (fd); - + if (fd != prev_fd) { num_ranges++; @@ -201,14 +201,14 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, break; } #endif /* CFF_SERIALIZE_FDSELECT_0 */ - + case 3: return serialize_fdselect_3_4 (c, num_glyphs, src, size, fdselect_ranges); - + case 4: return serialize_fdselect_3_4 (c, num_glyphs, @@ -219,6 +219,6 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, default: assert(false); } - + return_trace (true); } diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index d601f27..b4a9bb7 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -127,7 +127,7 @@ struct StrEncoder protected: inline void set_error (void) { error = true; } - + StrBuff &buff; bool error; }; @@ -135,7 +135,7 @@ struct StrEncoder struct CFFSubTableOffsets { inline CFFSubTableOffsets (void) : privateDictsOffset (0) - + { topDictInfo.init (); FDSelectInfo.init (); @@ -321,7 +321,7 @@ struct SubrFlattener } return true; } - + const ACC &acc; const hb_vector_t &glyphs; bool drop_hints; @@ -428,7 +428,7 @@ struct ParsedCStr : ParsedValues unsigned int parsed_len = get_count (); if (likely (parsed_len > 0)) values[parsed_len-1].set_skip (); - + ParsedCSOp val; val.init (subr_num); SUPER::add_op (op, substr, val); @@ -511,12 +511,12 @@ struct SubrSubsetParam { case CSType_CharString: return parsed_charstring; - + case CSType_LocalSubr: if (likely (context.subr_num < parsed_local_subrs->len)) return &(*parsed_local_subrs)[context.subr_num]; break; - + case CSType_GlobalSubr: if (likely (context.subr_num < parsed_global_subrs->len)) return &(*parsed_global_subrs)[context.subr_num]; @@ -558,7 +558,7 @@ struct SubrRemap : Remap if (hb_set_has (closure, old_num)) add (old_num); } - + if (get_count () < 1240) bias = 107; else if (get_count () < 33900) @@ -677,7 +677,7 @@ struct SubrSubsetter hb_codepoint_t glyph = glyphs[i]; const ByteStr str = (*acc.charStrings)[glyph]; unsigned int fd = acc.fdSelect->get_fd (glyph); - + CSInterpreter interp; 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 */ SUBSETTER::finalize_parsed_str (interp.env, param, parsed_charstrings[i]); } - + if (drop_hints) { /* mark hint ops and arguments for drop */ @@ -728,9 +728,9 @@ struct SubrSubsetter collect_subr_refs_in_str (parsed_charstrings[i], param); } } - + remaps.create (closures); - + return true; } @@ -750,7 +750,7 @@ struct SubrSubsetter inline bool encode_subrs (const ParsedCStrs &subrs, const SubrRemap& remap, unsigned int fd, StrBuffArray &buffArray) const { unsigned int count = remap.get_count (); - + if (unlikely (!buffArray.resize (count))) return false; for (unsigned int old_num = 0; old_num < subrs.len; old_num++) @@ -782,12 +782,12 @@ struct SubrSubsetter : seen_moveto (false), ends_in_hint (false), vsindex_dropped (false) {} - + bool seen_moveto; bool ends_in_hint; bool vsindex_dropped; }; - + inline bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos, ParsedCStrs &subrs, unsigned int subr_num, const SubrSubsetParam ¶m, DropHintsParam &drop) @@ -805,7 +805,7 @@ struct SubrSubsetter if (!str.at_end (pos)) drop.ends_in_hint = false; } - + return has_hint; } @@ -823,7 +823,7 @@ struct SubrSubsetter has_hint = drop_hints_in_subr (str, pos, *param.parsed_local_subrs, str.values[pos].subr_num, param, drop); - + break; case OpCode_callgsubr: @@ -942,7 +942,7 @@ struct SubrSubsetter encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num)); encoder.encode_op (OpCode_callsubr); break; - + case OpCode_callgsubr: encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num)); encoder.encode_op (OpCode_callgsubr); diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index 2ffbdc9..dc4d123 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -195,10 +195,10 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer case OpCode_charset: case OpCode_Encoding: return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); - + case OpCode_Private: return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private); - + case OpCode_version: case OpCode_Notice: case OpCode_Copyright: @@ -290,7 +290,7 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet return; } HB_FALLTHROUGH; - + default: SUPER::flush_args_and_op (op, env, param); break; @@ -576,7 +576,7 @@ struct cff_subset_plan { { if (unlikely (!sidmap.reset (acc.stringIndex->count))) return false; - + for (unsigned int i = 0; i < NameDictValues::ValCount; 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++) if (fdmap.includes (i)) (void)sidmap.add (acc.fontDicts[i].fontName); - + return true; } @@ -622,7 +622,7 @@ struct cff_subset_plan { /* CFF header */ final_size += OT::cff1::static_size; - + /* Name INDEX */ offsets.nameIndexOffset = final_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); final_size += offsets.stringIndexInfo.size; } - + if (desubroutinize) { /* Flatten global & local subrs */ @@ -691,7 +691,7 @@ struct cff_subset_plan { flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) return false; - + /* no global/local subroutines */ 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 == c.head - c.start); - + CFF1Subrs *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; 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)) { assert (plan.offsets.FDSelectInfo.offset == c.head - c.start); - + if (unlikely (!hb_serialize_cff_fdselect (&c, glyphs.len, *acc.fdSelect, acc.fdCount, plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, plan.subset_fdselect_ranges))) diff --git a/src/hb-subset-cff2.cc b/src/hb-subset-cff2.cc index 49de995..64c5a24 100644 --- a/src/hb-subset-cff2.cc +++ b/src/hb-subset-cff2.cc @@ -68,7 +68,7 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> { case OpCode_vstore: return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); - + default: return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); } @@ -85,7 +85,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet case OpCode_endchar: /* dummy opcodes in CFF2. ignore */ break; - + case OpCode_hstem: case OpCode_hstemhm: case OpCode_vstem: @@ -98,7 +98,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet return; } HB_FALLTHROUGH; - + default: SUPER::flush_args_and_op (op, env, param); break; @@ -148,7 +148,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet encoder.encode_int (arg.numValues); encoder.encode_op (OpCode_blendcs); } - + static inline void flush_op (OpCode op, CFF2CSInterpEnv &env, FlattenParam& param) { switch (op) @@ -267,7 +267,7 @@ struct cff2_subset_plan { /* CFF2 header */ final_size += OT::cff2::static_size; - + /* top dict */ { CFF2TopDict_OpSerializer topSzr; @@ -282,7 +282,7 @@ struct cff2_subset_plan { flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) return false; - + /* no global/local subroutines */ offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (1, 0, 0); } @@ -353,7 +353,7 @@ struct cff2_subset_plan { subset_fdselect_ranges, fdmap))) return false; - + final_size += offsets.FDSelectInfo.size; } else @@ -467,7 +467,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, return false; } } - + /* variation store */ if (acc.varStore != &Null(CFF2VariationStore)) { @@ -484,7 +484,7 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, if (acc.fdSelect != &Null(CFF2FDSelect)) { 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, plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, plan.subset_fdselect_ranges))) -- 2.7.4