From 825df6dbc7fd013c68d7b5672f81e69b69bc14e7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 30 Nov 2018 23:04:59 -0500 Subject: [PATCH] [CFF] Change spaces to tabs --- src/hb-cff-interp-common.hh | 379 +++++++++++++------------- src/hb-cff-interp-cs-common.hh | 316 +++++++++++----------- src/hb-cff-interp-dict-common.hh | 174 ++++++------ src/hb-cff1-interp-cs.hh | 72 ++--- src/hb-cff2-interp-cs.hh | 76 +++--- src/hb-ot-cff-common.hh | 128 ++++----- src/hb-ot-cff1-table.cc | 4 +- src/hb-ot-cff1-table.hh | 450 +++++++++++++++---------------- src/hb-ot-cff2-table.cc | 4 +- src/hb-ot-cff2-table.hh | 212 +++++++-------- src/hb-subset-cff-common.cc | 76 +++--- src/hb-subset-cff-common.hh | 360 ++++++++++++------------- src/hb-subset-cff1.cc | 412 ++++++++++++++-------------- src/hb-subset-cff1.hh | 2 +- src/hb-subset-cff2.cc | 236 ++++++++-------- src/hb-subset-cff2.hh | 2 +- 16 files changed, 1454 insertions(+), 1449 deletions(-) diff --git a/src/hb-cff-interp-common.hh b/src/hb-cff-interp-common.hh index 6bcb145bc..aa2a1b95b 100644 --- a/src/hb-cff-interp-common.hh +++ b/src/hb-cff-interp-common.hh @@ -31,184 +31,189 @@ namespace CFF { using namespace OT; typedef unsigned int OpCode; + + /* === Dict operators === */ /* One byte operators (0-31) */ -#define OpCode_version 0 /* CFF Top */ -#define OpCode_Notice 1 /* CFF Top */ -#define OpCode_FullName 2 /* CFF Top */ -#define OpCode_FamilyName 3 /* CFF Top */ -#define OpCode_Weight 4 /* CFF Top */ -#define OpCode_FontBBox 5 /* CFF Top */ -#define OpCode_BlueValues 6 /* CFF Private, CFF2 Private */ -#define OpCode_OtherBlues 7 /* CFF Private, CFF2 Private */ -#define OpCode_FamilyBlues 8 /* CFF Private, CFF2 Private */ -#define OpCode_FamilyOtherBlues 9 /* CFF Private, CFF2 Private */ -#define OpCode_StdHW 10 /* CFF Private, CFF2 Private */ -#define OpCode_StdVW 11 /* CFF Private, CFF2 Private */ -#define OpCode_escape 12 /* All. Shared with CS */ -#define OpCode_UniqueID 13 /* CFF Top */ -#define OpCode_XUID 14 /* CFF Top */ -#define OpCode_charset 15 /* CFF Top (0) */ -#define OpCode_Encoding 16 /* CFF Top (0) */ -#define OpCode_CharStrings 17 /* CFF Top, CFF2 Top */ -#define OpCode_Private 18 /* CFF Top, CFF2 FD */ -#define OpCode_Subrs 19 /* CFF Private, CFF2 Private */ -#define OpCode_defaultWidthX 20 /* CFF Private (0) */ -#define OpCode_nominalWidthX 21 /* CFF Private (0) */ -#define OpCode_vsindexdict 22 /* CFF2 Private/CS */ -#define OpCode_blenddict 23 /* CFF2 Private/CS */ -#define OpCode_vstore 24 /* CFF2 Top */ -#define OpCode_reserved25 25 -#define OpCode_reserved26 26 -#define OpCode_reserved27 27 +#define OpCode_version 0 /* CFF Top */ +#define OpCode_Notice 1 /* CFF Top */ +#define OpCode_FullName 2 /* CFF Top */ +#define OpCode_FamilyName 3 /* CFF Top */ +#define OpCode_Weight 4 /* CFF Top */ +#define OpCode_FontBBox 5 /* CFF Top */ +#define OpCode_BlueValues 6 /* CFF Private, CFF2 Private */ +#define OpCode_OtherBlues 7 /* CFF Private, CFF2 Private */ +#define OpCode_FamilyBlues 8 /* CFF Private, CFF2 Private */ +#define OpCode_FamilyOtherBlues 9 /* CFF Private, CFF2 Private */ +#define OpCode_StdHW 10 /* CFF Private, CFF2 Private */ +#define OpCode_StdVW 11 /* CFF Private, CFF2 Private */ +#define OpCode_escape 12 /* All. Shared with CS */ +#define OpCode_UniqueID 13 /* CFF Top */ +#define OpCode_XUID 14 /* CFF Top */ +#define OpCode_charset 15 /* CFF Top (0) */ +#define OpCode_Encoding 16 /* CFF Top (0) */ +#define OpCode_CharStrings 17 /* CFF Top, CFF2 Top */ +#define OpCode_Private 18 /* CFF Top, CFF2 FD */ +#define OpCode_Subrs 19 /* CFF Private, CFF2 Private */ +#define OpCode_defaultWidthX 20 /* CFF Private (0) */ +#define OpCode_nominalWidthX 21 /* CFF Private (0) */ +#define OpCode_vsindexdict 22 /* CFF2 Private/CS */ +#define OpCode_blenddict 23 /* CFF2 Private/CS */ +#define OpCode_vstore 24 /* CFF2 Top */ +#define OpCode_reserved25 25 +#define OpCode_reserved26 26 +#define OpCode_reserved27 27 /* Numbers */ -#define OpCode_shortint 28 /* 16-bit integer, All */ -#define OpCode_longintdict 29 /* 32-bit integer, All */ -#define OpCode_BCD 30 /* real number, CFF2 Top/FD */ -#define OpCode_reserved31 31 +#define OpCode_shortint 28 /* 16-bit integer, All */ +#define OpCode_longintdict 29 /* 32-bit integer, All */ +#define OpCode_BCD 30 /* Real number, CFF2 Top/FD */ +#define OpCode_reserved31 31 /* 1-byte integers */ -#define OpCode_OneByteIntFirst 32 /* All. beginning of the range of first byte ints */ -#define OpCode_OneByteIntLast 246 /* All. ending of the range of first byte int */ +#define OpCode_OneByteIntFirst 32 /* All. beginning of the range of first byte ints */ +#define OpCode_OneByteIntLast 246 /* All. ending of the range of first byte int */ /* 2-byte integers */ -#define OpCode_TwoBytePosInt0 247 /* All. first byte of two byte positive int (+108 to +1131) */ -#define OpCode_TwoBytePosInt1 248 -#define OpCode_TwoBytePosInt2 249 -#define OpCode_TwoBytePosInt3 250 +#define OpCode_TwoBytePosInt0 247 /* All. first byte of two byte positive int (+108 to +1131) */ +#define OpCode_TwoBytePosInt1 248 +#define OpCode_TwoBytePosInt2 249 +#define OpCode_TwoBytePosInt3 250 -#define OpCode_TwoByteNegInt0 251 /* All. first byte of two byte negative int (-1131 to -108) */ -#define OpCode_TwoByteNegInt1 252 -#define OpCode_TwoByteNegInt2 253 -#define OpCode_TwoByteNegInt3 254 +#define OpCode_TwoByteNegInt0 251 /* All. first byte of two byte negative int (-1131 to -108) */ +#define OpCode_TwoByteNegInt1 252 +#define OpCode_TwoByteNegInt2 253 +#define OpCode_TwoByteNegInt3 254 /* Two byte escape operators 12, (0-41) */ -#define OpCode_ESC_Base 256 -#define Make_OpCode_ESC(byte2) ((OpCode)(OpCode_ESC_Base + (byte2))) +#define OpCode_ESC_Base 256 +#define Make_OpCode_ESC(byte2) ((OpCode)(OpCode_ESC_Base + (byte2))) inline OpCode Unmake_OpCode_ESC (OpCode op) { return (OpCode)(op - OpCode_ESC_Base); } inline bool Is_OpCode_ESC (OpCode op) { return op >= OpCode_ESC_Base; } -inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op)? 2: 1; } +inline unsigned int OpCode_Size (OpCode op) { return Is_OpCode_ESC (op) ? 2: 1; } -#define OpCode_Copyright Make_OpCode_ESC(0) /* CFF Top */ -#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */ -#define OpCode_ItalicAngle Make_OpCode_ESC(2) /* CFF Top (0) */ -#define OpCode_UnderlinePosition Make_OpCode_ESC(3) /* CFF Top (-100) */ -#define OpCode_UnderlineThickness Make_OpCode_ESC(4) /* CFF Top (50) */ -#define OpCode_PaintType Make_OpCode_ESC(5) /* CFF Top (0) */ -#define OpCode_CharstringType Make_OpCode_ESC(6) /* CFF Top (2) */ -#define OpCode_FontMatrix Make_OpCode_ESC(7) /* CFF Top, CFF2 Top (.001 0 0 .001 0 0)*/ -#define OpCode_StrokeWidth Make_OpCode_ESC(8) /* CFF Top (0) */ -#define OpCode_BlueScale Make_OpCode_ESC(9) /* CFF Private, CFF2 Private (0.039625) */ -#define OpCode_BlueShift Make_OpCode_ESC(10) /* CFF Private, CFF2 Private (7) */ -#define OpCode_BlueFuzz Make_OpCode_ESC(11) /* CFF Private, CFF2 Private (1) */ -#define OpCode_StemSnapH Make_OpCode_ESC(12) /* CFF Private, CFF2 Private */ -#define OpCode_StemSnapV Make_OpCode_ESC(13) /* CFF Private, CFF2 Private */ -#define OpCode_ForceBold Make_OpCode_ESC(14) /* CFF Private (false) */ -#define OpCode_reservedESC15 Make_OpCode_ESC(15) -#define OpCode_reservedESC16 Make_OpCode_ESC(16) -#define OpCode_LanguageGroup Make_OpCode_ESC(17) /* CFF Private, CFF2 Private (0) */ -#define OpCode_ExpansionFactor Make_OpCode_ESC(18) /* CFF Private, CFF2 Private (0.06) */ -#define OpCode_initialRandomSeed Make_OpCode_ESC(19) /* CFF Private (0) */ -#define OpCode_SyntheticBase Make_OpCode_ESC(20) /* CFF Top */ -#define OpCode_PostScript Make_OpCode_ESC(21) /* CFF Top */ -#define OpCode_BaseFontName Make_OpCode_ESC(22) /* CFF Top */ -#define OpCode_BaseFontBlend Make_OpCode_ESC(23) /* CFF Top */ -#define OpCode_reservedESC24 Make_OpCode_ESC(24) -#define OpCode_reservedESC25 Make_OpCode_ESC(25) -#define OpCode_reservedESC26 Make_OpCode_ESC(26) -#define OpCode_reservedESC27 Make_OpCode_ESC(27) -#define OpCode_reservedESC28 Make_OpCode_ESC(28) -#define OpCode_reservedESC29 Make_OpCode_ESC(29) -#define OpCode_ROS Make_OpCode_ESC(30) /* CFF Top_CID */ -#define OpCode_CIDFontVersion Make_OpCode_ESC(31) /* CFF Top_CID (0) */ -#define OpCode_CIDFontRevision Make_OpCode_ESC(32) /* CFF Top_CID (0) */ -#define OpCode_CIDFontType Make_OpCode_ESC(33) /* CFF Top_CID (0) */ -#define OpCode_CIDCount Make_OpCode_ESC(34) /* CFF Top_CID (8720) */ -#define OpCode_UIDBase Make_OpCode_ESC(35) /* CFF Top_CID */ -#define OpCode_FDArray Make_OpCode_ESC(36) /* CFF Top_CID, CFF2 Top */ -#define OpCode_FDSelect Make_OpCode_ESC(37) /* CFF Top_CID, CFF2 Top */ -#define OpCode_FontName Make_OpCode_ESC(38) /* CFF Top_CID */ +#define OpCode_Copyright Make_OpCode_ESC(0) /* CFF Top */ +#define OpCode_isFixedPitch Make_OpCode_ESC(1) /* CFF Top (false) */ +#define OpCode_ItalicAngle Make_OpCode_ESC(2) /* CFF Top (0) */ +#define OpCode_UnderlinePosition Make_OpCode_ESC(3) /* CFF Top (-100) */ +#define OpCode_UnderlineThickness Make_OpCode_ESC(4) /* CFF Top (50) */ +#define OpCode_PaintType Make_OpCode_ESC(5) /* CFF Top (0) */ +#define OpCode_CharstringType Make_OpCode_ESC(6) /* CFF Top (2) */ +#define OpCode_FontMatrix Make_OpCode_ESC(7) /* CFF Top, CFF2 Top (.001 0 0 .001 0 0)*/ +#define OpCode_StrokeWidth Make_OpCode_ESC(8) /* CFF Top (0) */ +#define OpCode_BlueScale Make_OpCode_ESC(9) /* CFF Private, CFF2 Private (0.039625) */ +#define OpCode_BlueShift Make_OpCode_ESC(10) /* CFF Private, CFF2 Private (7) */ +#define OpCode_BlueFuzz Make_OpCode_ESC(11) /* CFF Private, CFF2 Private (1) */ +#define OpCode_StemSnapH Make_OpCode_ESC(12) /* CFF Private, CFF2 Private */ +#define OpCode_StemSnapV Make_OpCode_ESC(13) /* CFF Private, CFF2 Private */ +#define OpCode_ForceBold Make_OpCode_ESC(14) /* CFF Private (false) */ +#define OpCode_reservedESC15 Make_OpCode_ESC(15) +#define OpCode_reservedESC16 Make_OpCode_ESC(16) +#define OpCode_LanguageGroup Make_OpCode_ESC(17) /* CFF Private, CFF2 Private (0) */ +#define OpCode_ExpansionFactor Make_OpCode_ESC(18) /* CFF Private, CFF2 Private (0.06) */ +#define OpCode_initialRandomSeed Make_OpCode_ESC(19) /* CFF Private (0) */ +#define OpCode_SyntheticBase Make_OpCode_ESC(20) /* CFF Top */ +#define OpCode_PostScript Make_OpCode_ESC(21) /* CFF Top */ +#define OpCode_BaseFontName Make_OpCode_ESC(22) /* CFF Top */ +#define OpCode_BaseFontBlend Make_OpCode_ESC(23) /* CFF Top */ +#define OpCode_reservedESC24 Make_OpCode_ESC(24) +#define OpCode_reservedESC25 Make_OpCode_ESC(25) +#define OpCode_reservedESC26 Make_OpCode_ESC(26) +#define OpCode_reservedESC27 Make_OpCode_ESC(27) +#define OpCode_reservedESC28 Make_OpCode_ESC(28) +#define OpCode_reservedESC29 Make_OpCode_ESC(29) +#define OpCode_ROS Make_OpCode_ESC(30) /* CFF Top_CID */ +#define OpCode_CIDFontVersion Make_OpCode_ESC(31) /* CFF Top_CID (0) */ +#define OpCode_CIDFontRevision Make_OpCode_ESC(32) /* CFF Top_CID (0) */ +#define OpCode_CIDFontType Make_OpCode_ESC(33) /* CFF Top_CID (0) */ +#define OpCode_CIDCount Make_OpCode_ESC(34) /* CFF Top_CID (8720) */ +#define OpCode_UIDBase Make_OpCode_ESC(35) /* CFF Top_CID */ +#define OpCode_FDArray Make_OpCode_ESC(36) /* CFF Top_CID, CFF2 Top */ +#define OpCode_FDSelect Make_OpCode_ESC(37) /* CFF Top_CID, CFF2 Top */ +#define OpCode_FontName Make_OpCode_ESC(38) /* CFF Top_CID */ - /* === CharString operators === */ -#define OpCode_hstem 1 /* CFF, CFF2 */ -#define OpCode_Reserved2 2 -#define OpCode_vstem 3 /* CFF, CFF2 */ -#define OpCode_vmoveto 4 /* CFF, CFF2 */ -#define OpCode_rlineto 5 /* CFF, CFF2 */ -#define OpCode_hlineto 6 /* CFF, CFF2 */ -#define OpCode_vlineto 7 /* CFF, CFF2 */ -#define OpCode_rrcurveto 8 /* CFF, CFF2 */ -#define OpCode_Reserved9 9 -#define OpCode_callsubr 10 /* CFF, CFF2 */ -#define OpCode_return 11 /* CFF */ -// #define OpCode_escape 12 /* CFF, CFF2 */ -#define OpCode_Reserved13 13 -#define OpCode_endchar 14 /* CFF */ -#define OpCode_vsindexcs 15 /* CFF2 */ -#define OpCode_blendcs 16 /* CFF2 */ -#define OpCode_Reserved17 17 -#define OpCode_hstemhm 18 /* CFF, CFF2 */ -#define OpCode_hintmask 19 /* CFF, CFF2 */ -#define OpCode_cntrmask 20 /* CFF, CFF2 */ -#define OpCode_rmoveto 21 /* CFF, CFF2 */ -#define OpCode_hmoveto 22 /* CFF, CFF2 */ -#define OpCode_vstemhm 23 /* CFF, CFF2 */ -#define OpCode_rcurveline 24 /* CFF, CFF2 */ -#define OpCode_rlinecurve 25 /* CFF, CFF2 */ -#define OpCode_vvcurveto 26 /* CFF, CFF2 */ -#define OpCode_hhcurveto 27 /* CFF, CFF2 */ -// #define OpCode_shortint 28 /* CFF, CFF2 */ -#define OpCode_callgsubr 29 /* CFF, CFF2 */ -#define OpCode_vhcurveto 30 /* CFF, CFF2 */ -#define OpCode_hvcurveto 31 /* CFF, CFF2 */ +/* === CharString operators === */ -#define OpCode_fixedcs 255 /* 32-bit fixed */ +#define OpCode_hstem 1 /* CFF, CFF2 */ +#define OpCode_Reserved2 2 +#define OpCode_vstem 3 /* CFF, CFF2 */ +#define OpCode_vmoveto 4 /* CFF, CFF2 */ +#define OpCode_rlineto 5 /* CFF, CFF2 */ +#define OpCode_hlineto 6 /* CFF, CFF2 */ +#define OpCode_vlineto 7 /* CFF, CFF2 */ +#define OpCode_rrcurveto 8 /* CFF, CFF2 */ +#define OpCode_Reserved9 9 +#define OpCode_callsubr 10 /* CFF, CFF2 */ +#define OpCode_return 11 /* CFF */ +//#define OpCode_escape 12 /* CFF, CFF2 */ +#define OpCode_Reserved13 13 +#define OpCode_endchar 14 /* CFF */ +#define OpCode_vsindexcs 15 /* CFF2 */ +#define OpCode_blendcs 16 /* CFF2 */ +#define OpCode_Reserved17 17 +#define OpCode_hstemhm 18 /* CFF, CFF2 */ +#define OpCode_hintmask 19 /* CFF, CFF2 */ +#define OpCode_cntrmask 20 /* CFF, CFF2 */ +#define OpCode_rmoveto 21 /* CFF, CFF2 */ +#define OpCode_hmoveto 22 /* CFF, CFF2 */ +#define OpCode_vstemhm 23 /* CFF, CFF2 */ +#define OpCode_rcurveline 24 /* CFF, CFF2 */ +#define OpCode_rlinecurve 25 /* CFF, CFF2 */ +#define OpCode_vvcurveto 26 /* CFF, CFF2 */ +#define OpCode_hhcurveto 27 /* CFF, CFF2 */ +//#define OpCode_shortint 28 /* CFF, CFF2 */ +#define OpCode_callgsubr 29 /* CFF, CFF2 */ +#define OpCode_vhcurveto 30 /* CFF, CFF2 */ +#define OpCode_hvcurveto 31 /* CFF, CFF2 */ + +#define OpCode_fixedcs 255 /* 32-bit fixed */ /* Two byte escape operators 12, (0-41) */ -#define OpCode_dotsection Make_OpCode_ESC(0) /* CFF (obsoleted) */ -#define OpCode_ReservedESC1 Make_OpCode_ESC(1) -#define OpCode_ReservedESC2 Make_OpCode_ESC(2) -#define OpCode_and Make_OpCode_ESC(3) /* CFF */ -#define OpCode_or Make_OpCode_ESC(4) /* CFF */ -#define OpCode_not Make_OpCode_ESC(5) /* CFF */ -#define OpCode_ReservedESC6 Make_OpCode_ESC(6) -#define OpCode_ReservedESC7 Make_OpCode_ESC(7) -#define OpCode_ReservedESC8 Make_OpCode_ESC(8) -#define OpCode_abs Make_OpCode_ESC(9) /* CFF */ -#define OpCode_add Make_OpCode_ESC(10) /* CFF */ -#define OpCode_sub Make_OpCode_ESC(11) /* CFF */ -#define OpCode_div Make_OpCode_ESC(12) /* CFF */ -#define OpCode_ReservedESC13 Make_OpCode_ESC(13) -#define OpCode_neg Make_OpCode_ESC(14) /* CFF */ -#define OpCode_eq Make_OpCode_ESC(15) /* CFF */ -#define OpCode_ReservedESC16 Make_OpCode_ESC(16) -#define OpCode_ReservedESC17 Make_OpCode_ESC(17) -#define OpCode_drop Make_OpCode_ESC(18) /* CFF */ -#define OpCode_ReservedESC19 Make_OpCode_ESC(19) -#define OpCode_put Make_OpCode_ESC(20) /* CFF */ -#define OpCode_get Make_OpCode_ESC(21) /* CFF */ -#define OpCode_ifelse Make_OpCode_ESC(22) /* CFF */ -#define OpCode_random Make_OpCode_ESC(23) /* CFF */ -#define OpCode_mul Make_OpCode_ESC(24) /* CFF */ -// #define OpCode_reservedESC25 Make_OpCode_ESC(25) -#define OpCode_sqrt Make_OpCode_ESC(26) /* CFF */ -#define OpCode_dup Make_OpCode_ESC(27) /* CFF */ -#define OpCode_exch Make_OpCode_ESC(28) /* CFF */ -#define OpCode_index Make_OpCode_ESC(29) /* CFF */ -#define OpCode_roll Make_OpCode_ESC(30) /* CFF */ -#define OpCode_reservedESC31 Make_OpCode_ESC(31) -#define OpCode_reservedESC32 Make_OpCode_ESC(32) -#define OpCode_reservedESC33 Make_OpCode_ESC(33) -#define OpCode_hflex Make_OpCode_ESC(34) /* CFF, CFF2 */ -#define OpCode_flex Make_OpCode_ESC(35) /* CFF, CFF2 */ -#define OpCode_hflex1 Make_OpCode_ESC(36) /* CFF, CFF2 */ -#define OpCode_flex1 Make_OpCode_ESC(37) /* CFF, CFF2 */ +#define OpCode_dotsection Make_OpCode_ESC(0) /* CFF (obsoleted) */ +#define OpCode_ReservedESC1 Make_OpCode_ESC(1) +#define OpCode_ReservedESC2 Make_OpCode_ESC(2) +#define OpCode_and Make_OpCode_ESC(3) /* CFF */ +#define OpCode_or Make_OpCode_ESC(4) /* CFF */ +#define OpCode_not Make_OpCode_ESC(5) /* CFF */ +#define OpCode_ReservedESC6 Make_OpCode_ESC(6) +#define OpCode_ReservedESC7 Make_OpCode_ESC(7) +#define OpCode_ReservedESC8 Make_OpCode_ESC(8) +#define OpCode_abs Make_OpCode_ESC(9) /* CFF */ +#define OpCode_add Make_OpCode_ESC(10) /* CFF */ +#define OpCode_sub Make_OpCode_ESC(11) /* CFF */ +#define OpCode_div Make_OpCode_ESC(12) /* CFF */ +#define OpCode_ReservedESC13 Make_OpCode_ESC(13) +#define OpCode_neg Make_OpCode_ESC(14) /* CFF */ +#define OpCode_eq Make_OpCode_ESC(15) /* CFF */ +#define OpCode_ReservedESC16 Make_OpCode_ESC(16) +#define OpCode_ReservedESC17 Make_OpCode_ESC(17) +#define OpCode_drop Make_OpCode_ESC(18) /* CFF */ +#define OpCode_ReservedESC19 Make_OpCode_ESC(19) +#define OpCode_put Make_OpCode_ESC(20) /* CFF */ +#define OpCode_get Make_OpCode_ESC(21) /* CFF */ +#define OpCode_ifelse Make_OpCode_ESC(22) /* CFF */ +#define OpCode_random Make_OpCode_ESC(23) /* CFF */ +#define OpCode_mul Make_OpCode_ESC(24) /* CFF */ +//#define OpCode_reservedESC25 Make_OpCode_ESC(25) +#define OpCode_sqrt Make_OpCode_ESC(26) /* CFF */ +#define OpCode_dup Make_OpCode_ESC(27) /* CFF */ +#define OpCode_exch Make_OpCode_ESC(28) /* CFF */ +#define OpCode_index Make_OpCode_ESC(29) /* CFF */ +#define OpCode_roll Make_OpCode_ESC(30) /* CFF */ +#define OpCode_reservedESC31 Make_OpCode_ESC(31) +#define OpCode_reservedESC32 Make_OpCode_ESC(32) +#define OpCode_reservedESC33 Make_OpCode_ESC(33) +#define OpCode_hflex Make_OpCode_ESC(34) /* CFF, CFF2 */ +#define OpCode_flex Make_OpCode_ESC(35) /* CFF, CFF2 */ +#define OpCode_hflex1 Make_OpCode_ESC(36) /* CFF, CFF2 */ +#define OpCode_flex1 Make_OpCode_ESC(37) /* CFF, CFF2 */ + + +#define OpCode_Invalid 0xFFFFu -#define OpCode_Invalid 65535 struct Number { @@ -217,8 +222,8 @@ struct Number inline void fini (void) {} - inline void set_int (int v) { format = NumInt; u.int_val = v; } - inline int to_int (void) const { return is_int ()? u.int_val: (int)to_real (); } + inline void set_int (int v) { format = NumInt; u.int_val = v; } + inline int to_int (void) const { return is_int ()? u.int_val: (int)to_real (); } inline void set_fixed (int32_t v) { format = NumFixed; u.fixed_val = v; } inline int32_t to_fixed (void) const { @@ -229,7 +234,7 @@ struct Number else return (int32_t)(u.int_val << 16); } - inline void set_real (float v) { format = NumReal; u.real_val = v; } + inline void set_real (float v) { format = NumReal; u.real_val = v; } inline float to_real (void) const { if (is_real ()) @@ -246,11 +251,11 @@ struct Number { default: case NumInt: - return u.int_val; + return u.int_val; case NumFixed: - return (u.fixed_val + 0xFFFF) >> 16; + return (u.fixed_val + 0xFFFF) >> 16; case NumReal: - return (int)ceilf (u.real_val); + return (int)ceilf (u.real_val); } } @@ -260,11 +265,11 @@ struct Number { default: case NumInt: - return u.int_val; + return u.int_val; case NumFixed: - return u.fixed_val >> 16; + return u.fixed_val >> 16; case NumReal: - return (int)floorf (u.real_val); + return (int)floorf (u.real_val); } } @@ -454,7 +459,7 @@ struct SubByteStr unsigned int offset; /* beginning of the sub-string within str */ protected: - bool error; + bool error; }; typedef hb_vector_t ByteStrArray; @@ -721,7 +726,7 @@ struct InterpEnv op = (OpCode)(unsigned char)substr[0]; if (op == OpCode_escape) { if (unlikely (!substr.avail ())) - return OpCode_Invalid; + return OpCode_Invalid; op = Make_OpCode_ESC(substr[1]); substr.inc (); } @@ -753,7 +758,7 @@ struct InterpEnv SubByteStr substr; ArgStack argStack; protected: - bool error; + bool error; }; typedef InterpEnv<> NumInterpEnv; @@ -765,33 +770,33 @@ struct OpSet { switch (op) { case OpCode_shortint: - env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1])); - env.substr.inc (2); - break; + env.argStack.push_int ((int16_t)((env.substr[0] << 8) | env.substr[1])); + env.substr.inc (2); + break; case OpCode_TwoBytePosInt0: case OpCode_TwoBytePosInt1: case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: - env.argStack.push_int ((int16_t)((op - OpCode_TwoBytePosInt0) * 256 + env.substr[0] + 108)); - env.substr.inc (); - break; + 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)); - env.substr.inc (); - break; + env.argStack.push_int ((int16_t)(-(op - OpCode_TwoByteNegInt0) * 256 - env.substr[0] - 108)); + env.substr.inc (); + break; default: - /* 1-byte integer */ - if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast))) - { - env.argStack.push_int ((int)op - 139); - } else { - /* invalid unknown operator */ - env.clear_args (); - env.set_error (); - } - break; + /* 1-byte integer */ + if (likely ((OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast))) + { + env.argStack.push_int ((int)op - 139); + } else { + /* invalid unknown operator */ + env.clear_args (); + env.set_error (); + } + break; } } }; diff --git a/src/hb-cff-interp-cs-common.hh b/src/hb-cff-interp-cs-common.hh index 941f1d4bd..85546fccc 100644 --- a/src/hb-cff-interp-cs-common.hh +++ b/src/hb-cff-interp-cs-common.hh @@ -51,7 +51,7 @@ struct CallContext inline void fini (void) {} SubByteStr substr; - CSType type; + CSType type; unsigned int subr_num; }; @@ -150,7 +150,7 @@ struct CSInterpEnv : InterpEnv unsigned int subr_num; if (unlikely (!popSubrNum (biasedSubrs, subr_num) - || callStack.get_count () >= kMaxCallLimit)) + || callStack.get_count () >= kMaxCallLimit)) { SUPER::set_error (); return; @@ -191,19 +191,19 @@ struct CSInterpEnv : InterpEnv public: CallContext context; - bool endchar_flag; - bool seen_moveto; - bool seen_hintmask; + bool endchar_flag; + bool seen_moveto; + bool seen_hintmask; unsigned int hstem_count; unsigned int vstem_count; unsigned int hintmask_size; - CallStack callStack; + CallStack callStack; BiasedSubrs globalSubrs; BiasedSubrs localSubrs; private: - Point pt; + Point pt; typedef InterpEnv SUPER; }; @@ -241,120 +241,120 @@ struct CSOpSet : OpSet switch (op) { case OpCode_return: - env.returnFromSubr (); - break; + env.returnFromSubr (); + break; case OpCode_endchar: - OPSET::check_width (op, env, param); - env.set_endchar (true); - OPSET::flush_args_and_op (op, env, param); - break; + OPSET::check_width (op, env, param); + env.set_endchar (true); + OPSET::flush_args_and_op (op, env, param); + break; case OpCode_fixedcs: - env.argStack.push_fixed_from_substr (env.substr); - break; + env.argStack.push_fixed_from_substr (env.substr); + break; case OpCode_callsubr: - env.callSubr (env.localSubrs, CSType_LocalSubr); - break; + env.callSubr (env.localSubrs, CSType_LocalSubr); + break; case OpCode_callgsubr: - env.callSubr (env.globalSubrs, CSType_GlobalSubr); - break; + env.callSubr (env.globalSubrs, CSType_GlobalSubr); + break; case OpCode_hstem: case OpCode_hstemhm: - OPSET::check_width (op, env, param); - OPSET::process_hstem (op, env, param); - break; + OPSET::check_width (op, env, param); + OPSET::process_hstem (op, env, param); + break; case OpCode_vstem: case OpCode_vstemhm: - OPSET::check_width (op, env, param); - OPSET::process_vstem (op, env, param); - break; + OPSET::check_width (op, env, param); + OPSET::process_vstem (op, env, param); + break; case OpCode_hintmask: case OpCode_cntrmask: - OPSET::check_width (op, env, param); - OPSET::process_hintmask (op, env, param); - break; + OPSET::check_width (op, env, param); + OPSET::process_hintmask (op, env, param); + break; case OpCode_rmoveto: - OPSET::check_width (op, env, param); - PATH::rmoveto (env, param); - OPSET::process_post_move (op, env, param); - break; + OPSET::check_width (op, env, param); + PATH::rmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; case OpCode_hmoveto: - OPSET::check_width (op, env, param); - PATH::hmoveto (env, param); - OPSET::process_post_move (op, env, param); - break; + OPSET::check_width (op, env, param); + PATH::hmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; case OpCode_vmoveto: - OPSET::check_width (op, env, param); - PATH::vmoveto (env, param); - OPSET::process_post_move (op, env, param); - break; + OPSET::check_width (op, env, param); + PATH::vmoveto (env, param); + OPSET::process_post_move (op, env, param); + break; case OpCode_rlineto: - PATH::rlineto (env, param); - process_post_path (op, env, param); - break; + PATH::rlineto (env, param); + process_post_path (op, env, param); + break; case OpCode_hlineto: - PATH::hlineto (env, param); - process_post_path (op, env, param); - break; + PATH::hlineto (env, param); + process_post_path (op, env, param); + break; case OpCode_vlineto: - PATH::vlineto (env, param); - process_post_path (op, env, param); - break; + PATH::vlineto (env, param); + process_post_path (op, env, param); + break; case OpCode_rrcurveto: - PATH::rrcurveto (env, param); - process_post_path (op, env, param); - break; + PATH::rrcurveto (env, param); + process_post_path (op, env, param); + break; case OpCode_rcurveline: - PATH::rcurveline (env, param); - process_post_path (op, env, param); - break; + PATH::rcurveline (env, param); + process_post_path (op, env, param); + break; case OpCode_rlinecurve: - PATH::rlinecurve (env, param); - process_post_path (op, env, param); - break; + PATH::rlinecurve (env, param); + process_post_path (op, env, param); + break; case OpCode_vvcurveto: - PATH::vvcurveto (env, param); - process_post_path (op, env, param); - break; + PATH::vvcurveto (env, param); + process_post_path (op, env, param); + break; case OpCode_hhcurveto: - PATH::hhcurveto (env, param); - process_post_path (op, env, param); - break; + PATH::hhcurveto (env, param); + process_post_path (op, env, param); + break; case OpCode_vhcurveto: - PATH::vhcurveto (env, param); - process_post_path (op, env, param); - break; + PATH::vhcurveto (env, param); + process_post_path (op, env, param); + break; case OpCode_hvcurveto: - PATH::hvcurveto (env, param); - process_post_path (op, env, param); - break; + PATH::hvcurveto (env, param); + process_post_path (op, env, param); + break; case OpCode_hflex: - PATH::hflex (env, param); - OPSET::process_post_flex (op, env, param); - break; + PATH::hflex (env, param); + OPSET::process_post_flex (op, env, param); + break; case OpCode_flex: - PATH::flex (env, param); - OPSET::process_post_flex (op, env, param); - break; + PATH::flex (env, param); + OPSET::process_post_flex (op, env, param); + break; case OpCode_hflex1: - PATH::hflex1 (env, param); - OPSET::process_post_flex (op, env, param); - break; + PATH::hflex1 (env, param); + OPSET::process_post_flex (op, env, param); + break; case OpCode_flex1: - PATH::flex1 (env, param); - OPSET::process_post_flex (op, env, param); - break; + PATH::flex1 (env, param); + OPSET::process_post_flex (op, env, param); + break; default: - SUPER::process_op (op, env); - break; + SUPER::process_op (op, env); + break; } } @@ -433,11 +433,11 @@ struct CSOpSet : OpSet case OpCode_TwoBytePosInt2: case OpCode_TwoBytePosInt3: case OpCode_TwoByteNegInt0: case OpCode_TwoByteNegInt1: case OpCode_TwoByteNegInt2: case OpCode_TwoByteNegInt3: - return true; + return true; default: - /* 1-byte integer */ - return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast); + /* 1-byte integer */ + return (OpCode_OneByteIntFirst <= op) && (op <= OpCode_OneByteIntLast); } } @@ -630,47 +630,47 @@ struct PathProcs for (; i + 8 <= env.argStack.get_count (); i += 8) { - PATH::curve (env, param, pt1, pt2, pt3); - pt1 = env.get_pt (); - pt1.move_x (env.eval_arg (i)); - pt2 = pt1; - pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - pt3 = pt2; - pt3.move_y (env.eval_arg (i+3)); - PATH::curve (env, param, pt1, pt2, pt3); + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); - pt1 = pt3; - pt1.move_y (env.eval_arg (i+4)); - pt2 = pt1; - pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); - pt3 = pt2; - pt3.move_x (env.eval_arg (i+7)); + pt1 = pt3; + pt1.move_y (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+7)); } if (i < env.argStack.get_count ()) - pt3.move_y (env.eval_arg (i)); + pt3.move_y (env.eval_arg (i)); PATH::curve (env, param, pt1, pt2, pt3); } else { for (; i + 8 <= env.argStack.get_count (); i += 8) { - pt1 = env.get_pt (); - pt1.move_y (env.eval_arg (i)); - pt2 = pt1; - pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - pt3 = pt2; - pt3.move_x (env.eval_arg (i+3)); - PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); - pt1 = pt3; - pt1.move_x (env.eval_arg (i+4)); - pt2 = pt1; - pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); - pt3 = pt2; - pt3.move_y (env.eval_arg (i+7)); - if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) - pt3.move_x (env.eval_arg (i+8)); - PATH::curve (env, param, pt1, pt2, pt3); + pt1 = pt3; + pt1.move_x (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+7)); + if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) + pt3.move_x (env.eval_arg (i+8)); + PATH::curve (env, param, pt1, pt2, pt3); } } } @@ -691,47 +691,47 @@ struct PathProcs for (; i + 8 <= env.argStack.get_count (); i += 8) { - PATH::curve (env, param, pt1, pt2, pt3); - pt1 = env.get_pt (); - pt1.move_y (env.eval_arg (i)); - pt2 = pt1; - pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - pt3 = pt2; - pt3.move_x (env.eval_arg (i+3)); - PATH::curve (env, param, pt1, pt2, pt3); + PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_y (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); - pt1 = pt3; - pt1.move_x (env.eval_arg (i+4)); - pt2 = pt1; - pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); - pt3 = pt2; - pt3.move_y (env.eval_arg (i+7)); + pt1 = pt3; + pt1.move_x (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+7)); } if (i < env.argStack.get_count ()) - pt3.move_x (env.eval_arg (i)); + pt3.move_x (env.eval_arg (i)); PATH::curve (env, param, pt1, pt2, pt3); } else { for (; i + 8 <= env.argStack.get_count (); i += 8) { - pt1 = env.get_pt (); - pt1.move_x (env.eval_arg (i)); - pt2 = pt1; - pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); - pt3 = pt2; - pt3.move_y (env.eval_arg (i+3)); - PATH::curve (env, param, pt1, pt2, pt3); + pt1 = env.get_pt (); + pt1.move_x (env.eval_arg (i)); + pt2 = pt1; + pt2.move (env.eval_arg (i+1), env.eval_arg (i+2)); + pt3 = pt2; + pt3.move_y (env.eval_arg (i+3)); + PATH::curve (env, param, pt1, pt2, pt3); - pt1 = pt3; - pt1.move_y (env.eval_arg (i+4)); - pt2 = pt1; - pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); - pt3 = pt2; - pt3.move_x (env.eval_arg (i+7)); - if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) - pt3.move_y (env.eval_arg (i+8)); - PATH::curve (env, param, pt1, pt2, pt3); + pt1 = pt3; + pt1.move_y (env.eval_arg (i+4)); + pt2 = pt1; + pt2.move (env.eval_arg (i+5), env.eval_arg (i+6)); + pt3 = pt2; + pt3.move_x (env.eval_arg (i+7)); + if ((env.argStack.get_count () - i < 16) && ((env.argStack.get_count () & 1) != 0)) + pt3.move_y (env.eval_arg (i+8)); + PATH::curve (env, param, pt1, pt2, pt3); } } } @@ -824,7 +824,7 @@ struct PathProcs Point d; d.init (); for (unsigned int i = 0; i < 10; i += 2) - d.move (env.eval_arg (i), env.eval_arg (i+1)); + d.move (env.eval_arg (i), env.eval_arg (i+1)); Point pt1 = env.get_pt (); pt1.move (env.eval_arg (0), env.eval_arg (1)); @@ -840,13 +840,13 @@ struct PathProcs if (fabs (d.x.to_real ()) > fabs (d.y.to_real ())) { - pt6.move_x (env.eval_arg (10)); - pt6.y = env.get_pt ().y; + pt6.move_x (env.eval_arg (10)); + pt6.y = env.get_pt ().y; } else { - pt6.x = env.get_pt ().x; - pt6.move_y (env.eval_arg (10)); + pt6.x = env.get_pt ().x; + pt6.move_y (env.eval_arg (10)); } curve2 (env, param, pt1, pt2, pt3, pt4, pt5, pt6); @@ -857,8 +857,8 @@ struct PathProcs protected: static inline void curve2 (ENV &env, PARAM& param, - const Point &pt1, const Point &pt2, const Point &pt3, - const Point &pt4, const Point &pt5, const Point &pt6) + const Point &pt1, const Point &pt2, const Point &pt3, + const Point &pt4, const Point &pt5, const Point &pt6) { PATH::curve (env, param, pt1, pt2, pt3); PATH::curve (env, param, pt4, pt5, pt6); @@ -875,9 +875,9 @@ struct CSInterpreter : Interpreter for (;;) { OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); if (unlikely (SUPER::env.in_error ())) - return false; + return false; if (SUPER::env.is_endchar ()) - break; + break; } return true; diff --git a/src/hb-cff-interp-dict-common.hh b/src/hb-cff-interp-dict-common.hh index 9bb278b0b..aff356259 100644 --- a/src/hb-cff-interp-dict-common.hh +++ b/src/hb-cff-interp-dict-common.hh @@ -45,7 +45,7 @@ struct DictVal : OpStr { } - Number single_val; + Number single_val; }; typedef DictVal NumDictVal; @@ -73,10 +73,10 @@ struct TopDictValues : DictValues { case OpCode_CharStrings: case OpCode_FDArray: - return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return opstr.str.len; + return opstr.str.len; } } @@ -90,16 +90,16 @@ struct DictOpSet : OpSet { switch (op) { case OpCode_longintdict: /* 5-byte integer */ - env.argStack.push_longint_from_substr (env.substr); - break; + env.argStack.push_longint_from_substr (env.substr); + break; case OpCode_BCD: /* real number */ - env.argStack.push_real (parse_bcd (env.substr)); - break; + env.argStack.push_real (parse_bcd (env.substr)); + break; default: - OpSet::process_op (op, env); - break; + OpSet::process_op (op, env); + break; } } @@ -123,84 +123,84 @@ struct DictOpSet : OpSet char d; if ((i & 1) == 0) { - if (!substr.avail ()) - { - substr.set_error (); - return 0.0f; - } - byte = substr[0]; - substr.inc (); - d = byte >> 4; + if (!substr.avail ()) + { + substr.set_error (); + return 0.0f; + } + byte = substr[0]; + substr.inc (); + d = byte >> 4; } else - d = byte & 0x0F; + d = byte & 0x0F; switch (d) { - case RESERVED: - substr.set_error (); - return v; + case RESERVED: + substr.set_error (); + return v; - case END: - value = (double)(neg? -int_part: int_part); - if (frac_count > 0) - value += (frac_part / pow (10.0, (double)frac_count)); - if (exp_part != 0) - { - if (exp_neg) - value /= pow (10.0, (double)exp_part); - else - value *= pow (10.0, (double)exp_part); - } - return (float)value; + case END: + value = (double)(neg? -int_part: int_part); + if (frac_count > 0) + value += (frac_part / pow (10.0, (double)frac_count)); + if (exp_part != 0) + { + if (exp_neg) + value /= pow (10.0, (double)exp_part); + else + value *= pow (10.0, (double)exp_part); + } + return (float)value; - case NEG: - if (i != 0) - { - substr.set_error (); - return 0.0f; - } - neg = true; - break; + case NEG: + if (i != 0) + { + substr.set_error (); + return 0.0f; + } + neg = true; + break; - case DECIMAL: - if (part != INT_PART) - { - substr.set_error (); - return v; - } - part = FRAC_PART; - break; + case DECIMAL: + if (part != INT_PART) + { + substr.set_error (); + return v; + } + part = FRAC_PART; + break; - case EXP_NEG: - exp_neg = true; - HB_FALLTHROUGH; + case EXP_NEG: + exp_neg = true; + HB_FALLTHROUGH; - case EXP_POS: - if (part == EXP_PART) - { - substr.set_error (); - return v; - } - part = EXP_PART; - break; + case EXP_POS: + if (part == EXP_PART) + { + substr.set_error (); + return v; + } + part = EXP_PART; + break; - default: - switch (part) { - default: - case INT_PART: - int_part = (int_part * 10) + d; - break; + default: + switch (part) { + default: + case INT_PART: + int_part = (int_part * 10) + d; + break; - case FRAC_PART: - frac_part = (frac_part * 10) + d; - frac_count++; - break; + case FRAC_PART: + frac_part = (frac_part * 10) + d; + frac_count++; + break; - case EXP_PART: - exp_part = (exp_part * 10) + d; - break; - } + case EXP_PART: + exp_part = (exp_part * 10) + d; + break; + } } } @@ -225,9 +225,9 @@ struct DictOpSet : OpSet case OpCode_ForceBold: case OpCode_LanguageGroup: case OpCode_ExpansionFactor: - return true; + return true; default: - return false; + return false; } } }; @@ -239,19 +239,19 @@ struct TopDictOpSet : DictOpSet { switch (op) { case OpCode_CharStrings: - dictval.charStringsOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.charStringsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_FDArray: - dictval.FDArrayOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.FDArrayOffset = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_FontMatrix: - env.clear_args (); - break; + env.clear_args (); + break; default: - DictOpSet::process_op (op, env); - break; + DictOpSet::process_op (op, env); + break; } } }; @@ -266,7 +266,7 @@ struct DictInterpreter : Interpreter { OPSET::process_op (SUPER::env.fetch_op (), SUPER::env, param); if (unlikely (SUPER::env.in_error ())) - return false; + return false; } return true; diff --git a/src/hb-cff1-interp-cs.hh b/src/hb-cff1-interp-cs.hh index 29659a33f..95950b0c1 100644 --- a/src/hb-cff1-interp-cs.hh +++ b/src/hb-cff1-interp-cs.hh @@ -58,9 +58,9 @@ struct CFF1CSInterpEnv : CSInterpEnv { if (has_width_) { - width = SUPER::argStack[0]; - has_width = true; - arg_start = 1; + width = SUPER::argStack[0]; + has_width = true; + arg_start = 1; } } processed_width = true; @@ -74,11 +74,11 @@ struct CFF1CSInterpEnv : CSInterpEnv inline void set_in_seac (bool _in_seac) { in_seac = _in_seac; } - bool processed_width; - bool has_width; + bool processed_width; + bool has_width; unsigned int arg_start; - Number width; - bool in_seac; + Number width; + bool in_seac; private: typedef CSInterpEnv SUPER; @@ -94,21 +94,21 @@ struct CFF1CSOpSet : CSOpSet { switch (op) { case OpCode_dotsection: - SUPER::flush_args_and_op (op, env, param); - break; + SUPER::flush_args_and_op (op, env, param); + break; case OpCode_endchar: - OPSET::check_width (op, env, param); - if (env.argStack.get_count () >= 4) - { - OPSET::process_seac (env, param); - } - OPSET::flush_args_and_op (op, env, param); - env.set_endchar (true); - break; + OPSET::check_width (op, env, param); + if (env.argStack.get_count () >= 4) + { + OPSET::process_seac (env, param); + } + OPSET::flush_args_and_op (op, env, param); + env.set_endchar (true); + break; default: - SUPER::process_op (op, env, param); + SUPER::process_op (op, env, param); } } @@ -119,24 +119,24 @@ struct CFF1CSOpSet : CSOpSet bool has_width = false; switch (op) { - case OpCode_endchar: - case OpCode_hstem: - case OpCode_hstemhm: - case OpCode_vstem: - case OpCode_vstemhm: - case OpCode_hintmask: - case OpCode_cntrmask: - has_width = ((env.argStack.get_count () & 1) != 0); - break; - case OpCode_hmoveto: - case OpCode_vmoveto: - has_width = (env.argStack.get_count () > 1); - break; - case OpCode_rmoveto: - has_width = (env.argStack.get_count () > 2); - break; - default: - return; + case OpCode_endchar: + case OpCode_hstem: + case OpCode_hstemhm: + case OpCode_vstem: + case OpCode_vstemhm: + case OpCode_hintmask: + case OpCode_cntrmask: + has_width = ((env.argStack.get_count () & 1) != 0); + break; + case OpCode_hmoveto: + case OpCode_vmoveto: + has_width = (env.argStack.get_count () > 1); + break; + case OpCode_rmoveto: + has_width = (env.argStack.get_count () > 2); + break; + default: + return; } env.set_width (has_width); } diff --git a/src/hb-cff2-interp-cs.hh b/src/hb-cff2-interp-cs.hh index 99b34d375..8d193d621 100644 --- a/src/hb-cff2-interp-cs.hh +++ b/src/hb-cff2-interp-cs.hh @@ -52,7 +52,7 @@ struct BlendArg : Number inline void set_real (float v) { reset_blends (); Number::set_real (v); } inline void set_blends (unsigned int numValues_, unsigned int valueIndex_, - unsigned int numBlends, const BlendArg *blends_) + unsigned int numBlends, const BlendArg *blends_) { numValues = numValues_; valueIndex = valueIndex_; @@ -80,7 +80,7 @@ struct CFF2CSInterpEnv : CSInterpEnv { template inline void init (const ByteStr &str, ACC &acc, unsigned int fd, - 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); @@ -133,10 +133,10 @@ struct CFF2CSInterpEnv : CSInterpEnv region_count = varStore->varStore.get_region_index_count (get_ivs ()); if (do_blend) { - scalars.resize (region_count); - varStore->varStore.get_scalars (get_ivs (), - (int *)coords, num_coords, - &scalars[0], region_count); + scalars.resize (region_count); + varStore->varStore.get_scalars (get_ivs (), + (int *)coords, num_coords, + &scalars[0], region_count); } seen_blend = true; } @@ -157,10 +157,10 @@ struct CFF2CSInterpEnv : CSInterpEnv } inline unsigned int get_region_count (void) const { return region_count; } - inline void set_region_count (unsigned int region_count_) { region_count = region_count_; } + inline void set_region_count (unsigned int region_count_) { region_count = region_count_; } inline unsigned int get_ivs (void) const { return ivs; } - inline void set_ivs (unsigned int ivs_) { ivs = ivs_; } - inline bool seen_vsindex (void) const { return seen_vsindex_; } + inline void set_ivs (unsigned int ivs_) { ivs = ivs_; } + inline bool seen_vsindex (void) const { return seen_vsindex_; } protected: inline void blend_arg (BlendArg &arg) @@ -169,13 +169,13 @@ struct CFF2CSInterpEnv : CSInterpEnv { if (likely (scalars.len == arg.deltas.len)) { - float v = arg.to_real (); - for (unsigned int i = 0; i < scalars.len; i++) - { - v += scalars[i] * arg.deltas[i].to_real (); - } - arg.set_real (v); - arg.deltas.resize (0); + float v = arg.to_real (); + for (unsigned int i = 0; i < scalars.len; i++) + { + v += scalars[i] * arg.deltas[i].to_real (); + } + arg.set_real (v); + arg.deltas.resize (0); } } } @@ -183,13 +183,13 @@ struct CFF2CSInterpEnv : CSInterpEnv protected: const int *coords; unsigned int num_coords; - const CFF2VariationStore *varStore; + const CFF2VariationStore *varStore; unsigned int region_count; unsigned int ivs; hb_vector_t scalars; - bool do_blend; - bool seen_vsindex_; - bool seen_blend; + bool do_blend; + bool seen_vsindex_; + bool seen_blend; typedef CSInterpEnv SUPER; }; @@ -201,30 +201,30 @@ struct CFF2CSOpSet : CSOpSet switch (op) { case OpCode_callsubr: case OpCode_callgsubr: - /* a subroutine number shoudln't be a blended value */ - if (unlikely (env.argStack.peek ().blending ())) - { - env.set_error (); - break; - } - SUPER::process_op (op, env, param); - break; + /* a subroutine number shoudln't be a blended value */ + if (unlikely (env.argStack.peek ().blending ())) + { + env.set_error (); + break; + } + SUPER::process_op (op, env, param); + break; case OpCode_blendcs: - OPSET::process_blend (env, param); - break; + OPSET::process_blend (env, param); + break; case OpCode_vsindexcs: - if (unlikely (env.argStack.peek ().blending ())) - { - env.set_error (); - break; - } - OPSET::process_vsindex (env, param); - break; + if (unlikely (env.argStack.peek ().blending ())) + { + env.set_error (); + break; + } + OPSET::process_vsindex (env, param); + break; default: - SUPER::process_op (op, env, param); + SUPER::process_op (op, env, param); } } diff --git a/src/hb-ot-cff-common.hh b/src/hb-ot-cff-common.hh index 3f5a85aaf..5ec1361a8 100644 --- a/src/hb-ot-cff-common.hh +++ b/src/hb-ot-cff-common.hh @@ -89,9 +89,9 @@ struct CFFIndex { TRACE_SANITIZE (this); return_trace (likely ((count.sanitize (c) && count == 0) || /* empty INDEX */ - (c->check_struct (this) && offSize >= 1 && offSize <= 4 && - c->check_array (offsets, offSize, count + 1) && - c->check_array ((const HBUINT8*)data_base (), 1, max_offset () - 1)))); + (c->check_struct (this) && offSize >= 1 && offSize <= 4 && + c->check_array (offsets, offSize, count + 1) && + c->check_array ((const HBUINT8*)data_base (), 1, max_offset () - 1)))); } inline static unsigned int calculate_offset_array_size (unsigned int offSize, unsigned int count) @@ -119,8 +119,8 @@ struct CFFIndex } inline bool serialize (hb_serialize_context_t *c, - unsigned int offSize_, - const ByteStrArray &byteArray) + unsigned int offSize_, + const ByteStrArray &byteArray) { TRACE_SERIALIZE (this); if (byteArray.len == 0) @@ -136,33 +136,33 @@ struct CFFIndex this->count.set (byteArray.len); this->offSize.set (offSize_); if (!unlikely (c->allocate_size (offSize_ * (byteArray.len + 1)))) - return_trace (false); + return_trace (false); /* serialize indices */ unsigned int offset = 1; unsigned int i = 0; for (; i < byteArray.len; i++) { - set_offset_at (i, offset); - offset += byteArray[i].get_size (); + set_offset_at (i, offset); + offset += byteArray[i].get_size (); } set_offset_at (i, offset); /* serialize data */ for (unsigned int i = 0; i < byteArray.len; i++) { - ByteStr *dest = c->start_embed (); - if (unlikely (dest == nullptr || - !dest->serialize (c, byteArray[i]))) - return_trace (false); + ByteStr *dest = c->start_embed (); + if (unlikely (dest == nullptr || + !dest->serialize (c, byteArray[i]))) + return_trace (false); } } return_trace (true); } inline bool serialize (hb_serialize_context_t *c, - unsigned int offSize_, - const StrBuffArray &buffArray) + unsigned int offSize_, + const StrBuffArray &buffArray) { ByteStrArray byteArray; byteArray.init (); @@ -221,9 +221,9 @@ struct CFFIndex if (this != &Null(CFFIndex)) { if (count > 0) - return min_size + offset_array_size () + (offset_at (count) - 1); + return min_size + offset_array_size () + (offset_at (count) - 1); else - return count.static_size; /* empty CFFIndex contains count only */ + return count.static_size; /* empty CFFIndex contains count only */ } else return 0; @@ -242,7 +242,7 @@ struct CFFIndex } public: - COUNT count; /* Number of object data. Note there are (count+1) offsets */ + COUNT count; /* Number of object data. Note there are (count+1) offsets */ HBUINT8 offSize; /* The byte size of each offset in the offsets array. */ HBUINT8 offsets[VAR]; /* The array of (count + 1) offsets into objects array (1-base). */ /* HBUINT8 data[VAR]; Object data */ @@ -262,12 +262,12 @@ struct CFFIndexOf : CFFIndex template inline bool serialize (hb_serialize_context_t *c, - unsigned int offSize_, - const DATA *dataArray, - unsigned int dataArrayLen, - const hb_vector_t &dataSizeArray, - const PARAM1 ¶m1, - const PARAM2 ¶m2) + unsigned int offSize_, + const DATA *dataArray, + unsigned int dataArrayLen, + const hb_vector_t &dataSizeArray, + const PARAM1 ¶m1, + const PARAM2 ¶m2) { TRACE_SERIALIZE (this); /* serialize CFFIndex header */ @@ -292,8 +292,8 @@ struct CFFIndexOf : CFFIndex { TYPE *dest = c->start_embed (); if (unlikely (dest == nullptr || - !dest->serialize (c, dataArray[i], param1, param2))) - return_trace (false); + !dest->serialize (c, dataArray[i], param1, param2))) + return_trace (false); } return_trace (true); } @@ -301,10 +301,10 @@ struct CFFIndexOf : CFFIndex /* in parallel to above */ template inline static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, - const DATA *dataArray, - unsigned int dataArrayLen, - hb_vector_t &dataSizeArray, /* OUT */ - const PARAM ¶m) + const DATA *dataArray, + unsigned int dataArrayLen, + hb_vector_t &dataSizeArray, /* OUT */ + const PARAM ¶m) { /* determine offset size */ unsigned int totalDataSize = 0; @@ -325,15 +325,15 @@ struct Dict : UnsizedByteStr { template inline bool serialize (hb_serialize_context_t *c, - const DICTVAL &dictval, - OP_SERIALIZER& opszr, - PARAM& param) + const DICTVAL &dictval, + OP_SERIALIZER& opszr, + PARAM& param) { TRACE_SERIALIZE (this); for (unsigned int i = 0; i < dictval.get_count (); i++) { if (unlikely (!opszr.serialize (c, dictval[i], param))) - return_trace (false); + return_trace (false); } return_trace (true); } @@ -341,8 +341,8 @@ struct Dict : UnsizedByteStr /* in parallel to above */ template inline static unsigned int calculate_serialized_size (const DICTVAL &dictval, - OP_SERIALIZER& opszr, - PARAM& param) + OP_SERIALIZER& opszr, + PARAM& param) { unsigned int size = 0; for (unsigned int i = 0; i < dictval.get_count (); i++) @@ -352,7 +352,7 @@ struct Dict : UnsizedByteStr template inline static unsigned int calculate_serialized_size (const DICTVAL &dictval, - OP_SERIALIZER& opszr) + OP_SERIALIZER& opszr) { unsigned int size = 0; for (unsigned int i = 0; i < dictval.get_count (); i++) @@ -471,9 +471,9 @@ struct FDArray : CFFIndexOf /* used by CFF1 */ template inline bool serialize (hb_serialize_context_t *c, - unsigned int offSize_, - const hb_vector_t &fontDicts, - OP_SERIALIZER& opszr) + unsigned int offSize_, + const hb_vector_t &fontDicts, + OP_SERIALIZER& opszr) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -497,7 +497,7 @@ struct FDArray : CFFIndexOf { FontDict *dict = c->start_embed (); if (unlikely (!dict->serialize (c, fontDicts[i], opszr, fontDicts[i]))) - return_trace (false); + return_trace (false); } return_trace (true); } @@ -505,12 +505,12 @@ struct FDArray : CFFIndexOf /* used by CFF2 */ template inline bool serialize (hb_serialize_context_t *c, - unsigned int offSize_, - const hb_vector_t &fontDicts, - unsigned int fdCount, - const Remap &fdmap, - OP_SERIALIZER& opszr, - const hb_vector_t &privateInfos) + unsigned int offSize_, + const hb_vector_t &fontDicts, + unsigned int fdCount, + const Remap &fdmap, + OP_SERIALIZER& opszr, + const hb_vector_t &privateInfos) { TRACE_SERIALIZE (this); if (unlikely (!c->extend_min (*this))) return_trace (false); @@ -525,8 +525,8 @@ struct FDArray : CFFIndexOf for (unsigned i = 0; i < fontDicts.len; i++) if (fdmap.includes (i)) { - CFFIndexOf::set_offset_at (fid++, offset); - offset += FontDict::calculate_serialized_size (fontDicts[i], opszr); + CFFIndexOf::set_offset_at (fid++, offset); + offset += FontDict::calculate_serialized_size (fontDicts[i], opszr); } CFFIndexOf::set_offset_at (fid, offset); @@ -534,9 +534,9 @@ struct FDArray : CFFIndexOf for (unsigned int i = 0; i < fontDicts.len; i++) if (fdmap.includes (i)) { - FontDict *dict = c->start_embed (); - if (unlikely (!dict->serialize (c, fontDicts[i], opszr, privateInfos[fdmap[i]]))) - return_trace (false); + FontDict *dict = c->start_embed (); + if (unlikely (!dict->serialize (c, fontDicts[i], opszr, privateInfos[fdmap[i]]))) + return_trace (false); } return_trace (true); } @@ -544,15 +544,15 @@ struct FDArray : CFFIndexOf /* in parallel to above */ template inline static unsigned int calculate_serialized_size (unsigned int &offSize_ /* OUT */, - const hb_vector_t &fontDicts, - unsigned int fdCount, - const Remap &fdmap, - OP_SERIALIZER& opszr) + const hb_vector_t &fontDicts, + unsigned int fdCount, + const Remap &fdmap, + OP_SERIALIZER& opszr) { unsigned int dictsSize = 0; for (unsigned int i = 0; i < fontDicts.len; i++) if (fdmap.includes (i)) - dictsSize += FontDict::calculate_serialized_size (fontDicts[i], opszr); + dictsSize += FontDict::calculate_serialized_size (fontDicts[i], opszr); offSize_ = calcOffSize (dictsSize); return CFFIndex::calculate_serialized_size (offSize_, fdCount, dictsSize); @@ -568,7 +568,7 @@ struct FDSelect0 { return_trace (false); for (unsigned int i = 0; i < c->get_num_glyphs (); i++) if (unlikely (!fds[i].sanitize (c))) - return_trace (false); + return_trace (false); return_trace (true); } @@ -614,9 +614,9 @@ struct FDSelect3_4 { for (unsigned int i = 0; i < nRanges; i++) { if (unlikely (!ranges[i].sanitize (c, fdcount))) - return_trace (false); + return_trace (false); if ((0 < i) && unlikely (ranges[i - 1].first >= ranges[i].first)) - return_trace (false); + return_trace (false); } if (unlikely (!sentinel().sanitize (c) || (sentinel() != c->get_num_glyphs ()))) return_trace (false); @@ -629,7 +629,7 @@ struct FDSelect3_4 { unsigned int i; for (i = 1; i < nRanges; i++) if (glyph < ranges[i].first) - break; + break; return (hb_codepoint_t)ranges[i - 1].fd; } @@ -637,7 +637,7 @@ struct FDSelect3_4 { inline GID_TYPE &sentinel (void) { return StructAfter (ranges[nRanges - 1]); } inline const GID_TYPE &sentinel (void) const { return StructAfter (ranges[nRanges - 1]); } - GID_TYPE nRanges; + GID_TYPE nRanges; FDSelect3_4_Range ranges[VAR]; /* GID_TYPE sentinel */ @@ -653,9 +653,9 @@ struct FDSelect { TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && (format == 0 || format == 3) && - (format == 0)? - u.format0.sanitize (c, fdcount): - u.format3.sanitize (c, fdcount))); + (format == 0)? + u.format0.sanitize (c, fdcount): + u.format3.sanitize (c, fdcount))); } inline bool serialize (hb_serialize_context_t *c, const FDSelect &src, unsigned int num_glyphs) diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc index 92c625882..d1e0a1fa9 100644 --- a/src/hb-ot-cff1-table.cc +++ b/src/hb-ot-cff1-table.cc @@ -276,8 +276,8 @@ struct CFF1CSOpSet_Extents : CFF1CSOpSet CFF1Index; template struct CFF1IndexOf : CFFIndexOf {}; -typedef CFFIndex CFF1Index; -typedef CFF1Index CFF1CharStrings; -typedef FDArray CFF1FDArray; -typedef Subrs CFF1Subrs; +typedef CFFIndex CFF1Index; +typedef CFF1Index CFF1CharStrings; +typedef FDArray CFF1FDArray; +typedef Subrs CFF1Subrs; struct CFF1FDSelect : FDSelect {}; @@ -114,14 +114,14 @@ struct Encoding1 { { if (glyph <= ranges[i].nLeft) { - return (hb_codepoint_t)ranges[i].first + glyph; + return (hb_codepoint_t)ranges[i].first + glyph; } glyph -= (ranges[i].nLeft + 1); } return CFF_UNDEF_CODE; } - HBUINT8 nRanges; + HBUINT8 nRanges; Encoding1_Range ranges[VAR]; DEFINE_SIZE_ARRAY (1, ranges); @@ -151,13 +151,13 @@ struct CFF1SuppEncData { { for (unsigned int i = 0; i < nSups; i++) if (sid == supps[i].glyph) - codes.push (supps[i].code); + codes.push (supps[i].code); } inline unsigned int get_size (void) const { return HBUINT8::static_size + SuppEncoding::static_size * nSups; } - HBUINT8 nSups; + HBUINT8 nSups; SuppEncoding supps[VAR]; DEFINE_SIZE_ARRAY (1, supps); @@ -191,10 +191,10 @@ struct Encoding { /* serialize a subset Encoding */ inline bool serialize (hb_serialize_context_t *c, - uint8_t format, - unsigned int enc_count, - const hb_vector_t& code_ranges, - const hb_vector_t& supp_codes) + uint8_t format, + unsigned int enc_count, + const hb_vector_t& code_ranges, + const hb_vector_t& supp_codes) { TRACE_SERIALIZE (this); Encoding *dest = c->extend_min (*this); @@ -208,10 +208,10 @@ struct Encoding { unsigned int glyph = 0; for (unsigned int i = 0; i < code_ranges.len; i++) { - hb_codepoint_t code = code_ranges[i].code; - for (int left = (int)code_ranges[i].glyph; left >= 0; left--) - fmt0->codes[glyph++].set (code++); - assert ((glyph <= 0x100) && (code <= 0x100)); + hb_codepoint_t code = code_ranges[i].code; + for (int left = (int)code_ranges[i].glyph; left >= 0; left--) + fmt0->codes[glyph++].set (code++); + assert ((glyph <= 0x100) && (code <= 0x100)); } } else @@ -221,9 +221,9 @@ struct Encoding { fmt1->nRanges.set (code_ranges.len); for (unsigned int i = 0; i < code_ranges.len; i++) { - assert ((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF)); - fmt1->ranges[i].first.set (code_ranges[i].code); - fmt1->ranges[i].nLeft.set (code_ranges[i].glyph); + assert ((code_ranges[i].code <= 0xFF) && (code_ranges[i].glyph <= 0xFF)); + fmt1->ranges[i].first.set (code_ranges[i].code); + fmt1->ranges[i].nLeft.set (code_ranges[i].glyph); } } if (supp_codes.len > 0) @@ -233,8 +233,8 @@ struct Encoding { suppData->nSups.set (supp_codes.len); for (unsigned int i = 0; i < supp_codes.len; i++) { - suppData->supps[i].code.set (supp_codes[i].code); - suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */ + suppData->supps[i].code.set (supp_codes[i].code); + suppData->supps[i].glyph.set (supp_codes[i].glyph); /* actually SID */ } } return_trace (true); @@ -242,9 +242,9 @@ struct Encoding { /* parallel to above: calculate the size of a subset Encoding */ static inline unsigned int calculate_serialized_size ( - uint8_t format, - unsigned int enc_count, - unsigned int supp_count) + uint8_t format, + unsigned int enc_count, + unsigned int supp_count) { unsigned int size = min_size; if (format == 0) @@ -331,7 +331,7 @@ struct Charset0 { for (unsigned int glyph = 1; glyph < num_glyphs; glyph++) { if (sids[glyph-1] == sid) - return glyph; + return glyph; } return 0; } @@ -372,7 +372,7 @@ struct Charset1_2 { for (unsigned int i = 0; num_glyphs > 0; i++) { if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1))) - return_trace (false); + return_trace (false); num_glyphs -= (ranges[i].nLeft + 1); } return_trace (true); @@ -385,7 +385,7 @@ struct Charset1_2 { for (unsigned int i = 0;; i++) { if (glyph <= ranges[i].nLeft) - return (hb_codepoint_t)ranges[i].first + glyph; + return (hb_codepoint_t)ranges[i].first + glyph; glyph -= (ranges[i].nLeft + 1); } @@ -399,7 +399,7 @@ struct Charset1_2 { for (unsigned int i = 0;; i++) { if ((ranges[i].first <= sid) && sid <= ranges[i].first + ranges[i].nLeft) - return glyph + (sid - ranges[i].first); + return glyph + (sid - ranges[i].first); glyph += (ranges[i].nLeft + 1); } @@ -462,9 +462,9 @@ struct Charset { /* serialize a subset Charset */ inline bool serialize (hb_serialize_context_t *c, - uint8_t format, - unsigned int num_glyphs, - const hb_vector_t& sid_ranges) + uint8_t format, + unsigned int num_glyphs, + const hb_vector_t& sid_ranges) { TRACE_SERIALIZE (this); Charset *dest = c->extend_min (*this); @@ -477,9 +477,9 @@ struct Charset { unsigned int glyph = 0; for (unsigned int i = 0; i < sid_ranges.len; i++) { - hb_codepoint_t sid = sid_ranges[i].code; - for (int left = (int)sid_ranges[i].glyph; left >= 0; left--) - fmt0->sids[glyph++].set (sid++); + hb_codepoint_t sid = sid_ranges[i].code; + for (int left = (int)sid_ranges[i].glyph; left >= 0; left--) + fmt0->sids[glyph++].set (sid++); } } else if (format == 1) @@ -488,9 +488,9 @@ struct Charset { if (unlikely (fmt1 == nullptr)) return_trace (false); for (unsigned int i = 0; i < sid_ranges.len; i++) { - assert (sid_ranges[i].glyph <= 0xFF); - fmt1->ranges[i].first.set (sid_ranges[i].code); - fmt1->ranges[i].nLeft.set (sid_ranges[i].glyph); + assert (sid_ranges[i].glyph <= 0xFF); + fmt1->ranges[i].first.set (sid_ranges[i].code); + fmt1->ranges[i].nLeft.set (sid_ranges[i].glyph); } } else /* format 2 */ @@ -499,9 +499,9 @@ struct Charset { if (unlikely (fmt2 == nullptr)) return_trace (false); for (unsigned int i = 0; i < sid_ranges.len; i++) { - assert (sid_ranges[i].glyph <= 0xFFFF); - fmt2->ranges[i].first.set (sid_ranges[i].code); - fmt2->ranges[i].nLeft.set (sid_ranges[i].glyph); + assert (sid_ranges[i].glyph <= 0xFFFF); + fmt2->ranges[i].first.set (sid_ranges[i].code); + fmt2->ranges[i].nLeft.set (sid_ranges[i].glyph); } } return_trace (true); @@ -509,8 +509,8 @@ struct Charset { /* parallel to above: calculate the size of a subset Charset */ static inline unsigned int calculate_serialized_size ( - uint8_t format, - unsigned int count) + uint8_t format, + unsigned int count) { unsigned int size = min_size; if (format == 0) @@ -573,7 +573,7 @@ struct CFF1StringIndex : CFF1Index if (unlikely ((strings.count == 0) || (sidmap.get_count () == 0))) { if (!unlikely (c->extend_min (this->count))) - return_trace (false); + return_trace (false); count.set (0); return_trace (true); } @@ -586,7 +586,7 @@ struct CFF1StringIndex : CFF1Index { hb_codepoint_t j = sidmap[i]; if (j != CFF_UNDEF_CODE) - bytesArray[j] = strings[i]; + bytesArray[j] = strings[i]; } bool result = CFF1Index::serialize (c, offSize_, bytesArray); @@ -604,7 +604,7 @@ struct CFF1StringIndex : CFF1Index unsigned int dataSize = 0; for (unsigned int i = 0; i < count; i++) if (sidmap[i] != CFF_UNDEF_CODE) - dataSize += length_at (i); + dataSize += length_at (i); offSize = calcOffSize(dataSize); return CFF1Index::calculate_serialized_size (offSize, sidmap.get_count (), dataSize); @@ -655,23 +655,23 @@ struct NameDictValues { switch (op) { case OpCode_version: - return version; + return version; case OpCode_Notice: - return notice; + return notice; case OpCode_Copyright: - return copyright; + return copyright; case OpCode_FullName: - return fullName; + return fullName; case OpCode_FamilyName: - return familyName; + return familyName; case OpCode_Weight: - return weight; + return weight; case OpCode_PostScript: - return postscript; + return postscript; case OpCode_FontName: - return fontName; + return fontName; default: - assert (0); + assert (0); } } @@ -733,9 +733,9 @@ struct CFF1TopDictOpSet : TopDictOpSet case OpCode_Weight: case OpCode_PostScript: case OpCode_BaseFontName: - dictval.nameSIDs[NameDictValues::name_op_to_index (op)] = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.nameSIDs[NameDictValues::name_op_to_index (op)] = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_isFixedPitch: case OpCode_ItalicAngle: case OpCode_UnderlinePosition: @@ -752,50 +752,50 @@ struct CFF1TopDictOpSet : TopDictOpSet case OpCode_FontBBox: case OpCode_XUID: case OpCode_BaseFontBlend: - env.clear_args (); - break; + env.clear_args (); + break; case OpCode_CIDCount: - dictval.cidCount = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.cidCount = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_ROS: - dictval.ros_supplement = env.argStack.pop_uint (); - dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint (); - dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.ros_supplement = env.argStack.pop_uint (); + dictval.nameSIDs[NameDictValues::ordering] = env.argStack.pop_uint (); + dictval.nameSIDs[NameDictValues::registry] = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_Encoding: - dictval.EncodingOffset = env.argStack.pop_uint (); - env.clear_args (); - if (unlikely (dictval.EncodingOffset == 0)) return; - break; + dictval.EncodingOffset = env.argStack.pop_uint (); + env.clear_args (); + if (unlikely (dictval.EncodingOffset == 0)) return; + break; case OpCode_charset: - dictval.CharsetOffset = env.argStack.pop_uint (); - env.clear_args (); - if (unlikely (dictval.CharsetOffset == 0)) return; - break; + dictval.CharsetOffset = env.argStack.pop_uint (); + env.clear_args (); + if (unlikely (dictval.CharsetOffset == 0)) return; + break; case OpCode_FDSelect: - dictval.FDSelectOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + 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; + 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); - /* Record this operand below if stack is empty, otherwise done */ - if (!env.argStack.is_empty ()) return; - break; + env.last_offset = env.substr.offset; + TopDictOpSet::process_op (op, env, dictval); + /* Record this operand below if stack is empty, otherwise done */ + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -828,23 +828,23 @@ struct CFF1FontDictOpSet : DictOpSet { switch (op) { case OpCode_FontName: - dictval.fontName = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.fontName = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_FontMatrix: case OpCode_PaintType: - env.clear_args (); - break; + 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; + dictval.privateDictInfo.offset = env.argStack.pop_uint (); + dictval.privateDictInfo.size = env.argStack.pop_uint (); + env.clear_args (); + break; default: - DictOpSet::process_op (op, env); - if (!env.argStack.is_empty ()) return; - break; + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -873,9 +873,9 @@ struct CFF1PrivateDictValues_Base : DictValues unsigned int size = 0; for (unsigned int i = 0; i < DictValues::get_count; i++) if (DictValues::get_value (i).op == OpCode_Subrs) - size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); + size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); else - size += DictValues::get_value (i).str.len; + size += DictValues::get_value (i).str.len; return size; } @@ -900,8 +900,8 @@ struct CFF1PrivateDictOpSet : DictOpSet case OpCode_FamilyOtherBlues: case OpCode_StemSnapH: case OpCode_StemSnapV: - env.clear_args (); - break; + env.clear_args (); + break; case OpCode_StdHW: case OpCode_StdVW: case OpCode_BlueScale: @@ -913,18 +913,18 @@ struct CFF1PrivateDictOpSet : DictOpSet case OpCode_initialRandomSeed: case OpCode_defaultWidthX: case OpCode_nominalWidthX: - val.single_val = env.argStack.pop_num (); - env.clear_args (); - break; + val.single_val = env.argStack.pop_num (); + env.clear_args (); + break; case OpCode_Subrs: - dictval.subrsOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; default: - DictOpSet::process_op (op, env); - if (!env.argStack.is_empty ()) return; - break; + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -955,18 +955,18 @@ struct CFF1PrivateDictOpSet_Subset : DictOpSet case OpCode_initialRandomSeed: case OpCode_defaultWidthX: case OpCode_nominalWidthX: - env.clear_args (); - break; + env.clear_args (); + break; case OpCode_Subrs: - dictval.subrsOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; default: - DictOpSet::process_op (op, env); - if (!env.argStack.is_empty ()) return; - break; + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -990,13 +990,13 @@ using namespace CFF; struct cff1 { - static const hb_tag_t tableTag = HB_OT_TAG_cff1; + static const hb_tag_t tableTag = HB_OT_TAG_cff1; inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - likely (version.major == 1)); + likely (version.major == 1)); } template @@ -1028,37 +1028,37 @@ struct cff1 { fini (); return; } { /* parse top dict */ - const ByteStr topDictStr = (*topDictIndex)[0]; - if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } - CFF1TopDict_Interpreter top_interp; - top_interp.env.init (topDictStr); - topDict.init (); - if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } + const ByteStr topDictStr = (*topDictIndex)[0]; + if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } + CFF1TopDict_Interpreter top_interp; + top_interp.env.init (topDictStr); + topDict.init (); + if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } } if (is_predef_charset ()) - charset = &Null(Charset); + charset = &Null(Charset); else { - charset = &StructAtOffsetOrNull (cff, topDict.CharsetOffset); - if (unlikely ((charset == &Null (Charset)) || !charset->sanitize (&sc))) { fini (); return; } + charset = &StructAtOffsetOrNull (cff, topDict.CharsetOffset); + if (unlikely ((charset == &Null (Charset)) || !charset->sanitize (&sc))) { fini (); return; } } fdCount = 1; if (is_CID ()) { - fdArray = &StructAtOffsetOrNull (cff, topDict.FDArrayOffset); - fdSelect = &StructAtOffsetOrNull (cff, topDict.FDSelectOffset); - if (unlikely ((fdArray == &Null(CFF1FDArray)) || !fdArray->sanitize (&sc) || - (fdSelect == &Null(CFF1FDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) - { fini (); return; } + fdArray = &StructAtOffsetOrNull (cff, topDict.FDArrayOffset); + fdSelect = &StructAtOffsetOrNull (cff, topDict.FDSelectOffset); + if (unlikely ((fdArray == &Null(CFF1FDArray)) || !fdArray->sanitize (&sc) || + (fdSelect == &Null(CFF1FDSelect)) || !fdSelect->sanitize (&sc, fdArray->count))) + { fini (); return; } - fdCount = fdArray->count; + fdCount = fdArray->count; } else { - fdArray = &Null(CFF1FDArray); - fdSelect = &Null(CFF1FDSelect); + fdArray = &Null(CFF1FDArray); + fdSelect = &Null(CFF1FDSelect); } stringIndex = &StructAtOffset (topDictIndex, topDictIndex->get_size ()); @@ -1080,51 +1080,51 @@ struct cff1 privateDicts.resize (fdCount); for (unsigned int i = 0; i < fdCount; i++) - privateDicts[i].init (); + privateDicts[i].init (); // parse CID font dicts and gather private dicts if (is_CID ()) { - for (unsigned int i = 0; i < fdCount; i++) - { - ByteStr fontDictStr = (*fdArray)[i]; - if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } - CFF1FontDictValues *font; - CFF1FontDict_Interpreter font_interp; - font_interp.env.init (fontDictStr); - font = fontDicts.push (); - font->init (); - if (unlikely (!font_interp.interpret (*font))) { fini (); return; } - PRIVDICTVAL *priv = &privateDicts[i]; - const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); - if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } - DictInterpreter priv_interp; - priv_interp.env.init (privDictStr); - priv->init (); - if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } + for (unsigned int i = 0; i < fdCount; i++) + { + ByteStr fontDictStr = (*fdArray)[i]; + if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } + CFF1FontDictValues *font; + CFF1FontDict_Interpreter font_interp; + font_interp.env.init (fontDictStr); + font = fontDicts.push (); + font->init (); + if (unlikely (!font_interp.interpret (*font))) { fini (); return; } + PRIVDICTVAL *priv = &privateDicts[i]; + const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter priv_interp; + priv_interp.env.init (privDictStr); + priv->init (); + if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); - if (priv->localSubrs != &Null(CFF1Subrs) && - unlikely (!priv->localSubrs->sanitize (&sc))) - { fini (); return; } - } + priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && + unlikely (!priv->localSubrs->sanitize (&sc))) + { fini (); return; } + } } else /* non-CID */ { - CFF1TopDictValues *font = &topDict; - PRIVDICTVAL *priv = &privateDicts[0]; + 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; - priv_interp.env.init (privDictStr); - priv->init (); - if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } + const ByteStr privDictStr (StructAtOffset (cff, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter priv_interp; + priv_interp.env.init (privDictStr); + priv->init (); + if (unlikely (!priv_interp.interpret (*priv))) { fini (); return; } - priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); - if (priv->localSubrs != &Null(CFF1Subrs) && - unlikely (!priv->localSubrs->sanitize (&sc))) - { fini (); return; } + priv->localSubrs = &StructAtOffsetOrNull (privDictStr.str, priv->subrsOffset); + if (priv->localSubrs != &Null(CFF1Subrs) && + unlikely (!priv->localSubrs->sanitize (&sc))) + { fini (); return; } } } @@ -1147,35 +1147,35 @@ struct cff1 { hb_codepoint_t sid = lookup_standard_encoding_for_sid (code); if (unlikely (sid == CFF_UNDEF_SID)) - return 0; + return 0; if (charset != &Null(Charset)) - return charset->get_glyph (sid, num_glyphs); + return charset->get_glyph (sid, num_glyphs); else if ((topDict.CharsetOffset == ISOAdobeCharset) - && (code <= 228 /*zcaron*/)) return sid; + && (code <= 228 /*zcaron*/)) return sid; return 0; } protected: - hb_blob_t *blob; + hb_blob_t *blob; hb_sanitize_context_t sc; public: - const Charset *charset; + const Charset *charset; const CFF1NameIndex *nameIndex; const CFF1TopDictIndex *topDictIndex; const CFF1StringIndex *stringIndex; - const CFF1Subrs *globalSubrs; + const CFF1Subrs *globalSubrs; const CFF1CharStrings *charStrings; const CFF1FDArray *fdArray; const CFF1FDSelect *fdSelect; - unsigned int fdCount; + unsigned int fdCount; CFF1TopDictValues topDict; hb_vector_t fontDicts; - hb_vector_t privateDicts; + hb_vector_t privateDicts; - unsigned int num_glyphs; + unsigned int num_glyphs; }; struct accelerator_t : accelerator_templ_t @@ -1195,15 +1195,15 @@ struct cff1 encoding = &Null(Encoding); if (is_CID ()) { - if (unlikely (charset == &Null(Charset))) { fini (); return; } + if (unlikely (charset == &Null(Charset))) { fini (); return; } } else { - if (!is_predef_encoding ()) - { - encoding = &StructAtOffsetOrNull (cff, topDict.EncodingOffset); - if (unlikely ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc))) { fini (); return; } - } + if (!is_predef_encoding ()) + { + encoding = &StructAtOffsetOrNull (cff, topDict.EncodingOffset); + if (unlikely ((encoding == &Null (Encoding)) || !encoding->sanitize (&sc))) { fini (); return; } + } } } @@ -1212,53 +1212,53 @@ struct cff1 inline hb_codepoint_t glyph_to_code (hb_codepoint_t glyph) const { if (encoding != &Null(Encoding)) - return encoding->get_code (glyph); + return encoding->get_code (glyph); else { - hb_codepoint_t sid = glyph_to_sid (glyph); - if (sid == 0) return 0; - hb_codepoint_t code = 0; - switch (topDict.EncodingOffset) - { - case StandardEncoding: - code = lookup_standard_encoding_for_code (sid); - break; - case ExpertEncoding: - code = lookup_expert_encoding_for_code (sid); - break; - default: - break; - } - return code; + hb_codepoint_t sid = glyph_to_sid (glyph); + if (sid == 0) return 0; + hb_codepoint_t code = 0; + switch (topDict.EncodingOffset) + { + case StandardEncoding: + code = lookup_standard_encoding_for_code (sid); + break; + case ExpertEncoding: + code = lookup_expert_encoding_for_code (sid); + break; + default: + break; + } + return code; } } inline hb_codepoint_t glyph_to_sid (hb_codepoint_t glyph) const { if (charset != &Null(Charset)) - return charset->get_sid (glyph); + return charset->get_sid (glyph); else { - hb_codepoint_t sid = 0; - switch (topDict.CharsetOffset) - { - case ISOAdobeCharset: - if (glyph <= 228 /*zcaron*/) sid = glyph; - break; - case ExpertCharset: - sid = lookup_expert_charset_for_sid (glyph); - break; - case ExpertSubsetCharset: - sid = lookup_expert_subset_charset_for_sid (glyph); - break; - default: - break; - } - return sid; + hb_codepoint_t sid = 0; + switch (topDict.CharsetOffset) + { + case ISOAdobeCharset: + if (glyph <= 228 /*zcaron*/) sid = glyph; + break; + case ExpertCharset: + sid = lookup_expert_charset_for_sid (glyph); + break; + case ExpertSubsetCharset: + sid = lookup_expert_subset_charset_for_sid (glyph); + break; + default: + break; + } + return sid; } } - const Encoding *encoding; + const Encoding *encoding; private: typedef accelerator_templ_t SUPER; @@ -1290,9 +1290,9 @@ struct cff1 HB_INTERNAL static hb_codepoint_t lookup_standard_encoding_for_sid (hb_codepoint_t code); public: - FixedVersion version; /* Version of CFF table. set to 0x0100u */ + FixedVersion version; /* Version of CFF table. set to 0x0100u */ OffsetTo nameIndex; /* headerSize = Offset to Name INDEX. */ - HBUINT8 offSize; /* offset size (unused?) */ + HBUINT8 offSize; /* offset size (unused?) */ public: DEFINE_SIZE_STATIC (4); diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc index 4ea3252ef..b5c807c42 100644 --- a/src/hb-ot-cff2-table.cc +++ b/src/hb-ot-cff2-table.cc @@ -96,8 +96,8 @@ struct CFF2PathProcs_Extents : PathProcs {}; bool OT::cff2::accelerator_t::get_extents (hb_font_t *font, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const + hb_codepoint_t glyph, + hb_glyph_extents_t *extents) const { if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false; diff --git a/src/hb-ot-cff2-table.hh b/src/hb-ot-cff2-table.hh index aa0a0d277..3c4191cd9 100644 --- a/src/hb-ot-cff2-table.hh +++ b/src/hb-ot-cff2-table.hh @@ -56,11 +56,11 @@ struct CFF2FDSelect TRACE_SANITIZE (this); return_trace (likely (c->check_struct (this) && (format == 0 || format == 3 || format == 4) && - (format == 0)? - u.format0.sanitize (c, fdcount): - ((format == 3)? - u.format3.sanitize (c, fdcount): - u.format4.sanitize (c, fdcount)))); + (format == 0)? + u.format0.sanitize (c, fdcount): + ((format == 3)? + u.format3.sanitize (c, fdcount): + u.format4.sanitize (c, fdcount)))); } inline bool serialize (hb_serialize_context_t *c, const CFF2FDSelect &src, unsigned int num_glyphs) @@ -130,7 +130,7 @@ struct CFF2VariationStore inline unsigned int get_size (void) const { return HBUINT16::static_size + size; } - HBUINT16 size; + HBUINT16 size; VariationStore varStore; DEFINE_SIZE_MIN (2 + VariationStore::min_size); @@ -158,13 +158,13 @@ struct CFF2TopDictValues : TopDictValues<> OpCode op = get_value (i).op; switch (op) { - case OpCode_vstore: - case OpCode_FDSelect: - size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); - break; - default: - size += TopDictValues<>::calculate_serialized_op_size (get_value (i)); - break; + case OpCode_vstore: + case OpCode_FDSelect: + size += OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); + break; + default: + size += TopDictValues<>::calculate_serialized_op_size (get_value (i)); + break; } } return size; @@ -180,27 +180,27 @@ struct CFF2TopDictOpSet : TopDictOpSet<> { switch (op) { case OpCode_FontMatrix: - { - DictVal val; - val.init (); - dictval.add_op (op, env.substr); - env.clear_args (); - } - break; + { + DictVal val; + val.init (); + dictval.add_op (op, env.substr); + env.clear_args (); + } + break; case OpCode_vstore: - dictval.vstoreOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.vstoreOffset = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_FDSelect: - dictval.FDSelectOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + 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 */ - if (!env.argStack.is_empty ()) return; + SUPER::process_op (op, env, dictval); + /* Record this operand below if stack is empty, otherwise done */ + if (!env.argStack.is_empty ()) return; } if (unlikely (env.in_error ())) return; @@ -233,15 +233,15 @@ struct CFF2FontDictOpSet : DictOpSet { switch (op) { case OpCode_Private: - dictval.privateDictInfo.offset = env.argStack.pop_uint (); - dictval.privateDictInfo.size = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.privateDictInfo.offset = env.argStack.pop_uint (); + dictval.privateDictInfo.size = env.argStack.pop_uint (); + env.clear_args (); + break; default: - SUPER::process_op (op, env); - if (!env.argStack.is_empty ()) - return; + SUPER::process_op (op, env); + if (!env.argStack.is_empty ()) + return; } if (unlikely (env.in_error ())) return; @@ -274,9 +274,9 @@ struct CFF2PrivateDictValues_Base : DictValues unsigned int size = 0; for (unsigned int i = 0; i < DictValues::get_count; i++) if (DictValues::get_value (i).op == OpCode_Subrs) - size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); + size += OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Subrs); else - size += DictValues::get_value (i).str.len; + size += DictValues::get_value (i).str.len; return size; } @@ -307,11 +307,11 @@ struct CFF2PrivDictInterpEnv : NumInterpEnv } inline unsigned int get_ivs (void) const { return ivs; } - inline void set_ivs (unsigned int ivs_) { ivs = ivs_; } + inline void set_ivs (unsigned int ivs_) { ivs = ivs_; } protected: unsigned int ivs; - bool seen_vsindex; + bool seen_vsindex; }; struct CFF2PrivateDictOpSet : DictOpSet @@ -329,33 +329,33 @@ struct CFF2PrivateDictOpSet : DictOpSet case OpCode_BlueFuzz: case OpCode_ExpansionFactor: case OpCode_LanguageGroup: - val.single_val = env.argStack.pop_num (); - env.clear_args (); - break; + val.single_val = env.argStack.pop_num (); + env.clear_args (); + break; case OpCode_BlueValues: case OpCode_OtherBlues: case OpCode_FamilyBlues: case OpCode_FamilyOtherBlues: case OpCode_StemSnapH: case OpCode_StemSnapV: - env.clear_args (); - break; + env.clear_args (); + break; case OpCode_Subrs: - dictval.subrsOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; case OpCode_vsindexdict: - env.process_vsindex (); - dictval.ivs = env.get_ivs (); - env.clear_args (); - break; + env.process_vsindex (); + dictval.ivs = env.get_ivs (); + env.clear_args (); + break; case OpCode_blenddict: - break; + break; default: - DictOpSet::process_op (op, env); - if (!env.argStack.is_empty ()) return; - break; + DictOpSet::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -382,22 +382,22 @@ struct CFF2PrivateDictOpSet_Subset : DictOpSet case OpCode_StemSnapV: case OpCode_LanguageGroup: case OpCode_ExpansionFactor: - env.clear_args (); - break; + env.clear_args (); + break; case OpCode_blenddict: - env.clear_args (); - return; + env.clear_args (); + return; case OpCode_Subrs: - dictval.subrsOffset = env.argStack.pop_uint (); - env.clear_args (); - break; + dictval.subrsOffset = env.argStack.pop_uint (); + env.clear_args (); + break; default: - SUPER::process_op (op, env); - if (!env.argStack.is_empty ()) return; - break; + SUPER::process_op (op, env); + if (!env.argStack.is_empty ()) return; + break; } if (unlikely (env.in_error ())) return; @@ -420,13 +420,13 @@ using namespace CFF; struct cff2 { - static const hb_tag_t tableTag = HB_OT_TAG_cff2; + static const hb_tag_t tableTag = HB_OT_TAG_cff2; inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - likely (version.major == 2)); + likely (version.major == 2)); } template @@ -450,12 +450,12 @@ struct cff2 { fini (); return; } { /* parse top dict */ - ByteStr topDictStr (cff2 + cff2->topDict, cff2->topDictSize); - if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } - CFF2TopDict_Interpreter top_interp; - top_interp.env.init (topDictStr); - topDict.init (); - if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } + ByteStr topDictStr (cff2 + cff2->topDict, cff2->topDictSize); + if (unlikely (!topDictStr.sanitize (&sc))) { fini (); return; } + CFF2TopDict_Interpreter top_interp; + top_interp.env.init (topDictStr); + topDict.init (); + if (unlikely (!top_interp.interpret (topDict))) { fini (); return; } } globalSubrs = &StructAtOffset (cff2, cff2->topDict + cff2->topDictSize); @@ -465,9 +465,9 @@ struct cff2 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)) || - (((fdSelect != &Null(CFF2FDSelect)) && unlikely (!fdSelect->sanitize (&sc, fdArray->count))))) + (charStrings == &Null(CFF2CharStrings)) || unlikely (!charStrings->sanitize (&sc)) || + (fdArray == &Null(CFF2FDArray)) || unlikely (!fdArray->sanitize (&sc)) || + (((fdSelect != &Null(CFF2FDSelect)) && unlikely (!fdSelect->sanitize (&sc, fdArray->count))))) { fini (); return; } num_glyphs = charStrings->count; @@ -480,26 +480,26 @@ struct cff2 /* parse font dicts and gather private dicts */ for (unsigned int i = 0; i < fdCount; i++) { - const ByteStr fontDictStr = (*fdArray)[i]; - if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } - CFF2FontDictValues *font; - CFF2FontDict_Interpreter font_interp; - font_interp.env.init (fontDictStr); - font = fontDicts.push (); - font->init (); - if (unlikely (!font_interp.interpret (*font))) { fini (); return; } + const ByteStr fontDictStr = (*fdArray)[i]; + if (unlikely (!fontDictStr.sanitize (&sc))) { fini (); return; } + CFF2FontDictValues *font; + CFF2FontDict_Interpreter font_interp; + font_interp.env.init (fontDictStr); + font = fontDicts.push (); + font->init (); + if (unlikely (!font_interp.interpret (*font))) { fini (); return; } - const ByteStr privDictStr (StructAtOffsetOrNull (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); - if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } - DictInterpreter priv_interp; - priv_interp.env.init(privDictStr); - privateDicts[i].init (); - if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; } + const ByteStr privDictStr (StructAtOffsetOrNull (cff2, font->privateDictInfo.offset), font->privateDictInfo.size); + if (unlikely (!privDictStr.sanitize (&sc))) { fini (); return; } + DictInterpreter priv_interp; + priv_interp.env.init(privDictStr); + privateDicts[i].init (); + if (unlikely (!priv_interp.interpret (privateDicts[i]))) { fini (); return; } - privateDicts[i].localSubrs = &StructAtOffsetOrNull (privDictStr.str, privateDicts[i].subrsOffset); - if (privateDicts[i].localSubrs != &Null(CFF2Subrs) && - unlikely (!privateDicts[i].localSubrs->sanitize (&sc))) - { fini (); return; } + privateDicts[i].localSubrs = &StructAtOffsetOrNull (privDictStr.str, privateDicts[i].subrsOffset); + if (privateDicts[i].localSubrs != &Null(CFF2Subrs) && + unlikely (!privateDicts[i].localSubrs->sanitize (&sc))) + { fini (); return; } } } @@ -515,29 +515,29 @@ struct cff2 inline bool is_valid (void) const { return blob != nullptr; } protected: - hb_blob_t *blob; + hb_blob_t *blob; hb_sanitize_context_t sc; public: - CFF2TopDictValues topDict; - const CFF2Subrs *globalSubrs; + CFF2TopDictValues topDict; + const CFF2Subrs *globalSubrs; const CFF2VariationStore *varStore; const CFF2CharStrings *charStrings; - const CFF2FDArray *fdArray; - const CFF2FDSelect *fdSelect; - unsigned int fdCount; + const CFF2FDArray *fdArray; + const CFF2FDSelect *fdSelect; + unsigned int fdCount; hb_vector_t fontDicts; hb_vector_t privateDicts; - unsigned int num_glyphs; + unsigned int num_glyphs; }; struct accelerator_t : accelerator_templ_t { HB_INTERNAL bool get_extents (hb_font_t *font, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents) const; + hb_codepoint_t glyph, + hb_glyph_extents_t *extents) const; }; typedef accelerator_templ_t accelerator_subset_t; @@ -561,9 +561,9 @@ struct cff2 } public: - FixedVersion version; /* Version of CFF2 table. set to 0x0200u */ + FixedVersion version; /* Version of CFF2 table. set to 0x0200u */ OffsetTo topDict; /* headerSize = Offset to Top DICT. */ - HBUINT16 topDictSize; /* Top DICT size */ + HBUINT16 topDictSize; /* Top DICT size */ public: DEFINE_SIZE_STATIC (5); diff --git a/src/hb-subset-cff-common.cc b/src/hb-subset-cff-common.cc index 0b2100903..21501c6ac 100644 --- a/src/hb-subset-cff-common.cc +++ b/src/hb-subset-cff-common.cc @@ -44,13 +44,13 @@ using namespace CFF; bool hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, - unsigned int fdCount, - const FDSelect &src, /* IN */ - unsigned int &subset_fd_count /* OUT */, - unsigned int &subset_fdselect_size /* OUT */, - unsigned int &subset_fdselect_format /* OUT */, - hb_vector_t &fdselect_ranges /* OUT */, - Remap &fdmap /* OUT */) + unsigned int fdCount, + const FDSelect &src, /* IN */ + unsigned int &subset_fd_count /* OUT */, + unsigned int &subset_fdselect_size /* OUT */, + unsigned int &subset_fdselect_format /* OUT */, + hb_vector_t &fdselect_ranges /* OUT */, + Remap &fdmap /* OUT */) { subset_fd_count = 0; subset_fdselect_size = 0; @@ -74,10 +74,10 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, if (fd != prev_fd) { - num_ranges++; - prev_fd = fd; - code_pair pair = { fd, i }; - fdselect_ranges.push (pair); + num_ranges++; + prev_fd = fd; + code_pair pair = { fd, i }; + fdselect_ranges.push (pair); } } @@ -93,13 +93,13 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, /* create a fdmap */ if (!fdmap.reset (fdCount)) { - hb_set_destroy (set); - return false; + hb_set_destroy (set); + return false; } hb_codepoint_t fd = CFF_UNDEF_CODE; while (set->next (&fd)) - fdmap.add (fd); + fdmap.add (fd); assert (fdmap.get_count () == subset_fd_count); hb_set_destroy (set); } @@ -143,10 +143,10 @@ hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, template static inline bool serialize_fdselect_3_4 (hb_serialize_context_t *c, - const unsigned int num_glyphs, - const FDSelect &src, - unsigned int size, - const hb_vector_t &fdselect_ranges) + const unsigned int num_glyphs, + const FDSelect &src, + unsigned int size, + const hb_vector_t &fdselect_ranges) { TRACE_SERIALIZE (this); FDSELECT3_4 *p = c->allocate_size (size); @@ -167,12 +167,12 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c, **/ bool hb_serialize_cff_fdselect (hb_serialize_context_t *c, - const unsigned int num_glyphs, - const FDSelect &src, - unsigned int fd_count, - unsigned int fdselect_format, - unsigned int size, - const hb_vector_t &fdselect_ranges) + const unsigned int num_glyphs, + const FDSelect &src, + unsigned int fd_count, + unsigned int fdselect_format, + unsigned int size, + const hb_vector_t &fdselect_ranges) { TRACE_SERIALIZE (this); FDSelect *p = c->allocate_min (); @@ -191,12 +191,12 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, unsigned int fd = fdselect_ranges[range_index++].code; for (unsigned int i = 0; i < num_glyphs; i++) { - if ((range_index < fdselect_ranges.len) && - (i >= fdselect_ranges[range_index].glyph)) - { - fd = fdselect_ranges[range_index++].code; - } - p->fds[i].set (fd); + if ((range_index < fdselect_ranges.len) && + (i >= fdselect_ranges[range_index].glyph)) + { + fd = fdselect_ranges[range_index++].code; + } + p->fds[i].set (fd); } break; } @@ -204,17 +204,17 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c, case 3: return serialize_fdselect_3_4 (c, - num_glyphs, - src, - size, - fdselect_ranges); + num_glyphs, + src, + size, + fdselect_ranges); case 4: return serialize_fdselect_3_4 (c, - num_glyphs, - src, - size, - fdselect_ranges); + num_glyphs, + src, + size, + fdselect_ranges); default: assert(false); diff --git a/src/hb-subset-cff-common.hh b/src/hb-subset-cff-common.hh index b4a9bb792..bc18f1e97 100644 --- a/src/hb-subset-cff-common.hh +++ b/src/hb-subset-cff-common.hh @@ -57,26 +57,26 @@ struct StrEncoder if ((-1131 <= v) && (v <= 1131)) { if ((-107 <= v) && (v <= 107)) - encode_byte (v + 139); + encode_byte (v + 139); else if (v > 0) { - v -= 108; - encode_byte ((v >> 8) + OpCode_TwoBytePosInt0); - encode_byte (v & 0xFF); + v -= 108; + encode_byte ((v >> 8) + OpCode_TwoBytePosInt0); + encode_byte (v & 0xFF); } else { - v = -v - 108; - encode_byte ((v >> 8) + OpCode_TwoByteNegInt0); - encode_byte (v & 0xFF); + v = -v - 108; + encode_byte ((v >> 8) + OpCode_TwoByteNegInt0); + encode_byte (v & 0xFF); } } else { if (unlikely (v < -32768)) - v = -32768; + v = -32768; else if (unlikely (v > 32767)) - v = 32767; + v = 32767; encode_byte (OpCode_shortint); encode_byte ((v >> 8) & 0xFF); encode_byte (v & 0xFF); @@ -163,24 +163,24 @@ template struct CFFTopDict_OpSerializer : OpSerializer { inline bool serialize (hb_serialize_context_t *c, - const OPSTR &opstr, - const CFFSubTableOffsets &offsets) const + const OPSTR &opstr, + const CFFSubTableOffsets &offsets) const { TRACE_SERIALIZE (this); switch (opstr.op) { case OpCode_CharStrings: - return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.charStringsInfo.offset)); + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.charStringsInfo.offset)); case OpCode_FDArray: - return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDArrayInfo.offset)); + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDArrayInfo.offset)); case OpCode_FDSelect: - return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDSelectInfo.offset)); + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.FDSelectInfo.offset)); default: - return_trace (copy_opstr (c, opstr)); + return_trace (copy_opstr (c, opstr)); } return_trace (true); } @@ -192,10 +192,10 @@ struct CFFTopDict_OpSerializer : OpSerializer case OpCode_CharStrings: case OpCode_FDArray: case OpCode_FDSelect: - return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return opstr.str.len; + return opstr.str.len; } } }; @@ -203,8 +203,8 @@ struct CFFTopDict_OpSerializer : OpSerializer struct CFFFontDict_OpSerializer : OpSerializer { inline bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const TableInfo &privateDictInfo) const + const OpStr &opstr, + const TableInfo &privateDictInfo) const { TRACE_SERIALIZE (this); @@ -212,8 +212,8 @@ struct CFFFontDict_OpSerializer : OpSerializer { /* serialize the private dict size & offset as 2-byte & 4-byte integers */ if (unlikely (!UnsizedByteStr::serialize_int2 (c, privateDictInfo.size) || - !UnsizedByteStr::serialize_int4 (c, privateDictInfo.offset))) - return_trace (false); + !UnsizedByteStr::serialize_int4 (c, privateDictInfo.offset))) + return_trace (false); /* serialize the opcode */ HBUINT8 *p = c->allocate_size (1); @@ -246,8 +246,8 @@ struct CFFPrivateDict_OpSerializer : OpSerializer : desubroutinize (desubroutinize_), drop_hints (drop_hints_) {} inline bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const unsigned int subrsOffset) const + const OpStr &opstr, + const unsigned int subrsOffset) const { TRACE_SERIALIZE (this); @@ -256,25 +256,25 @@ struct CFFPrivateDict_OpSerializer : OpSerializer if (opstr.op == OpCode_Subrs) { if (desubroutinize || (subrsOffset == 0)) - return_trace (true); + return_trace (true); else - return_trace (FontDict::serialize_offset2_op (c, opstr.op, subrsOffset)); + return_trace (FontDict::serialize_offset2_op (c, opstr.op, subrsOffset)); } else return_trace (copy_opstr (c, opstr)); } inline unsigned int calculate_serialized_size (const OpStr &opstr, - bool has_localsubr=true) const + bool has_localsubr=true) const { if (drop_hints && DictOpSet::is_hint_op (opstr.op)) return 0; if (opstr.op == OpCode_Subrs) { if (desubroutinize || !has_localsubr) - return 0; + return 0; else - return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op); + return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (opstr.op); } else return opstr.str.len; @@ -288,15 +288,15 @@ struct CFFPrivateDict_OpSerializer : OpSerializer struct FlattenParam { StrBuff &flatStr; - bool drop_hints; + bool drop_hints; }; template struct SubrFlattener { inline SubrFlattener (const ACC &acc_, - const hb_vector_t &glyphs_, - bool drop_hints_) + const hb_vector_t &glyphs_, + bool drop_hints_) : acc (acc_), glyphs (glyphs_), drop_hints (drop_hints_) @@ -317,7 +317,7 @@ struct SubrFlattener interp.env.init (str, acc, fd); FlattenParam param = { flat_charstrings[i], drop_hints }; if (unlikely (!interp.interpret (param))) - return false; + return false; } return true; } @@ -349,7 +349,7 @@ struct SubrClosures { local_closures[i] = hb_set_create (); if (local_closures[i] == hb_set_get_empty ()) - valid = false; + valid = false; } } @@ -400,9 +400,9 @@ struct ParsedCSOp : OpStr unsigned int subr_num; protected: - bool drop_flag : 1; - bool keep_flag : 1; - bool skip_flag : 1; + bool drop_flag : 1; + bool keep_flag : 1; + bool skip_flag : 1; }; struct ParsedCStr : ParsedValues @@ -427,7 +427,7 @@ struct ParsedCStr : ParsedValues { unsigned int parsed_len = get_count (); if (likely (parsed_len > 0)) - values[parsed_len-1].set_skip (); + values[parsed_len-1].set_skip (); ParsedCSOp val; val.init (subr_num); @@ -445,7 +445,7 @@ struct ParsedCStr : ParsedValues inline bool at_end (unsigned int pos) const { return ((pos + 1 >= values.len) /* CFF2 */ - || (values[pos + 1].op == OpCode_return)); + || (values[pos + 1].op == OpCode_return)); } inline bool is_parsed (void) const { return parsed; } @@ -492,9 +492,9 @@ struct ParsedCStrs : hb_vector_t struct SubrSubsetParam { inline void init (ParsedCStr *parsed_charstring_, - ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_, - hb_set_t *global_closure_, hb_set_t *local_closure_, - bool drop_hints_) + ParsedCStrs *parsed_global_subrs_, ParsedCStrs *parsed_local_subrs_, + hb_set_t *global_closure_, hb_set_t *local_closure_, + bool drop_hints_) { parsed_charstring = parsed_charstring_; current_parsed_str = parsed_charstring; @@ -510,17 +510,17 @@ struct SubrSubsetParam switch (context.type) { case CSType_CharString: - return parsed_charstring; + return parsed_charstring; case CSType_LocalSubr: - if (likely (context.subr_num < parsed_local_subrs->len)) - return &(*parsed_local_subrs)[context.subr_num]; - break; + 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]; - break; + if (likely (context.subr_num < parsed_global_subrs->len)) + return &(*parsed_global_subrs)[context.subr_num]; + break; } return nullptr; } @@ -542,7 +542,7 @@ struct SubrSubsetParam ParsedCStrs *parsed_local_subrs; hb_set_t *global_closure; hb_set_t *local_closure; - bool drop_hints; + bool drop_hints; }; struct SubrRemap : Remap @@ -556,7 +556,7 @@ struct SubrRemap : Remap for (hb_codepoint_t old_num = 0; old_num < len; old_num++) { if (hb_set_has (closure, old_num)) - add (old_num); + add (old_num); } if (get_count () < 1240) @@ -619,7 +619,7 @@ struct SubrRemaps local_remaps.fini_deep (); } - SubrRemap global_remap; + SubrRemap global_remap; hb_vector_t local_remaps; }; @@ -683,12 +683,12 @@ struct SubrSubsetter SubrSubsetParam param; param.init (&parsed_charstrings[i], - &parsed_global_subrs, &parsed_local_subrs[fd], - closures.global_closure, closures.local_closures[fd], - drop_hints); + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); if (unlikely (!interp.interpret (param))) - return false; + return false; /* 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]); @@ -699,33 +699,33 @@ struct SubrSubsetter /* mark hint ops and arguments for drop */ for (unsigned int i = 0; i < glyphs.len; i++) { - unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); - SubrSubsetParam param; - param.init (&parsed_charstrings[i], - &parsed_global_subrs, &parsed_local_subrs[fd], - closures.global_closure, closures.local_closures[fd], - drop_hints); + unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); + SubrSubsetParam param; + param.init (&parsed_charstrings[i], + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); - DropHintsParam drop; - if (drop_hints_in_str (parsed_charstrings[i], param, drop)) - { - parsed_charstrings[i].set_hint_dropped (); - if (drop.vsindex_dropped) - parsed_charstrings[i].set_vsindex_dropped (); - } + DropHintsParam drop; + if (drop_hints_in_str (parsed_charstrings[i], param, drop)) + { + parsed_charstrings[i].set_hint_dropped (); + if (drop.vsindex_dropped) + parsed_charstrings[i].set_vsindex_dropped (); + } } /* after dropping hints recreate closures of actually used subrs */ closures.reset (); for (unsigned int i = 0; i < glyphs.len; i++) { - unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); - SubrSubsetParam param; - param.init (&parsed_charstrings[i], - &parsed_global_subrs, &parsed_local_subrs[fd], - closures.global_closure, closures.local_closures[fd], - drop_hints); - collect_subr_refs_in_str (parsed_charstrings[i], param); + unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); + SubrSubsetParam param; + param.init (&parsed_charstrings[i], + &parsed_global_subrs, &parsed_local_subrs[fd], + closures.global_closure, closures.local_closures[fd], + drop_hints); + collect_subr_refs_in_str (parsed_charstrings[i], param); } } @@ -742,7 +742,7 @@ struct SubrSubsetter { unsigned int fd = acc.fdSelect->get_fd (glyphs[i]); if (unlikely (!encode_str (parsed_charstrings[i], fd, buffArray[i]))) - return false; + return false; } return true; } @@ -758,8 +758,8 @@ struct SubrSubsetter hb_codepoint_t new_num = remap[old_num]; if (new_num != CFF_UNDEF_CODE) { - if (unlikely (!encode_str (subrs[old_num], fd, buffArray[new_num]))) - return false; + if (unlikely (!encode_str (subrs[old_num], fd, buffArray[new_num]))) + return false; } } return true; @@ -780,8 +780,8 @@ struct SubrSubsetter { inline DropHintsParam (void) : seen_moveto (false), - ends_in_hint (false), - vsindex_dropped (false) {} + ends_in_hint (false), + vsindex_dropped (false) {} bool seen_moveto; bool ends_in_hint; @@ -789,8 +789,8 @@ struct SubrSubsetter }; inline bool drop_hints_in_subr (ParsedCStr &str, unsigned int pos, - ParsedCStrs &subrs, unsigned int subr_num, - const SubrSubsetParam ¶m, DropHintsParam &drop) + ParsedCStrs &subrs, unsigned int subr_num, + const SubrSubsetParam ¶m, DropHintsParam &drop) { drop.ends_in_hint = false; bool has_hint = drop_hints_in_str (subrs[subr_num], param, drop); @@ -803,7 +803,7 @@ struct SubrSubsetter /* if this subr call is at the end of the parent subr, propagate the flag * otherwise reset the flag */ if (!str.at_end (pos)) - drop.ends_in_hint = false; + drop.ends_in_hint = false; } return has_hint; @@ -819,64 +819,64 @@ struct SubrSubsetter bool has_hint = false; switch (str.values[pos].op) { - case OpCode_callsubr: - has_hint = drop_hints_in_subr (str, pos, - *param.parsed_local_subrs, str.values[pos].subr_num, - param, drop); + case OpCode_callsubr: + has_hint = drop_hints_in_subr (str, pos, + *param.parsed_local_subrs, str.values[pos].subr_num, + param, drop); - break; + break; - case OpCode_callgsubr: - has_hint = drop_hints_in_subr (str, pos, - *param.parsed_global_subrs, str.values[pos].subr_num, - param, drop); - break; + case OpCode_callgsubr: + has_hint = drop_hints_in_subr (str, pos, + *param.parsed_global_subrs, str.values[pos].subr_num, + param, drop); + break; - case OpCode_rmoveto: - case OpCode_hmoveto: - case OpCode_vmoveto: - drop.seen_moveto = true; - break; + case OpCode_rmoveto: + case OpCode_hmoveto: + case OpCode_vmoveto: + drop.seen_moveto = true; + break; - case OpCode_hintmask: - case OpCode_cntrmask: - if (drop.seen_moveto) - { - str.values[pos].set_drop (); - break; - } - HB_FALLTHROUGH; + case OpCode_hintmask: + case OpCode_cntrmask: + if (drop.seen_moveto) + { + str.values[pos].set_drop (); + break; + } + HB_FALLTHROUGH; - case OpCode_hstemhm: - case OpCode_vstemhm: - case OpCode_hstem: - case OpCode_vstem: - has_hint = true; - str.values[pos].set_drop (); - if (str.at_end (pos)) - drop.ends_in_hint = true; - break; + case OpCode_hstemhm: + case OpCode_vstemhm: + case OpCode_hstem: + case OpCode_vstem: + has_hint = true; + str.values[pos].set_drop (); + if (str.at_end (pos)) + drop.ends_in_hint = true; + break; - case OpCode_dotsection: - str.values[pos].set_drop (); - break; + case OpCode_dotsection: + str.values[pos].set_drop (); + break; - default: - /* NONE */ - break; + default: + /* NONE */ + break; } if (has_hint) { - for (int i = pos - 1; i >= 0; i--) - { - ParsedCSOp &csop = str.values[(unsigned)i]; - if (csop.for_drop ()) - break; - csop.set_drop (); - if (csop.op == OpCode_vsindexcs) - drop.vsindex_dropped = true; - } - seen_hint |= has_hint; + for (int i = pos - 1; i >= 0; i--) + { + ParsedCSOp &csop = str.values[(unsigned)i]; + if (csop.for_drop ()) + break; + csop.set_drop (); + if (csop.op == OpCode_vsindexcs) + drop.vsindex_dropped = true; + } + seen_hint |= has_hint; } } @@ -884,9 +884,9 @@ struct SubrSubsetter } inline void collect_subr_refs_in_subr (ParsedCStr &str, unsigned int pos, - unsigned int subr_num, ParsedCStrs &subrs, - hb_set_t *closure, - const SubrSubsetParam ¶m) + unsigned int subr_num, ParsedCStrs &subrs, + hb_set_t *closure, + const SubrSubsetParam ¶m) { hb_set_add (closure, subr_num); collect_subr_refs_in_str (subrs[subr_num], param); @@ -898,22 +898,22 @@ struct SubrSubsetter { if (!str.values[pos].for_drop ()) { - switch (str.values[pos].op) - { - case OpCode_callsubr: - collect_subr_refs_in_subr (str, pos, - str.values[pos].subr_num, *param.parsed_local_subrs, - param.local_closure, param); - break; + switch (str.values[pos].op) + { + case OpCode_callsubr: + collect_subr_refs_in_subr (str, pos, + str.values[pos].subr_num, *param.parsed_local_subrs, + param.local_closure, param); + break; - case OpCode_callgsubr: - collect_subr_refs_in_subr (str, pos, - str.values[pos].subr_num, *param.parsed_global_subrs, - param.global_closure, param); - break; + case OpCode_callgsubr: + collect_subr_refs_in_subr (str, pos, + str.values[pos].subr_num, *param.parsed_global_subrs, + param.global_closure, param); + break; - default: break; - } + default: break; + } } } } @@ -929,42 +929,42 @@ struct SubrSubsetter { encoder.encode_num (str.prefix_num ()); if (str.prefix_op () != OpCode_Invalid) - encoder.encode_op (str.prefix_op ()); + encoder.encode_op (str.prefix_op ()); } for (unsigned int i = 0; i < str.get_count(); i++) { const ParsedCSOp &opstr = str.values[i]; if (!opstr.for_drop () && !opstr.for_skip ()) { - switch (opstr.op) - { - case OpCode_callsubr: - encoder.encode_int (remaps.local_remaps[fd].biased_num (opstr.subr_num)); - encoder.encode_op (OpCode_callsubr); - break; + switch (opstr.op) + { + case OpCode_callsubr: + 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); - break; + case OpCode_callgsubr: + encoder.encode_int (remaps.global_remap.biased_num (opstr.subr_num)); + encoder.encode_op (OpCode_callgsubr); + break; - default: - encoder.copy_str (opstr.str); - break; - } + default: + encoder.copy_str (opstr.str); + break; + } } } return !encoder.is_error (); } protected: - SubrClosures closures; + SubrClosures closures; - ParsedCStrs parsed_charstrings; - ParsedCStrs parsed_global_subrs; + ParsedCStrs parsed_charstrings; + ParsedCStrs parsed_global_subrs; hb_vector_t parsed_local_subrs; - SubrRemaps remaps; + SubrRemaps remaps; private: typedef typename SUBRS::count_type subr_count_type; @@ -973,21 +973,21 @@ struct SubrSubsetter HB_INTERNAL bool hb_plan_subset_cff_fdselect (const hb_vector_t &glyphs, - unsigned int fdCount, - const CFF::FDSelect &src, /* IN */ - unsigned int &subset_fd_count /* OUT */, - unsigned int &subset_fdselect_size /* OUT */, - unsigned int &subset_fdselect_format /* OUT */, - hb_vector_t &fdselect_ranges /* OUT */, - CFF::Remap &fdmap /* OUT */); + unsigned int fdCount, + const CFF::FDSelect &src, /* IN */ + unsigned int &subset_fd_count /* OUT */, + unsigned int &subset_fdselect_size /* OUT */, + unsigned int &subset_fdselect_format /* OUT */, + hb_vector_t &fdselect_ranges /* OUT */, + CFF::Remap &fdmap /* OUT */); HB_INTERNAL bool hb_serialize_cff_fdselect (hb_serialize_context_t *c, - unsigned int num_glyphs, - const CFF::FDSelect &src, - unsigned int fd_count, - unsigned int fdselect_format, - unsigned int size, - const hb_vector_t &fdselect_ranges); + unsigned int num_glyphs, + const CFF::FDSelect &src, + unsigned int fd_count, + unsigned int fdselect_format, + unsigned int size, + const hb_vector_t &fdselect_ranges); #endif /* HB_SUBSET_CFF_COMMON_HH */ diff --git a/src/hb-subset-cff1.cc b/src/hb-subset-cff1.cc index dc4d12340..53e7b2288 100644 --- a/src/hb-subset-cff1.cc +++ b/src/hb-subset-cff1.cc @@ -119,20 +119,20 @@ struct CFF1TopDictValuesMod : CFF1TopDictValues struct TopDictModifiers { inline TopDictModifiers (const CFF1SubTableOffsets &offsets_, - const unsigned int (&nameSIDs_)[NameDictValues::ValCount]) + const unsigned int (&nameSIDs_)[NameDictValues::ValCount]) : offsets (offsets_), nameSIDs (nameSIDs_) {} const CFF1SubTableOffsets &offsets; - const unsigned int (&nameSIDs)[NameDictValues::ValCount]; + const unsigned int (&nameSIDs)[NameDictValues::ValCount]; }; struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer { inline bool serialize (hb_serialize_context_t *c, - const CFF1TopDictVal &opstr, - const TopDictModifiers &mod) const + const CFF1TopDictVal &opstr, + const TopDictModifiers &mod) const { TRACE_SERIALIZE (this); @@ -140,22 +140,22 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer switch (op) { case OpCode_charset: - return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.charsetInfo.offset)); + return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.charsetInfo.offset)); case OpCode_Encoding: - return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.encodingOffset)); + return_trace (FontDict::serialize_offset4_op(c, op, mod.offsets.encodingOffset)); case OpCode_Private: - { - if (unlikely (!UnsizedByteStr::serialize_int2 (c, mod.offsets.privateDictInfo.size))) - return_trace (false); - if (unlikely (!UnsizedByteStr::serialize_int4 (c, mod.offsets.privateDictInfo.offset))) - return_trace (false); - HBUINT8 *p = c->allocate_size (1); - if (unlikely (p == nullptr)) return_trace (false); - p->set (OpCode_Private); - } - break; + { + if (unlikely (!UnsizedByteStr::serialize_int2 (c, mod.offsets.privateDictInfo.size))) + return_trace (false); + if (unlikely (!UnsizedByteStr::serialize_int4 (c, mod.offsets.privateDictInfo.offset))) + return_trace (false); + HBUINT8 *p = c->allocate_size (1); + if (unlikely (p == nullptr)) return_trace (false); + p->set (OpCode_Private); + } + break; case OpCode_version: case OpCode_Notice: @@ -166,23 +166,23 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer case OpCode_PostScript: case OpCode_BaseFontName: case OpCode_FontName: - return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[NameDictValues::name_op_to_index (op)])); + return_trace (FontDict::serialize_offset2_op(c, op, mod.nameSIDs[NameDictValues::name_op_to_index (op)])); case OpCode_ROS: - { - /* for registry & ordering, reassigned SIDs are serialized - * for supplement, the original byte string is copied along with the op code */ - OpStr supp_op; - supp_op.op = op; - supp_op.str.str = opstr.str.str + opstr.last_arg_offset; - assert (opstr.str.len >= opstr.last_arg_offset + 3); - supp_op.str.len = opstr.str.len - opstr.last_arg_offset; - return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::registry]) && - UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) && - copy_opstr (c, supp_op)); - } + { + /* for registry & ordering, reassigned SIDs are serialized + * for supplement, the original byte string is copied along with the op code */ + OpStr supp_op; + supp_op.op = op; + supp_op.str.str = opstr.str.str + opstr.last_arg_offset; + assert (opstr.str.len >= opstr.last_arg_offset + 3); + supp_op.str.len = opstr.str.len - opstr.last_arg_offset; + return_trace (UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::registry]) && + UnsizedByteStr::serialize_int2 (c, mod.nameSIDs[NameDictValues::ordering]) && + copy_opstr (c, supp_op)); + } default: - return_trace (CFFTopDict_OpSerializer::serialize (c, opstr, mod.offsets)); + return_trace (CFFTopDict_OpSerializer::serialize (c, opstr, mod.offsets)); } return_trace (true); } @@ -194,10 +194,10 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer { case OpCode_charset: case OpCode_Encoding: - return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (op); + 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); + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (OpCode_Private); case OpCode_version: case OpCode_Notice: @@ -208,13 +208,13 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer case OpCode_PostScript: case OpCode_BaseFontName: case OpCode_FontName: - return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op); + return OpCode_Size (OpCode_shortint) + 2 + OpCode_Size (op); case OpCode_ROS: - return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.len - opstr.last_arg_offset)/* supplement + op */; + return ((OpCode_Size (OpCode_shortint) + 2) * 2) + (opstr.str.len - opstr.last_arg_offset)/* supplement + op */; default: - return CFFTopDict_OpSerializer::calculate_serialized_size (opstr); + return CFFTopDict_OpSerializer::calculate_serialized_size (opstr); } } }; @@ -222,8 +222,8 @@ struct CFF1TopDict_OpSerializer : CFFTopDict_OpSerializer struct FontDictValuesMod { inline void init (const CFF1FontDictValues *base_, - unsigned int fontName_, - const TableInfo &privateDictInfo_) + unsigned int fontName_, + const TableInfo &privateDictInfo_) { base = base_; fontName = fontName_; @@ -238,15 +238,15 @@ struct FontDictValuesMod inline const OpStr &operator [] (unsigned int i) const { return (*base)[i]; } const CFF1FontDictValues *base; - TableInfo privateDictInfo; - unsigned int fontName; + TableInfo privateDictInfo; + unsigned int fontName; }; struct CFF1FontDict_OpSerializer : CFFFontDict_OpSerializer { inline bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const FontDictValuesMod &mod) const + const OpStr &opstr, + const FontDictValuesMod &mod) const { TRACE_SERIALIZE (this); @@ -284,16 +284,16 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet case OpCode_hintmask: case OpCode_cntrmask: case OpCode_dotsection: - if (param.drop_hints) - { - env.clear_args (); - return; - } - HB_FALLTHROUGH; + if (param.drop_hints) + { + env.clear_args (); + return; + } + HB_FALLTHROUGH; default: - SUPER::flush_args_and_op (op, env, param); - break; + SUPER::flush_args_and_op (op, env, param); + break; } } static inline void flush_args (CFF1CSInterpEnv &env, FlattenParam& param) @@ -324,7 +324,7 @@ struct CFF1CSOpSet_Flatten : CFF1CSOpSet { StrEncoder encoder (param.flatStr); for (unsigned int i = 0; i < env.hintmask_size; i++) - encoder.encode_byte (env.substr[i]); + encoder.encode_byte (env.substr[i]); } } @@ -343,7 +343,7 @@ struct RangeList : hb_vector_t code_pair &pair = (*this)[i - 1]; unsigned int nLeft = last_glyph - pair.glyph - 1; if (nLeft >= 0x100) - two_byte = true; + two_byte = true; last_glyph = pair.glyph; pair.glyph = nLeft; } @@ -358,37 +358,37 @@ struct CFF1CSOpSet_SubrSubset : CFF1CSOpSetadd_op (op, env.substr); - param.current_parsed_str->set_parsed (); - env.returnFromSubr (); - param.set_current_str (env); - break; + param.current_parsed_str->add_op (op, env.substr); + param.current_parsed_str->set_parsed (); + env.returnFromSubr (); + param.set_current_str (env); + break; case OpCode_endchar: - param.current_parsed_str->add_op (op, env.substr); - param.current_parsed_str->set_parsed (); - SUPER::process_op (op, env, param); - break; + param.current_parsed_str->add_op (op, env.substr); + param.current_parsed_str->set_parsed (); + SUPER::process_op (op, env, param); + break; case OpCode_callsubr: - process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); - break; + process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); + break; case OpCode_callgsubr: - process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); - break; + process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); + break; default: - SUPER::process_op (op, env, param); - param.current_parsed_str->add_op (op, env.substr); - break; + SUPER::process_op (op, env, param); + param.current_parsed_str->add_op (op, env.substr); + break; } } protected: static inline void process_call_subr (OpCode op, CSType type, - CFF1CSInterpEnv &env, SubrSubsetParam& param, - CFF1BiasedSubrs& subrs, hb_set_t *closure) + CFF1CSInterpEnv &env, SubrSubsetParam& param, + CFF1BiasedSubrs& subrs, hb_set_t *closure) { SubByteStr substr = env.substr; env.callSubr (subrs, type); @@ -417,9 +417,9 @@ struct CFF1SubrSubsetter : SubrSubsetterset_parsed (); + parsed_str->set_parsed (); else - env.set_error (); + env.set_error (); } } }; @@ -487,27 +487,27 @@ struct cff_subset_plan { code = acc.glyph_to_code (orig_glyph); if (code == CFF_UNDEF_CODE) { - subset_enc_num_codes = glyph - 1; - break; + subset_enc_num_codes = glyph - 1; + break; } if (code != last_code + 1) { - code_pair pair = { code, glyph }; - subset_enc_code_ranges.push (pair); + code_pair pair = { code, glyph }; + subset_enc_code_ranges.push (pair); } last_code = code; if (encoding != &Null(Encoding)) { - hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph); - encoding->get_supplement_codes (sid, supp_codes); - for (unsigned int i = 0; i < supp_codes.len; i++) - { - code_pair pair = { supp_codes[i], sid }; - subset_enc_supp_codes.push (pair); - } - supp_size += SuppEncoding::static_size * supp_codes.len; + hb_codepoint_t sid = acc.glyph_to_sid (orig_glyph); + encoding->get_supplement_codes (sid, supp_codes); + for (unsigned int i = 0; i < supp_codes.len; i++) + { + code_pair pair = { supp_codes[i], sid }; + subset_enc_supp_codes.push (pair); + } + supp_size += SuppEncoding::static_size * supp_codes.len; } } supp_codes.fini (); @@ -524,9 +524,9 @@ struct cff_subset_plan { subset_enc_format = 1; return Encoding::calculate_serialized_size ( - subset_enc_format, - subset_enc_format? subset_enc_code_ranges.len: subset_enc_num_codes, - subset_enc_supp_codes.len); + subset_enc_format, + subset_enc_format? subset_enc_code_ranges.len: subset_enc_num_codes, + subset_enc_supp_codes.len); } inline unsigned int plan_subset_charset (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan) @@ -542,12 +542,12 @@ struct cff_subset_plan { sid = acc.glyph_to_sid (orig_glyph); if (!acc.is_CID ()) - sid = sidmap.add (sid); + sid = sidmap.add (sid); if (sid != last_sid + 1) { - code_pair pair = { sid, glyph }; - subset_charset_ranges.push (pair); + code_pair pair = { sid, glyph }; + subset_charset_ranges.push (pair); } last_sid = sid; } @@ -568,8 +568,8 @@ struct cff_subset_plan { subset_charset_format = 2; return Charset::calculate_serialized_size ( - subset_charset_format, - subset_charset_format? subset_charset_ranges.len: plan->glyphs.len); + subset_charset_format, + subset_charset_format? subset_charset_ranges.len: plan->glyphs.len); } inline bool collect_sids_in_dicts (const OT::cff1::accelerator_subset_t &acc) @@ -582,21 +582,21 @@ struct cff_subset_plan { unsigned int sid = acc.topDict.nameSIDs[i]; if (sid != CFF_UNDEF_SID) { - (void)sidmap.add (sid); - topDictModSIDs[i] = sidmap[sid]; + (void)sidmap.add (sid); + topDictModSIDs[i] = sidmap[sid]; } } if (acc.fdArray != &Null(CFF1FDArray)) for (unsigned int i = 0; i < orig_fdcount; i++) - if (fdmap.includes (i)) - (void)sidmap.add (acc.fontDicts[i].fontName); + if (fdmap.includes (i)) + (void)sidmap.add (acc.fontDicts[i].fontName); return true; } inline bool create (const OT::cff1::accelerator_subset_t &acc, - hb_subset_plan_t *plan) + hb_subset_plan_t *plan) { /* make sure notdef is first */ if ((plan->glyphs.len == 0) || (plan->glyphs[0] != 0)) return false; @@ -612,8 +612,8 @@ struct cff_subset_plan { for (unsigned int glyph = 0; glyph < plan->glyphs.len; glyph++) { if (plan->glyphs[glyph] != glyph) { - gid_renum = true; - break; + gid_renum = true; + break; } } @@ -635,32 +635,32 @@ struct cff_subset_plan { bool need_to_add_set = (subset_charset && !acc.topDict.has_op (OpCode_charset)); if (need_to_add_enc || need_to_add_set) { - if (need_to_add_enc) - topdict_mod.add_op (OpCode_Encoding); - if (need_to_add_set) - topdict_mod.add_op (OpCode_charset); + if (need_to_add_enc) + topdict_mod.add_op (OpCode_Encoding); + if (need_to_add_set) + topdict_mod.add_op (OpCode_charset); } offsets.topDictInfo.offset = final_size; CFF1TopDict_OpSerializer topSzr; unsigned int topDictSize = TopDict::calculate_serialized_size (topdict_mod, topSzr); offsets.topDictInfo.offSize = calcOffSize(topDictSize); final_size += CFF1IndexOf::calculate_serialized_size - (offsets.topDictInfo.offSize, - &topdict_mod, 1, topdict_sizes, topSzr); + (offsets.topDictInfo.offSize, + &topdict_mod, 1, topdict_sizes, topSzr); } /* Determine re-mapping of font index as fdmap among other info */ if (acc.fdSelect != &Null(CFF1FDSelect)) { - if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, - orig_fdcount, - *acc.fdSelect, - subset_fdcount, - offsets.FDSelectInfo.size, - subset_fdselect_format, - subset_fdselect_ranges, - fdmap))) - return false; + if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, + orig_fdcount, + *acc.fdSelect, + subset_fdcount, + offsets.FDSelectInfo.size, + subset_fdselect_format, + subset_fdselect_ranges, + fdmap))) + return false; } else fdmap.identity (1); @@ -669,10 +669,10 @@ struct cff_subset_plan { { /* SIDs for name strings in dicts are added before glyph names so they fit in 16-bit int range */ if (unlikely (!collect_sids_in_dicts (acc))) - return false; + return false; assert (sidmap.get_count () <= 0x8000); if (subset_charset) - offsets.charsetInfo.size = plan_subset_charset (acc, plan); + offsets.charsetInfo.size = plan_subset_charset (acc, plan); topdict_mod.reassignSIDs (sidmap); } @@ -688,9 +688,9 @@ struct cff_subset_plan { { /* Flatten global & local subrs */ SubrFlattener - flattener(acc, plan->glyphs, plan->drop_hints); + flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) - return false; + return false; /* no global/local subroutines */ offsets.globalSubrsInfo.size = CFF1Subrs::calculate_serialized_size (1, 0, 0); @@ -699,14 +699,14 @@ struct cff_subset_plan { { /* Subset subrs: collect used subroutines, leaving all unused ones behind */ if (!subr_subsetter.subset (acc, plan->glyphs, plan->drop_hints)) - return false; + return false; /* encode charstrings, global subrs, local subrs with new subroutine numbers */ if (!subr_subsetter.encode_charstrings (acc, plan->glyphs, subset_charstrings)) - return false; + return false; if (!subr_subsetter.encode_globalsubrs (subset_globalsubrs)) - return false; + return false; /* global subrs */ unsigned int dataSize = subset_globalsubrs.total_size (); @@ -715,26 +715,26 @@ struct cff_subset_plan { /* local subrs */ if (!offsets.localSubrsInfos.resize (orig_fdcount)) - return false; + return false; if (!subset_localsubrs.resize (orig_fdcount)) - return false; + return false; for (unsigned int fd = 0; fd < orig_fdcount; fd++) { - subset_localsubrs[fd].init (); - offsets.localSubrsInfos[fd].init (); - if (fdmap.includes (fd)) - { - if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) - return false; + subset_localsubrs[fd].init (); + offsets.localSubrsInfos[fd].init (); + if (fdmap.includes (fd)) + { + if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) + return false; - unsigned int dataSize = subset_localsubrs[fd].total_size (); - if (dataSize > 0) - { - offsets.localSubrsInfos[fd].offset = final_size; - offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); - offsets.localSubrsInfos[fd].size = CFF1Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); - } - } + unsigned int dataSize = subset_localsubrs[fd].total_size (); + if (dataSize > 0) + { + offsets.localSubrsInfos[fd].offset = final_size; + offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); + offsets.localSubrsInfos[fd].size = CFF1Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); + } + } } } @@ -771,8 +771,8 @@ struct cff_subset_plan { CFF1FontDict_OpSerializer fontSzr; unsigned int dictsSize = 0; for (unsigned int i = 0; i < acc.fontDicts.len; i++) - if (fdmap.includes (i)) - dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); + if (fdmap.includes (i)) + dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); offsets.FDArrayInfo.offSize = calcOffSize (dictsSize); final_size += CFF1Index::calculate_serialized_size (offsets.FDArrayInfo.offSize, subset_fdcount, dictsSize); @@ -792,23 +792,23 @@ struct cff_subset_plan { { if (fdmap.includes (i)) { - bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; - CFFPrivateDict_OpSerializer privSzr (desubroutinize, plan->drop_hints); - unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); - TableInfo privInfo = { final_size, priv_size, 0 }; - FontDictValuesMod fontdict_mod; - if (!acc.is_CID ()) - fontdict_mod.init ( &Null(CFF1FontDictValues), CFF_UNDEF_SID, privInfo ); - else - fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo ); - fontdicts_mod.push (fontdict_mod); - final_size += privInfo.size; + bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; + CFFPrivateDict_OpSerializer privSzr (desubroutinize, plan->drop_hints); + unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); + TableInfo privInfo = { final_size, priv_size, 0 }; + FontDictValuesMod fontdict_mod; + if (!acc.is_CID ()) + fontdict_mod.init ( &Null(CFF1FontDictValues), CFF_UNDEF_SID, privInfo ); + else + fontdict_mod.init ( &acc.fontDicts[i], sidmap[acc.fontDicts[i].fontName], privInfo ); + fontdicts_mod.push (fontdict_mod); + final_size += privInfo.size; - if (!plan->desubroutinize && has_localsubrs) - { - offsets.localSubrsInfos[i].offset = final_size; - final_size += offsets.localSubrsInfos[i].size; - } + if (!plan->desubroutinize && has_localsubrs) + { + offsets.localSubrsInfos[i].offset = final_size; + final_size += offsets.localSubrsInfos[i].size; + } } } @@ -816,12 +816,12 @@ struct cff_subset_plan { offsets.privateDictInfo = fontdicts_mod[0].privateDictInfo; return ((subset_charstrings.len == plan->glyphs.len) - && (fontdicts_mod.len == subset_fdcount)); + && (fontdicts_mod.len == subset_fdcount)); } inline unsigned int get_final_size (void) const { return final_size; } - unsigned int final_size; + unsigned int final_size; hb_vector_t topdict_sizes; CFF1TopDictValuesMod topdict_mod; CFF1SubTableOffsets offsets; @@ -836,36 +836,36 @@ struct cff_subset_plan { * set to CFF_UNDEF_CODE if excluded from subset */ Remap fdmap; - StrBuffArray subset_charstrings; - StrBuffArray subset_globalsubrs; + StrBuffArray subset_charstrings; + StrBuffArray subset_globalsubrs; hb_vector_t subset_localsubrs; hb_vector_t fontdicts_mod; - bool drop_hints; + bool drop_hints; - bool gid_renum; - bool subset_encoding; - uint8_t subset_enc_format; - unsigned int subset_enc_num_codes; - RangeList subset_enc_code_ranges; + bool gid_renum; + bool subset_encoding; + uint8_t subset_enc_format; + unsigned int subset_enc_num_codes; + RangeList subset_enc_code_ranges; hb_vector_t subset_enc_supp_codes; - uint8_t subset_charset_format; - RangeList subset_charset_ranges; - bool subset_charset; + uint8_t subset_charset_format; + RangeList subset_charset_ranges; + bool subset_charset; - RemapSID sidmap; - unsigned int topDictModSIDs[NameDictValues::ValCount]; + RemapSID sidmap; + unsigned int topDictModSIDs[NameDictValues::ValCount]; - bool desubroutinize; + bool desubroutinize; CFF1SubrSubsetter subr_subsetter; }; static inline bool _write_cff1 (const cff_subset_plan &plan, - const OT::cff1::accelerator_subset_t &acc, - const hb_vector_t& glyphs, - unsigned int dest_sz, - void *dest) + const OT::cff1::accelerator_subset_t &acc, + const hb_vector_t& glyphs, + unsigned int dest_sz, + void *dest) { hb_serialize_context_t c (dest, dest_sz); @@ -902,8 +902,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, CFF1TopDict_OpSerializer topSzr; TopDictModifiers modifier (plan.offsets, plan.topDictModSIDs); if (unlikely (!dest->serialize (&c, plan.offsets.topDictInfo.offSize, - &plan.topdict_mod, 1, - plan.topdict_sizes, topSzr, modifier))) + &plan.topdict_mod, 1, + plan.topdict_sizes, topSzr, modifier))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF top dict"); return false; @@ -943,10 +943,10 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, Encoding *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, - plan.subset_enc_format, - plan.subset_enc_num_codes, - plan.subset_enc_code_ranges, - plan.subset_enc_supp_codes))) + plan.subset_enc_format, + plan.subset_enc_num_codes, + plan.subset_enc_code_ranges, + plan.subset_enc_supp_codes))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize Encoding"); return false; @@ -960,9 +960,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, Charset *dest = c.start_embed (); if (unlikely (dest == nullptr)) return false; if (unlikely (!dest->serialize (&c, - plan.subset_charset_format, - plan.num_glyphs, - plan.subset_charset_ranges))) + plan.subset_charset_format, + plan.num_glyphs, + plan.subset_charset_ranges))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize Charset"); return false; @@ -975,8 +975,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, 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))) + plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, + plan.subset_fdselect_ranges))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF subset FDSelect"); return false; @@ -991,8 +991,8 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, if (unlikely (fda == nullptr)) return false; CFF1FontDict_OpSerializer fontSzr; if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, - plan.fontdicts_mod, - fontSzr))) + plan.fontdicts_mod, + fontSzr))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF FDArray"); return false; @@ -1027,18 +1027,18 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); if (unlikely (!result)) { - DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); - return false; + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); + return false; } if (plan.offsets.localSubrsInfos[i].size > 0) { - CFF1Subrs *dest = c.start_embed (); - if (unlikely (dest == nullptr)) return false; - if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) - { - DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); - return false; - } + CFF1Subrs *dest = c.start_embed (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); + return false; + } } } } @@ -1051,9 +1051,9 @@ static inline bool _write_cff1 (const cff_subset_plan &plan, static bool _hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc, - const char *data, - hb_subset_plan_t *plan, - hb_blob_t **prime /* OUT */) + const char *data, + hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) { cff_subset_plan cff_plan; @@ -1067,17 +1067,17 @@ _hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc, char *cff_prime_data = (char *) calloc (1, cff_prime_size); 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."); free (cff_prime_data); return false; } *prime = hb_blob_create (cff_prime_data, - cff_prime_size, - HB_MEMORY_MODE_READONLY, - cff_prime_data, - free); + cff_prime_size, + HB_MEMORY_MODE_READONLY, + cff_prime_data, + free); return true; } @@ -1089,7 +1089,7 @@ _hb_subset_cff1 (const OT::cff1::accelerator_subset_t &acc, **/ bool 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 (plan->source); const char *data = hb_blob_get_data(cff_blob, nullptr); @@ -1097,7 +1097,7 @@ hb_subset_cff1 (hb_subset_plan_t *plan, OT::cff1::accelerator_subset_t acc; acc.init(plan->source); bool result = likely (acc.is_valid ()) && - _hb_subset_cff1 (acc, data, plan, prime); + _hb_subset_cff1 (acc, data, plan, prime); hb_blob_destroy (cff_blob); acc.fini (); diff --git a/src/hb-subset-cff1.hh b/src/hb-subset-cff1.hh index 33a66380a..1ec867884 100644 --- a/src/hb-subset-cff1.hh +++ b/src/hb-subset-cff1.hh @@ -33,6 +33,6 @@ HB_INTERNAL bool hb_subset_cff1 (hb_subset_plan_t *plan, - hb_blob_t **cff_prime /* OUT */); + hb_blob_t **cff_prime /* OUT */); #endif /* HB_SUBSET_CFF1_HH */ diff --git a/src/hb-subset-cff2.cc b/src/hb-subset-cff2.cc index 64c5a243c..463ca2b76 100644 --- a/src/hb-subset-cff2.cc +++ b/src/hb-subset-cff2.cc @@ -47,18 +47,18 @@ struct CFF2SubTableOffsets : CFFSubTableOffsets struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> { inline bool serialize (hb_serialize_context_t *c, - const OpStr &opstr, - const CFF2SubTableOffsets &offsets) const + const OpStr &opstr, + const CFF2SubTableOffsets &offsets) const { TRACE_SERIALIZE (this); switch (opstr.op) { case OpCode_vstore: - return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset)); + return_trace (FontDict::serialize_offset4_op(c, opstr.op, offsets.varStoreOffset)); default: - return_trace (CFFTopDict_OpSerializer<>::serialize (c, opstr, offsets)); + return_trace (CFFTopDict_OpSerializer<>::serialize (c, opstr, offsets)); } } @@ -67,10 +67,10 @@ struct CFF2TopDict_OpSerializer : CFFTopDict_OpSerializer<> switch (opstr.op) { case OpCode_vstore: - return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); + return OpCode_Size (OpCode_longintdict) + 4 + OpCode_Size (opstr.op); default: - return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); + return CFFTopDict_OpSerializer<>::calculate_serialized_size (opstr); } } }; @@ -83,8 +83,8 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet { case OpCode_return: case OpCode_endchar: - /* dummy opcodes in CFF2. ignore */ - break; + /* dummy opcodes in CFF2. ignore */ + break; case OpCode_hstem: case OpCode_hstemhm: @@ -92,16 +92,16 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet case OpCode_vstemhm: case OpCode_hintmask: case OpCode_cntrmask: - if (param.drop_hints) - { - env.clear_args (); - return; - } - HB_FALLTHROUGH; + if (param.drop_hints) + { + env.clear_args (); + return; + } + HB_FALLTHROUGH; default: - SUPER::flush_args_and_op (op, env, param); - break; + SUPER::flush_args_and_op (op, env, param); + break; } } @@ -112,15 +112,15 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet const BlendArg &arg = env.argStack[i]; if (arg.blending ()) { - assert ((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues)); - flatten_blends (arg, i, env, param); - i += arg.numValues; + assert ((arg.numValues > 0) && (env.argStack.get_count () >= arg.numValues)); + flatten_blends (arg, i, env, param); + i += arg.numValues; } else { - StrEncoder encoder (param.flatStr); - encoder.encode_num (arg); - i++; + StrEncoder encoder (param.flatStr); + encoder.encode_num (arg); + i++; } } SUPER::flush_args (env, param); @@ -134,7 +134,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet { const BlendArg &arg1 = env.argStack[i + j]; assert (arg1.blending () && (arg.numValues == arg1.numValues) && (arg1.valueIndex == j) && - (arg1.deltas.len == env.get_region_count ())); + (arg1.deltas.len == env.get_region_count ())); encoder.encode_num (arg1); } /* flatten deltas for each value */ @@ -142,7 +142,7 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet { const BlendArg &arg1 = env.argStack[i + j]; for (unsigned int k = 0; k < arg1.deltas.len; k++) - encoder.encode_num (arg1.deltas[k]); + encoder.encode_num (arg1.deltas[k]); } /* flatten the number of values followed by blend operator */ encoder.encode_int (arg.numValues); @@ -155,10 +155,10 @@ struct CFF2CSOpSet_Flatten : CFF2CSOpSet { case OpCode_return: case OpCode_endchar: - return; + return; default: - StrEncoder encoder (param.flatStr); - encoder.encode_op (op); + StrEncoder encoder (param.flatStr); + encoder.encode_op (op); } } @@ -174,35 +174,35 @@ struct CFF2CSOpSet_SubrSubset : CFF2CSOpSetset_parsed (); - env.returnFromSubr (); - param.set_current_str (env); - break; + param.current_parsed_str->set_parsed (); + env.returnFromSubr (); + param.set_current_str (env); + break; case OpCode_endchar: - param.current_parsed_str->set_parsed (); - SUPER::process_op (op, env, param); - break; + param.current_parsed_str->set_parsed (); + SUPER::process_op (op, env, param); + break; case OpCode_callsubr: - process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); - break; + process_call_subr (op, CSType_LocalSubr, env, param, env.localSubrs, param.local_closure); + break; case OpCode_callgsubr: - process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); - break; + process_call_subr (op, CSType_GlobalSubr, env, param, env.globalSubrs, param.global_closure); + break; default: - SUPER::process_op (op, env, param); - param.current_parsed_str->add_op (op, env.substr); - break; + SUPER::process_op (op, env, param); + param.current_parsed_str->add_op (op, env.substr); + break; } } protected: static inline void process_call_subr (OpCode op, CSType type, - CFF2CSInterpEnv &env, SubrSubsetParam& param, - CFF2BiasedSubrs& subrs, hb_set_t *closure) + CFF2CSInterpEnv &env, SubrSubsetParam& param, + CFF2BiasedSubrs& subrs, hb_set_t *closure) { SubByteStr substr = env.substr; env.callSubr (subrs, type); @@ -257,7 +257,7 @@ struct cff2_subset_plan { } inline bool create (const OT::cff2::accelerator_subset_t &acc, - hb_subset_plan_t *plan) + hb_subset_plan_t *plan) { final_size = 0; orig_fdcount = acc.fdArray->count; @@ -279,9 +279,9 @@ struct cff2_subset_plan { { /* Flatten global & local subrs */ SubrFlattener - flattener(acc, plan->glyphs, plan->drop_hints); + flattener(acc, plan->glyphs, plan->drop_hints); if (!flattener.flatten (subset_charstrings)) - return false; + return false; /* no global/local subroutines */ offsets.globalSubrsInfo.size = CFF2Subrs::calculate_serialized_size (1, 0, 0); @@ -290,14 +290,14 @@ struct cff2_subset_plan { { /* Subset subrs: collect used subroutines, leaving all unused ones behind */ if (!subr_subsetter.subset (acc, plan->glyphs, plan->drop_hints)) - return false; + return false; /* encode charstrings, global subrs, local subrs with new subroutine numbers */ if (!subr_subsetter.encode_charstrings (acc, plan->glyphs, subset_charstrings)) - return false; + return false; if (!subr_subsetter.encode_globalsubrs (subset_globalsubrs)) - return false; + return false; /* global subrs */ unsigned int dataSize = subset_globalsubrs.total_size (); @@ -306,26 +306,26 @@ struct cff2_subset_plan { /* local subrs */ if (!offsets.localSubrsInfos.resize (orig_fdcount)) - return false; + return false; if (!subset_localsubrs.resize (orig_fdcount)) - return false; + return false; for (unsigned int fd = 0; fd < orig_fdcount; fd++) { - subset_localsubrs[fd].init (); - offsets.localSubrsInfos[fd].init (); - if (fdmap.includes (fd)) - { - if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) - return false; + subset_localsubrs[fd].init (); + offsets.localSubrsInfos[fd].init (); + if (fdmap.includes (fd)) + { + if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd])) + return false; - unsigned int dataSize = subset_localsubrs[fd].total_size (); - if (dataSize > 0) - { - offsets.localSubrsInfos[fd].offset = final_size; - offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); - offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); - } - } + unsigned int dataSize = subset_localsubrs[fd].total_size (); + if (dataSize > 0) + { + offsets.localSubrsInfos[fd].offset = final_size; + offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); + offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].len, dataSize); + } + } } } @@ -345,14 +345,14 @@ struct cff2_subset_plan { { offsets.FDSelectInfo.offset = final_size; if (unlikely (!hb_plan_subset_cff_fdselect (plan->glyphs, - orig_fdcount, - *(const FDSelect *)acc.fdSelect, - subset_fdcount, - offsets.FDSelectInfo.size, - subset_fdselect_format, - subset_fdselect_ranges, - fdmap))) - return false; + orig_fdcount, + *(const FDSelect *)acc.fdSelect, + subset_fdcount, + offsets.FDSelectInfo.size, + subset_fdselect_format, + subset_fdselect_ranges, + fdmap))) + return false; final_size += offsets.FDSelectInfo.size; } @@ -365,8 +365,8 @@ struct cff2_subset_plan { CFFFontDict_OpSerializer fontSzr; unsigned int dictsSize = 0; for (unsigned int i = 0; i < acc.fontDicts.len; i++) - if (fdmap.includes (i)) - dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); + if (fdmap.includes (i)) + dictsSize += FontDict::calculate_serialized_size (acc.fontDicts[i], fontSzr); offsets.FDArrayInfo.offSize = calcOffSize (dictsSize); final_size += CFF2Index::calculate_serialized_size (offsets.FDArrayInfo.offSize, subset_fdcount, dictsSize); @@ -386,18 +386,18 @@ struct cff2_subset_plan { { if (fdmap.includes (i)) { - bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; - CFFPrivateDict_OpSerializer privSzr (desubroutinize, drop_hints); - unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); - TableInfo privInfo = { final_size, priv_size, 0 }; - privateDictInfos.push (privInfo); - final_size += privInfo.size; + bool has_localsubrs = offsets.localSubrsInfos[i].size > 0; + CFFPrivateDict_OpSerializer privSzr (desubroutinize, drop_hints); + unsigned int priv_size = PrivateDict::calculate_serialized_size (acc.privateDicts[i], privSzr, has_localsubrs); + TableInfo privInfo = { final_size, priv_size, 0 }; + privateDictInfos.push (privInfo); + final_size += privInfo.size; - if (!plan->desubroutinize && has_localsubrs) - { - offsets.localSubrsInfos[i].offset = final_size; - final_size += offsets.localSubrsInfos[i].size; - } + if (!plan->desubroutinize && has_localsubrs) + { + offsets.localSubrsInfos[i].offset = final_size; + final_size += offsets.localSubrsInfos[i].size; + } } } @@ -406,7 +406,7 @@ struct cff2_subset_plan { inline unsigned int get_final_size (void) const { return final_size; } - unsigned int final_size; + unsigned int final_size; CFF2SubTableOffsets offsets; unsigned int orig_fdcount; @@ -416,21 +416,21 @@ struct cff2_subset_plan { Remap fdmap; - StrBuffArray subset_charstrings; - StrBuffArray subset_globalsubrs; + StrBuffArray subset_charstrings; + StrBuffArray subset_globalsubrs; hb_vector_t subset_localsubrs; hb_vector_t privateDictInfos; - bool drop_hints; - bool desubroutinize; + bool drop_hints; + bool desubroutinize; CFF2SubrSubsetter subr_subsetter; }; static inline bool _write_cff2 (const cff2_subset_plan &plan, - const OT::cff2::accelerator_subset_t &acc, - const hb_vector_t& glyphs, - unsigned int dest_sz, - void *dest) + const OT::cff2::accelerator_subset_t &acc, + const hb_vector_t& glyphs, + unsigned int dest_sz, + void *dest) { hb_serialize_context_t c (dest, dest_sz); @@ -486,8 +486,8 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, 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))) + plan.subset_fdselect_format, plan.offsets.FDSelectInfo.size, + plan.subset_fdselect_ranges))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 subset FDSelect"); return false; @@ -501,8 +501,8 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, if (unlikely (fda == nullptr)) return false; CFFFontDict_OpSerializer fontSzr; if (unlikely (!fda->serialize (&c, plan.offsets.FDArrayInfo.offSize, - acc.fontDicts, plan.subset_fdcount, plan.fdmap, - fontSzr, plan.privateDictInfos))) + acc.fontDicts, plan.subset_fdcount, plan.fdmap, + fontSzr, plan.privateDictInfos))) { DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF2 FDArray"); return false; @@ -537,18 +537,18 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, result = pd->serialize (&c, acc.privateDicts[i], privSzr, subroffset); if (unlikely (!result)) { - DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); - return false; + DEBUG_MSG (SUBSET, nullptr, "failed to serialize CFF Private Dict[%d]", i); + return false; } if (plan.offsets.localSubrsInfos[i].size > 0) { - CFF2Subrs *dest = c.start_embed (); - if (unlikely (dest == nullptr)) return false; - if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) - { - DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); - return false; - } + CFF2Subrs *dest = c.start_embed (); + if (unlikely (dest == nullptr)) return false; + if (unlikely (!dest->serialize (&c, plan.offsets.localSubrsInfos[i].offSize, plan.subset_localsubrs[i]))) + { + DEBUG_MSG (SUBSET, nullptr, "failed to serialize local subroutines"); + return false; + } } } } @@ -561,9 +561,9 @@ static inline bool _write_cff2 (const cff2_subset_plan &plan, static bool _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, - const char *data, - hb_subset_plan_t *plan, - hb_blob_t **prime /* OUT */) + const char *data, + hb_subset_plan_t *plan, + hb_blob_t **prime /* OUT */) { cff2_subset_plan cff2_plan; @@ -577,17 +577,17 @@ _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, char *cff2_prime_data = (char *) calloc (1, cff2_prime_size); if (unlikely (!_write_cff2 (cff2_plan, acc, plan->glyphs, - cff2_prime_size, cff2_prime_data))) { + cff2_prime_size, cff2_prime_data))) { DEBUG_MSG(SUBSET, nullptr, "Failed to write a subset cff2."); free (cff2_prime_data); return false; } *prime = hb_blob_create (cff2_prime_data, - cff2_prime_size, - HB_MEMORY_MODE_READONLY, - cff2_prime_data, - free); + cff2_prime_size, + HB_MEMORY_MODE_READONLY, + cff2_prime_data, + free); return true; } @@ -599,7 +599,7 @@ _hb_subset_cff2 (const OT::cff2::accelerator_subset_t &acc, **/ bool hb_subset_cff2 (hb_subset_plan_t *plan, - hb_blob_t **prime /* OUT */) + hb_blob_t **prime /* OUT */) { hb_blob_t *cff2_blob = hb_sanitize_context_t().reference_table (plan->source); const char *data = hb_blob_get_data(cff2_blob, nullptr); @@ -607,7 +607,7 @@ hb_subset_cff2 (hb_subset_plan_t *plan, OT::cff2::accelerator_subset_t acc; acc.init(plan->source); bool result = likely (acc.is_valid ()) && - _hb_subset_cff2 (acc, data, plan, prime); + _hb_subset_cff2 (acc, data, plan, prime); hb_blob_destroy (cff2_blob); acc.fini (); diff --git a/src/hb-subset-cff2.hh b/src/hb-subset-cff2.hh index baac1a9be..a07dc290e 100644 --- a/src/hb-subset-cff2.hh +++ b/src/hb-subset-cff2.hh @@ -33,6 +33,6 @@ HB_INTERNAL bool hb_subset_cff2 (hb_subset_plan_t *plan, - hb_blob_t **cff2_prime /* OUT */); + hb_blob_t **cff2_prime /* OUT */); #endif /* HB_SUBSET_CFF2_HH */