diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml index 9b3ad248..c8c4da63 100644 --- a/.github/workflows/analysis.yml +++ b/.github/workflows/analysis.yml @@ -15,7 +15,7 @@ jobs: go-version: 'stable' - name: Install analysis tools - run: go install honnef.co/go/tools/cmd/staticcheck@v0.6.0 + run: go install honnef.co/go/tools/cmd/staticcheck@v0.8.0 - name: Vet run: go vet ./... diff --git a/font/cff/cff2.go b/font/cff/cff2.go index 18f721bc..e619f9f1 100644 --- a/font/cff/cff2.go +++ b/font/cff/cff2.go @@ -9,7 +9,7 @@ import ( "github.com/go-text/typesetting/font/opentype/tables" ) -//go:generate ../../../../typesetting-utils/generators/binarygen/cmd/generator . _src.go +//go:generate ../../../typesetting-utils/generators/binarygen/cmd/generator . _src.go // CFF2 represents a parsed 'CFF2' Opentype table. type CFF2 struct { diff --git a/font/cff/cff_gen.go b/font/cff/cff_gen.go index 53ede583..3cab0887 100755 --- a/font/cff/cff_gen.go +++ b/font/cff/cff_gen.go @@ -7,7 +7,7 @@ import ( "fmt" ) -// Code generated by binarygen from cff2_src.go. DO NOT EDIT +// Code generated by binarygen from cff_src.go. DO NOT EDIT func (item *header2) mustParse(src []byte) { _ = src[4] // early bound checking @@ -58,7 +58,6 @@ func parseFdSelect0(src []byte, fdsCount int) (fdSelect0, int, error) { return item, 0, fmt.Errorf("reading fdSelect0: "+"EOF: expected length: 1, got %d", L) } item.format = src[0] - n += 1 { @@ -81,7 +80,6 @@ func parseFdSelect3(src []byte) (fdSelect3, int, error) { _ = src[2] // early bound checking item.format = src[0] item.nRanges = binary.BigEndian.Uint16(src[1:]) - n += 3 { arrayLength := int(item.nRanges) @@ -100,7 +98,6 @@ func parseFdSelect3(src []byte) (fdSelect3, int, error) { return item, 0, fmt.Errorf("reading fdSelect3: "+"EOF: expected length: n + 2, got %d", L) } item.sentinel = binary.BigEndian.Uint16(src[n:]) - n += 2 return item, n, nil } @@ -114,7 +111,6 @@ func parseFdSelect4(src []byte) (fdSelect4, int, error) { _ = src[4] // early bound checking item.format = src[0] item.nRanges = binary.BigEndian.Uint32(src[1:]) - n += 5 { arrayLength := int(item.nRanges) @@ -133,7 +129,6 @@ func parseFdSelect4(src []byte) (fdSelect4, int, error) { return item, 0, fmt.Errorf("reading fdSelect4: "+"EOF: expected length: n + 4, got %d", L) } item.sentinel = binary.BigEndian.Uint32(src[n:]) - n += 4 return item, n, nil } diff --git a/font/cff/cff_src.go b/font/cff/cff_src.go index dbfe540a..2bd46fb9 100644 --- a/font/cff/cff_src.go +++ b/font/cff/cff_src.go @@ -6,8 +6,6 @@ import ( "github.com/go-text/typesetting/font/opentype/tables" ) -//go:generate ../../../../../typesetting-utils/generators/binarygen/cmd/generator . _src.go - type header2 struct { majorVersion uint8 // Format major version. Set to 2. minorVersion uint8 // Format minor version. Set to zero. diff --git a/font/opentype/tables/aat_ankr_gen.go b/font/opentype/tables/aat_ankr_gen.go index 169df984..12f8374c 100755 --- a/font/opentype/tables/aat_ankr_gen.go +++ b/font/opentype/tables/aat_ankr_gen.go @@ -66,7 +66,6 @@ func ParseAATLookupRecord4(src []byte, parentSrc []byte) (AATLookupRecord4, int, item.LastGlyph = binary.BigEndian.Uint16(src[0:]) item.FirstGlyph = binary.BigEndian.Uint16(src[2:]) offsetValues := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetValues != 0 { // ignore null offset @@ -97,7 +96,6 @@ func ParseAATLoopkup0(src []byte, valuesCount int) (AATLoopkup0, int, error) { return item, 0, fmt.Errorf("reading AATLoopkup0: "+"EOF: expected length: 2, got %d", L) } item.version = binary.BigEndian.Uint16(src[0:]) - n += 2 { @@ -125,7 +123,6 @@ func ParseAATLoopkup10(src []byte) (AATLoopkup10, int, error) { item.unitSize = binary.BigEndian.Uint16(src[2:]) item.FirstGlyph = binary.BigEndian.Uint16(src[4:]) arrayLengthValues := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { @@ -151,7 +148,6 @@ func ParseAATLoopkup2(src []byte) (AATLoopkup2, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits) @@ -178,7 +174,6 @@ func ParseAATLoopkup4(src []byte) (AATLoopkup4, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits - 1) @@ -206,7 +201,6 @@ func ParseAATLoopkup6(src []byte) (AATLoopkup6, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits) @@ -231,7 +225,6 @@ func ParseAATLoopkup8(src []byte) (AATLoopkup8, int, error) { return item, 0, fmt.Errorf("reading AATLoopkup8: "+"EOF: expected length: 2, got %d", L) } item.version = binary.BigEndian.Uint16(src[0:]) - n += 2 { var ( @@ -256,7 +249,6 @@ func ParseAATLoopkup8Data(src []byte) (AATLoopkup8Data, int, error) { _ = src[3] // early bound checking item.FirstGlyph = binary.BigEndian.Uint16(src[0:]) arrayLengthValues := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -284,7 +276,6 @@ func ParseAnkr(src []byte, valuesCount int) (Ankr, int, error) { item.flags = binary.BigEndian.Uint16(src[2:]) offsetLookupTable := int(binary.BigEndian.Uint32(src[4:])) offsetGlyphDataTable := int(binary.BigEndian.Uint32(src[8:])) - n += 12 { if offsetLookupTable != 0 { // ignore null offset diff --git a/font/opentype/tables/aat_feat_gen.go b/font/opentype/tables/aat_feat_gen.go index 4d82df23..ef273beb 100755 --- a/font/opentype/tables/aat_feat_gen.go +++ b/font/opentype/tables/aat_feat_gen.go @@ -26,7 +26,6 @@ func ParseFeat(src []byte) (Feat, int, error) { item.featureNameCount = binary.BigEndian.Uint16(src[4:]) item.none1 = binary.BigEndian.Uint16(src[6:]) item.none2 = binary.BigEndian.Uint32(src[8:]) - n += 12 { arrayLength := int(item.featureNameCount) @@ -57,7 +56,6 @@ func ParseFeatureName(src []byte, parentSrc []byte) (FeatureName, int, error) { offsetSettingTable := int(binary.BigEndian.Uint32(src[4:])) item.FeatureFlags = binary.BigEndian.Uint16(src[8:]) item.NameIndex = binary.BigEndian.Uint16(src[10:]) - n += 12 { if offsetSettingTable != 0 { // ignore null offset diff --git a/font/opentype/tables/aat_kerx_gen.go b/font/opentype/tables/aat_kerx_gen.go index 295a5152..462494bb 100755 --- a/font/opentype/tables/aat_kerx_gen.go +++ b/font/opentype/tables/aat_kerx_gen.go @@ -77,7 +77,6 @@ func ParseAATLoopkupExt0(src []byte, valuesCount int) (AATLoopkupExt0, int, erro return item, 0, fmt.Errorf("reading AATLoopkupExt0: "+"EOF: expected length: 2, got %d", L) } item.version = binary.BigEndian.Uint16(src[0:]) - n += 2 { @@ -105,7 +104,6 @@ func ParseAATLoopkupExt10(src []byte) (AATLoopkupExt10, int, error) { item.unitSize = binary.BigEndian.Uint16(src[2:]) item.FirstGlyph = binary.BigEndian.Uint16(src[4:]) arrayLengthValues := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { @@ -131,7 +129,6 @@ func ParseAATLoopkupExt2(src []byte) (AATLoopkupExt2, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits) @@ -158,7 +155,6 @@ func ParseAATLoopkupExt4(src []byte) (AATLoopkupExt4, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits) @@ -186,7 +182,6 @@ func ParseAATLoopkupExt6(src []byte) (AATLoopkupExt6, int, error) { _ = src[11] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.binSearchHeader.mustParse(src[2:]) - n += 12 { arrayLength := int(item.nUnits) @@ -211,7 +206,6 @@ func ParseAATLoopkupExt8(src []byte) (AATLoopkupExt8, int, error) { return item, 0, fmt.Errorf("reading AATLoopkupExt8: "+"EOF: expected length: 2, got %d", L) } item.version = binary.BigEndian.Uint16(src[0:]) - n += 2 { var ( @@ -238,7 +232,6 @@ func ParseAATStateTableExt(src []byte, valuesCount int, entryDataSize int) (AATS offsetClass := int(binary.BigEndian.Uint32(src[4:])) item.stateArray = Offset32(binary.BigEndian.Uint32(src[8:])) item.entryTable = Offset32(binary.BigEndian.Uint32(src[12:])) - n += 16 { if offsetClass != 0 { // ignore null offset @@ -285,7 +278,6 @@ func ParseKerx(src []byte, valuesCount int) (Kerx, int, error) { item.version = binary.BigEndian.Uint16(src[0:]) item.padding = binary.BigEndian.Uint16(src[2:]) item.nTables = binary.BigEndian.Uint32(src[4:]) - n += 8 { arrayLength := int(item.nTables) @@ -369,7 +361,6 @@ func ParseKerxData0(src []byte, tupleCount int) (KerxData0, int, error) { item.searchRange = binary.BigEndian.Uint32(src[4:]) item.entrySelector = binary.BigEndian.Uint32(src[8:]) item.rangeShift = binary.BigEndian.Uint32(src[12:]) - n += 16 { arrayLength := int(item.nPairs) @@ -411,7 +402,6 @@ func ParseKerxData1(src []byte, tupleCount int, valuesCount int) (KerxData1, int return item, 0, fmt.Errorf("reading KerxData1: "+"EOF: expected length: n + 4, got %d", L) } item.valueTable = Offset32(binary.BigEndian.Uint32(src[n:])) - n += 4 { @@ -434,7 +424,6 @@ func ParseKerxData2(src []byte, parentSrc []byte, valuesCount int) (KerxData2, i offsetLeft := int(binary.BigEndian.Uint32(src[4:])) offsetRight := int(binary.BigEndian.Uint32(src[8:])) item.KerningStart = Offset32(binary.BigEndian.Uint32(src[12:])) - n += 16 { if offsetLeft != 0 { // ignore null offset @@ -495,7 +484,6 @@ func ParseKerxData4(src []byte, valuesCount int) (KerxData4, int, error) { return item, 0, fmt.Errorf("reading KerxData4: "+"EOF: expected length: n + 4, got %d", L) } item.Flags = binary.BigEndian.Uint32(src[n:]) - n += 4 { @@ -521,7 +509,6 @@ func ParseKerxData6(src []byte, parentSrc []byte, tupleCount int, valuesCount in item.columnIndexTableOffset = binary.BigEndian.Uint32(src[12:]) item.kerningArrayOffset = binary.BigEndian.Uint32(src[16:]) item.kerningVectorOffset = binary.BigEndian.Uint32(src[20:]) - n += 24 { @@ -559,7 +546,6 @@ func ParseKerxSubtable(src []byte, valuesCount int) (KerxSubtable, int, error) { item.padding = src[6] item.version = kerxSTVersion(src[7]) item.TupleCount = binary.BigEndian.Uint32(src[8:]) - n += 12 { var ( @@ -617,7 +603,6 @@ func parseLoopkupRecordExt4(src []byte, parentSrc []byte) (loopkupRecordExt4, in item.LastGlyph = binary.BigEndian.Uint16(src[0:]) item.FirstGlyph = binary.BigEndian.Uint16(src[2:]) offsetValues := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetValues != 0 { // ignore null offset diff --git a/font/opentype/tables/aat_ltag_gen.go b/font/opentype/tables/aat_ltag_gen.go index 972bba88..607046fc 100755 --- a/font/opentype/tables/aat_ltag_gen.go +++ b/font/opentype/tables/aat_ltag_gen.go @@ -19,7 +19,6 @@ func ParseLtag(src []byte) (Ltag, int, error) { item.version = binary.BigEndian.Uint32(src[0:]) item.flags = binary.BigEndian.Uint32(src[4:]) item.numTags = binary.BigEndian.Uint32(src[8:]) - n += 12 { arrayLength := int(item.numTags) diff --git a/font/opentype/tables/aat_mortx_gen.go b/font/opentype/tables/aat_mortx_gen.go index fcd17bf2..c2a6515a 100755 --- a/font/opentype/tables/aat_mortx_gen.go +++ b/font/opentype/tables/aat_mortx_gen.go @@ -27,7 +27,6 @@ func ParseMorx(src []byte, valuesCount int) (Morx, int, error) { item.version = binary.BigEndian.Uint16(src[0:]) item.unused = binary.BigEndian.Uint16(src[2:]) item.nChains = binary.BigEndian.Uint32(src[4:]) - n += 8 { arrayLength := int(item.nChains) @@ -57,7 +56,6 @@ func ParseMorxChain(src []byte, valuesCount int) (MorxChain, int, error) { item.chainLength = binary.BigEndian.Uint32(src[4:]) item.nFeatureEntries = binary.BigEndian.Uint32(src[8:]) item.nSubtable = binary.BigEndian.Uint32(src[12:]) - n += 16 { arrayLength := int(item.nFeatureEntries) @@ -102,7 +100,6 @@ func ParseMorxChainSubtable(src []byte, valuesCount int) (MorxChainSubtable, int item.ignored[1] = src[6] item.version = MorxSubtableVersion(src[7]) item.SubFeatureFlags = binary.BigEndian.Uint32(src[8:]) - n += 12 { var ( @@ -155,7 +152,6 @@ func ParseMorxSubtableContextual(src []byte, valuesCount int) (MorxSubtableConte return item, 0, fmt.Errorf("reading MorxSubtableContextual: "+"EOF: expected length: n + 4, got %d", L) } offsetSubstitutions := int(binary.BigEndian.Uint32(src[n:])) - n += 4 { if offsetSubstitutions != 0 { // ignore null offset @@ -192,7 +188,6 @@ func ParseMorxSubtableInsertion(src []byte, valuesCount int) (MorxSubtableInsert return item, 0, fmt.Errorf("reading MorxSubtableInsertion: "+"EOF: expected length: n + 4, got %d", L) } offsetInsertions := int(binary.BigEndian.Uint32(src[n:])) - n += 4 { if offsetInsertions != 0 { // ignore null offset @@ -237,7 +232,6 @@ func ParseMorxSubtableLigature(src []byte, valuesCount int) (MorxSubtableLigatur item.ligActionOffset = Offset32(binary.BigEndian.Uint32(src[n:])) item.componentOffset = Offset32(binary.BigEndian.Uint32(src[n+4:])) item.ligatureOffset = Offset32(binary.BigEndian.Uint32(src[n+8:])) - n += 12 { diff --git a/font/opentype/tables/aat_trak_gen.go b/font/opentype/tables/aat_trak_gen.go index f60d477f..4e513d58 100755 --- a/font/opentype/tables/aat_trak_gen.go +++ b/font/opentype/tables/aat_trak_gen.go @@ -19,7 +19,6 @@ func ParseTrackData(src []byte, parentSrc []byte) (TrackData, int, error) { item.nTracks = binary.BigEndian.Uint16(src[0:]) item.nSizes = binary.BigEndian.Uint16(src[2:]) offsetSizeTable := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { if offsetSizeTable != 0 { // ignore null offset @@ -67,7 +66,6 @@ func ParseTrackTableEntry(src []byte, grandParentSrc []byte, perSizeTrackingCoun item.Track = Float1616FromUint(binary.BigEndian.Uint32(src[0:])) item.NameIndex = binary.BigEndian.Uint16(src[4:]) offsetPerSizeTracking := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetPerSizeTracking != 0 { // ignore null offset @@ -101,7 +99,6 @@ func ParseTrak(src []byte) (Trak, int, error) { offsetHoriz := int(binary.BigEndian.Uint16(src[6:])) offsetVert := int(binary.BigEndian.Uint16(src[8:])) item.reserved = binary.BigEndian.Uint16(src[10:]) - n += 12 { if offsetHoriz != 0 { // ignore null offset diff --git a/font/opentype/tables/cmap_gen.go b/font/opentype/tables/cmap_gen.go index e10d6c82..8542beae 100755 --- a/font/opentype/tables/cmap_gen.go +++ b/font/opentype/tables/cmap_gen.go @@ -281,7 +281,6 @@ func ParseCmap(src []byte) (Cmap, int, error) { _ = src[3] // early bound checking item.version = binary.BigEndian.Uint16(src[0:]) item.numTables = binary.BigEndian.Uint16(src[2:]) - n += 4 { arrayLength := int(item.numTables) @@ -362,7 +361,6 @@ func ParseCmapSubtable10(src []byte) (CmapSubtable10, int, error) { item.language = binary.BigEndian.Uint32(src[8:]) item.StartCharCode = binary.BigEndian.Uint32(src[12:]) arrayLengthGlyphIdArray := int(binary.BigEndian.Uint32(src[16:])) - n += 20 { @@ -391,7 +389,6 @@ func ParseCmapSubtable12(src []byte) (CmapSubtable12, int, error) { item.length = binary.BigEndian.Uint32(src[4:]) item.language = binary.BigEndian.Uint32(src[8:]) arrayLengthGroups := int(binary.BigEndian.Uint32(src[12:])) - n += 16 { @@ -420,7 +417,6 @@ func ParseCmapSubtable13(src []byte) (CmapSubtable13, int, error) { item.length = binary.BigEndian.Uint32(src[4:]) item.language = binary.BigEndian.Uint32(src[8:]) arrayLengthGroups := int(binary.BigEndian.Uint32(src[12:])) - n += 16 { @@ -447,7 +443,6 @@ func ParseCmapSubtable14(src []byte) (CmapSubtable14, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) item.length = binary.BigEndian.Uint32(src[2:]) arrayLengthVarSelectors := int(binary.BigEndian.Uint32(src[6:])) - n += 10 { @@ -472,7 +467,6 @@ func ParseCmapSubtable2(src []byte) (CmapSubtable2, int, error) { return item, 0, fmt.Errorf("reading CmapSubtable2: "+"EOF: expected length: 2, got %d", L) } item.format = binary.BigEndian.Uint16(src[0:]) - n += 2 { @@ -496,7 +490,6 @@ func ParseCmapSubtable4(src []byte) (CmapSubtable4, int, error) { item.searchRange = binary.BigEndian.Uint16(src[8:]) item.entrySelector = binary.BigEndian.Uint16(src[10:]) item.rangeShift = binary.BigEndian.Uint16(src[12:]) - n += 14 { arrayLength := int(item.segCountX2 / 2) @@ -515,50 +508,49 @@ func ParseCmapSubtable4(src []byte) (CmapSubtable4, int, error) { return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: n + 2, got %d", L) } item.reservedPad = binary.BigEndian.Uint16(src[n:]) - n += 2 { arrayLength := int(item.segCountX2 / 2) - if L := len(src); L < n+arrayLength*2 { - return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+arrayLength*2, L) + if L := len(src); L < n+2+arrayLength*2 { + return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+2+arrayLength*2, L) } item.StartCode = make([]uint16, arrayLength) // allocation guarded by the previous check for i := range item.StartCode { - item.StartCode[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.StartCode[i] = binary.BigEndian.Uint16(src[n+2+i*2:]) } n += arrayLength * 2 } { arrayLength := int(item.segCountX2 / 2) - if L := len(src); L < n+arrayLength*2 { - return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+arrayLength*2, L) + if L := len(src); L < n+2+arrayLength*2 { + return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+2+arrayLength*2, L) } item.IdDelta = make([]uint16, arrayLength) // allocation guarded by the previous check for i := range item.IdDelta { - item.IdDelta[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.IdDelta[i] = binary.BigEndian.Uint16(src[n+2+i*2:]) } n += arrayLength * 2 } { arrayLength := int(item.segCountX2 / 2) - if L := len(src); L < n+arrayLength*2 { - return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+arrayLength*2, L) + if L := len(src); L < n+2+arrayLength*2 { + return item, 0, fmt.Errorf("reading CmapSubtable4: "+"EOF: expected length: %d, got %d", n+2+arrayLength*2, L) } item.IdRangeOffsets = make([]uint16, arrayLength) // allocation guarded by the previous check for i := range item.IdRangeOffsets { - item.IdRangeOffsets[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.IdRangeOffsets[i] = binary.BigEndian.Uint16(src[n+2+i*2:]) } n += arrayLength * 2 } { - item.GlyphIDArray = src[n:] + item.GlyphIDArray = src[n+2:] n = len(src) } return item, n, nil @@ -576,7 +568,6 @@ func ParseCmapSubtable6(src []byte) (CmapSubtable6, int, error) { item.language = binary.BigEndian.Uint16(src[4:]) item.FirstCode = binary.BigEndian.Uint16(src[6:]) arrayLengthGlyphIdArray := int(binary.BigEndian.Uint16(src[8:])) - n += 10 { @@ -600,7 +591,6 @@ func ParseDefaultUVSTable(src []byte) (DefaultUVSTable, int, error) { return item, 0, fmt.Errorf("reading DefaultUVSTable: "+"EOF: expected length: 4, got %d", L) } arrayLengthRanges := int(binary.BigEndian.Uint32(src[0:])) - n += 4 { @@ -627,7 +617,6 @@ func ParseEncodingRecord(src []byte, parentSrc []byte) (EncodingRecord, int, err item.PlatformID = PlatformID(binary.BigEndian.Uint16(src[0:])) item.EncodingID = EncodingID(binary.BigEndian.Uint16(src[2:])) offsetSubtable := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { if offsetSubtable != 0 { // ignore null offset @@ -656,7 +645,6 @@ func ParseUVSMappingTable(src []byte) (UVSMappingTable, int, error) { return item, 0, fmt.Errorf("reading UVSMappingTable: "+"EOF: expected length: 4, got %d", L) } arrayLengthRanges := int(binary.BigEndian.Uint32(src[0:])) - n += 4 { @@ -685,7 +673,6 @@ func ParseVariationSelector(src []byte, parentSrc []byte) (VariationSelector, in item.VarSelector[2] = src[2] offsetDefaultUVS := int(binary.BigEndian.Uint32(src[3:])) offsetNonDefaultUVS := int(binary.BigEndian.Uint32(src[7:])) - n += 11 { if offsetDefaultUVS != 0 { // ignore null offset diff --git a/font/opentype/tables/glyphs_bitmap_gen.go b/font/opentype/tables/glyphs_bitmap_gen.go index 27ef0fa5..5dd60065 100755 --- a/font/opentype/tables/glyphs_bitmap_gen.go +++ b/font/opentype/tables/glyphs_bitmap_gen.go @@ -61,7 +61,6 @@ func ParseBitmapData17(src []byte) (BitmapData17, int, error) { _ = src[8] // early bound checking item.SmallGlyphMetrics.mustParse(src[0:]) arrayLengthImage := int(binary.BigEndian.Uint32(src[5:])) - n += 9 { @@ -84,7 +83,6 @@ func ParseBitmapData18(src []byte) (BitmapData18, int, error) { _ = src[11] // early bound checking item.BigGlyphMetrics.mustParse(src[0:]) arrayLengthImage := int(binary.BigEndian.Uint32(src[8:])) - n += 12 { @@ -105,7 +103,6 @@ func ParseBitmapData19(src []byte) (BitmapData19, int, error) { return item, 0, fmt.Errorf("reading BitmapData19: "+"EOF: expected length: 4, got %d", L) } arrayLengthImage := int(binary.BigEndian.Uint32(src[0:])) - n += 4 { @@ -123,10 +120,9 @@ func ParseBitmapData1Or2(src []byte) (BitmapData1Or2, int, error) { var item BitmapData1Or2 n := 0 if L := len(src); L < 5 { - return item, 0, fmt.Errorf("reading BitmapData1or2: "+"EOF: expected length: 5, got %d", L) + return item, 0, fmt.Errorf("reading BitmapData1Or2: "+"EOF: expected length: 5, got %d", L) } item.SmallGlyphMetrics.mustParse(src[0:]) - n += 5 { @@ -157,7 +153,6 @@ func ParseCBLC(src []byte) (CBLC, int, error) { item.majorVersion = binary.BigEndian.Uint16(src[0:]) item.minorVersion = binary.BigEndian.Uint16(src[2:]) arrayLengthBitmapSizes := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -235,7 +230,6 @@ func ParseIndexData4(src []byte) (IndexData4, int, error) { return item, 0, fmt.Errorf("reading IndexData4: "+"EOF: expected length: 4, got %d", L) } item.numGlyphs = binary.BigEndian.Uint32(src[0:]) - n += 4 { arrayLength := int(item.numGlyphs + 1) @@ -263,7 +257,6 @@ func ParseIndexData5(src []byte) (IndexData5, int, error) { item.ImageSize = binary.BigEndian.Uint32(src[0:]) item.BigMetrics.mustParse(src[4:]) arrayLengthGlyphIdArray := int(binary.BigEndian.Uint32(src[12:])) - n += 16 { @@ -290,7 +283,6 @@ func ParseIndexSubHeader(src []byte, sbitOffsetsCount int) (IndexSubHeader, int, item.indexFormat = indexVersion(binary.BigEndian.Uint16(src[0:])) item.ImageFormat = binary.BigEndian.Uint16(src[2:]) item.ImageDataOffset = Offset32(binary.BigEndian.Uint32(src[4:])) - n += 8 { var ( diff --git a/font/opentype/tables/glyphs_colr_gen.go b/font/opentype/tables/glyphs_colr_gen.go index e75399df..fcc9aa0b 100755 --- a/font/opentype/tables/glyphs_colr_gen.go +++ b/font/opentype/tables/glyphs_colr_gen.go @@ -113,7 +113,6 @@ func ParseCOLR1(src []byte) (COLR1, int, error) { offsetClipList := int(binary.BigEndian.Uint32(src[n+8:])) offsetVarIndexMap := int(binary.BigEndian.Uint32(src[n+12:])) offsetItemVariationStore := int(binary.BigEndian.Uint32(src[n+16:])) - n += 20 { if offsetBaseGlyphList != 0 { // ignore null offset @@ -202,7 +201,6 @@ func ParseClip(src []byte, parentSrc []byte) (Clip, int, error) { item.StartGlyphID = binary.BigEndian.Uint16(src[0:]) item.EndGlyphID = binary.BigEndian.Uint16(src[2:]) offsetClipBox := int(readUint24(src[4:])) - n += 7 { if offsetClipBox != 0 { // ignore null offset @@ -281,7 +279,6 @@ func ParseClipList(src []byte) (ClipList, int, error) { _ = src[4] // early bound checking item.format = src[0] arrayLengthClips := int(binary.BigEndian.Uint32(src[1:])) - n += 5 { @@ -308,7 +305,6 @@ func ParseColorLine(src []byte) (ColorLine, int, error) { _ = src[2] // early bound checking item.Extend = Extend(src[0]) arrayLengthColorStops := int(binary.BigEndian.Uint16(src[1:])) - n += 3 { @@ -334,7 +330,6 @@ func ParseDeltaSetMapping(src []byte) (DeltaSetMapping, int, error) { _ = src[1] // early bound checking item.format = src[0] item.entryFormat = src[1] - n += 2 { @@ -356,7 +351,6 @@ func ParseItemVarStore(src []byte) (ItemVarStore, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetVariationRegionList := int(binary.BigEndian.Uint32(src[2:])) arrayLengthItemVariationDatas := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetVariationRegionList != 0 { // ignore null offset @@ -411,7 +405,6 @@ func ParseItemVariationData(src []byte) (ItemVariationData, int, error) { item.itemCount = binary.BigEndian.Uint16(src[0:]) item.wordDeltaCount = binary.BigEndian.Uint16(src[2:]) item.regionIndexCount = binary.BigEndian.Uint16(src[4:]) - n += 6 { arrayLength := int(item.regionIndexCount) @@ -443,7 +436,6 @@ func ParseLayerList(src []byte) (LayerList, int, error) { return item, 0, fmt.Errorf("reading LayerList: "+"EOF: expected length: 4, got %d", L) } arrayLengthPaintTables := int(binary.BigEndian.Uint32(src[0:])) - n += 4 { @@ -507,7 +499,6 @@ func ParsePaintComposite(src []byte) (PaintComposite, int, error) { offsetSourcePaint := int(readUint24(src[1:])) item.CompositeMode = CompositeMode(src[4]) offsetBackdropPaint := int(readUint24(src[5:])) - n += 8 { if offsetSourcePaint != 0 { // ignore null offset @@ -556,7 +547,6 @@ func ParsePaintGlyph(src []byte) (PaintGlyph, int, error) { item.format = src[0] offsetPaint := int(readUint24(src[1:])) item.GlyphID = binary.BigEndian.Uint16(src[4:]) - n += 6 { if offsetPaint != 0 { // ignore null offset @@ -593,7 +583,6 @@ func ParsePaintLinearGradient(src []byte) (PaintLinearGradient, int, error) { item.Y1 = int16(binary.BigEndian.Uint16(src[10:])) item.X2 = int16(binary.BigEndian.Uint16(src[12:])) item.Y2 = int16(binary.BigEndian.Uint16(src[14:])) - n += 16 { if offsetColorLine != 0 { // ignore null offset @@ -627,7 +616,6 @@ func ParsePaintRadialGradient(src []byte) (PaintRadialGradient, int, error) { item.X1 = int16(binary.BigEndian.Uint16(src[10:])) item.Y1 = int16(binary.BigEndian.Uint16(src[12:])) item.Radius1 = binary.BigEndian.Uint16(src[14:]) - n += 16 { if offsetColorLine != 0 { // ignore null offset @@ -656,7 +644,6 @@ func ParsePaintRotate(src []byte) (PaintRotate, int, error) { item.format = src[0] offsetPaint := int(readUint24(src[1:])) item.Angle = Coord(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetPaint != 0 { // ignore null offset @@ -690,7 +677,6 @@ func ParsePaintRotateAroundCenter(src []byte) (PaintRotateAroundCenter, int, err item.Angle = Coord(binary.BigEndian.Uint16(src[4:])) item.CenterX = int16(binary.BigEndian.Uint16(src[6:])) item.CenterY = int16(binary.BigEndian.Uint16(src[8:])) - n += 10 { if offsetPaint != 0 { // ignore null offset @@ -723,7 +709,6 @@ func ParsePaintScale(src []byte) (PaintScale, int, error) { offsetPaint := int(readUint24(src[1:])) item.ScaleX = Coord(binary.BigEndian.Uint16(src[4:])) item.ScaleY = Coord(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetPaint != 0 { // ignore null offset @@ -758,7 +743,6 @@ func ParsePaintScaleAroundCenter(src []byte) (PaintScaleAroundCenter, int, error item.ScaleY = Coord(binary.BigEndian.Uint16(src[6:])) item.CenterX = int16(binary.BigEndian.Uint16(src[8:])) item.CenterY = int16(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetPaint != 0 { // ignore null offset @@ -790,7 +774,6 @@ func ParsePaintScaleUniform(src []byte) (PaintScaleUniform, int, error) { item.format = src[0] offsetPaint := int(readUint24(src[1:])) item.Scale = Coord(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetPaint != 0 { // ignore null offset @@ -824,7 +807,6 @@ func ParsePaintScaleUniformAroundCenter(src []byte) (PaintScaleUniformAroundCent item.Scale = Coord(binary.BigEndian.Uint16(src[4:])) item.CenterX = int16(binary.BigEndian.Uint16(src[6:])) item.CenterY = int16(binary.BigEndian.Uint16(src[8:])) - n += 10 { if offsetPaint != 0 { // ignore null offset @@ -857,7 +839,6 @@ func ParsePaintSkew(src []byte) (PaintSkew, int, error) { offsetPaint := int(readUint24(src[1:])) item.XSkewAngle = Coord(binary.BigEndian.Uint16(src[4:])) item.YSkewAngle = Coord(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetPaint != 0 { // ignore null offset @@ -892,7 +873,6 @@ func ParsePaintSkewAroundCenter(src []byte) (PaintSkewAroundCenter, int, error) item.YSkewAngle = Coord(binary.BigEndian.Uint16(src[6:])) item.CenterX = int16(binary.BigEndian.Uint16(src[8:])) item.CenterY = int16(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetPaint != 0 { // ignore null offset @@ -938,7 +918,6 @@ func ParsePaintSweepGradient(src []byte) (PaintSweepGradient, int, error) { item.CenterY = int16(binary.BigEndian.Uint16(src[6:])) item.StartAngle = Coord(binary.BigEndian.Uint16(src[8:])) item.EndAngle = Coord(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetColorLine != 0 { // ignore null offset @@ -1053,7 +1032,6 @@ func ParsePaintTransform(src []byte) (PaintTransform, int, error) { item.format = src[0] offsetPaint := int(readUint24(src[1:])) offsetTransform := int(readUint24(src[4:])) - n += 7 { if offsetPaint != 0 { // ignore null offset @@ -1100,7 +1078,6 @@ func ParsePaintTranslate(src []byte) (PaintTranslate, int, error) { offsetPaint := int(readUint24(src[1:])) item.Dx = int16(binary.BigEndian.Uint16(src[4:])) item.Dy = int16(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetPaint != 0 { // ignore null offset @@ -1138,7 +1115,6 @@ func ParsePaintVarLinearGradient(src []byte) (PaintVarLinearGradient, int, error item.X2 = int16(binary.BigEndian.Uint16(src[12:])) item.Y2 = int16(binary.BigEndian.Uint16(src[14:])) item.VarIndexBase = binary.BigEndian.Uint32(src[16:]) - n += 20 { if offsetColorLine != 0 { // ignore null offset @@ -1173,7 +1149,6 @@ func ParsePaintVarRadialGradient(src []byte) (PaintVarRadialGradient, int, error item.Y1 = int16(binary.BigEndian.Uint16(src[12:])) item.Radius1 = binary.BigEndian.Uint16(src[14:]) item.VarIndexBase = binary.BigEndian.Uint32(src[16:]) - n += 20 { if offsetColorLine != 0 { // ignore null offset @@ -1203,7 +1178,6 @@ func ParsePaintVarRotate(src []byte) (PaintVarRotate, int, error) { offsetPaint := int(readUint24(src[1:])) item.Angle = Coord(binary.BigEndian.Uint16(src[4:])) item.VarIndexBase = binary.BigEndian.Uint32(src[6:]) - n += 10 { if offsetPaint != 0 { // ignore null offset @@ -1238,7 +1212,6 @@ func ParsePaintVarRotateAroundCenter(src []byte) (PaintVarRotateAroundCenter, in item.CenterX = int16(binary.BigEndian.Uint16(src[6:])) item.CenterY = int16(binary.BigEndian.Uint16(src[8:])) item.VarIndexBase = binary.BigEndian.Uint32(src[10:]) - n += 14 { if offsetPaint != 0 { // ignore null offset @@ -1272,7 +1245,6 @@ func ParsePaintVarScale(src []byte) (PaintVarScale, int, error) { item.ScaleX = Coord(binary.BigEndian.Uint16(src[4:])) item.ScaleY = Coord(binary.BigEndian.Uint16(src[6:])) item.VarIndexBase = binary.BigEndian.Uint32(src[8:]) - n += 12 { if offsetPaint != 0 { // ignore null offset @@ -1308,7 +1280,6 @@ func ParsePaintVarScaleAroundCenter(src []byte) (PaintVarScaleAroundCenter, int, item.CenterX = int16(binary.BigEndian.Uint16(src[8:])) item.CenterY = int16(binary.BigEndian.Uint16(src[10:])) item.VarIndexBase = binary.BigEndian.Uint32(src[12:]) - n += 16 { if offsetPaint != 0 { // ignore null offset @@ -1341,7 +1312,6 @@ func ParsePaintVarScaleUniform(src []byte) (PaintVarScaleUniform, int, error) { offsetPaint := int(readUint24(src[1:])) item.Scale = Coord(binary.BigEndian.Uint16(src[4:])) item.VarIndexBase = binary.BigEndian.Uint32(src[6:]) - n += 10 { if offsetPaint != 0 { // ignore null offset @@ -1376,7 +1346,6 @@ func ParsePaintVarScaleUniformAroundCenter(src []byte) (PaintVarScaleUniformArou item.CenterX = int16(binary.BigEndian.Uint16(src[6:])) item.CenterY = int16(binary.BigEndian.Uint16(src[8:])) item.VarIndexBase = binary.BigEndian.Uint32(src[10:]) - n += 14 { if offsetPaint != 0 { // ignore null offset @@ -1410,7 +1379,6 @@ func ParsePaintVarSkew(src []byte) (PaintVarSkew, int, error) { item.XSkewAngle = Coord(binary.BigEndian.Uint16(src[4:])) item.YSkewAngle = Coord(binary.BigEndian.Uint16(src[6:])) item.VarIndexBase = binary.BigEndian.Uint32(src[8:]) - n += 12 { if offsetPaint != 0 { // ignore null offset @@ -1446,7 +1414,6 @@ func ParsePaintVarSkewAroundCenter(src []byte) (PaintVarSkewAroundCenter, int, e item.CenterX = int16(binary.BigEndian.Uint16(src[8:])) item.CenterY = int16(binary.BigEndian.Uint16(src[10:])) item.VarIndexBase = binary.BigEndian.Uint32(src[12:]) - n += 16 { if offsetPaint != 0 { // ignore null offset @@ -1493,7 +1460,6 @@ func ParsePaintVarSweepGradient(src []byte) (PaintVarSweepGradient, int, error) item.StartAngle = Coord(binary.BigEndian.Uint16(src[8:])) item.EndAngle = Coord(binary.BigEndian.Uint16(src[10:])) item.VarIndexBase = binary.BigEndian.Uint32(src[12:]) - n += 16 { if offsetColorLine != 0 { // ignore null offset @@ -1522,7 +1488,6 @@ func ParsePaintVarTransform(src []byte) (PaintVarTransform, int, error) { item.format = src[0] offsetPaint := int(readUint24(src[1:])) offsetTransform := int(readUint24(src[4:])) - n += 7 { if offsetPaint != 0 { // ignore null offset @@ -1570,7 +1535,6 @@ func ParsePaintVarTranslate(src []byte) (PaintVarTranslate, int, error) { item.Dx = int16(binary.BigEndian.Uint16(src[4:])) item.Dy = int16(binary.BigEndian.Uint16(src[6:])) item.VarIndexBase = binary.BigEndian.Uint32(src[8:]) - n += 12 { if offsetPaint != 0 { // ignore null offset @@ -1612,7 +1576,6 @@ func ParseVarColorLine(src []byte) (VarColorLine, int, error) { _ = src[2] // early bound checking item.Extend = Extend(src[0]) arrayLengthColorStops := int(binary.BigEndian.Uint16(src[1:])) - n += 3 { @@ -1656,7 +1619,6 @@ func ParseVariationRegionList(src []byte) (VariationRegionList, int, error) { _ = src[3] // early bound checking item.axisCount = binary.BigEndian.Uint16(src[0:]) arrayLengthVariationRegions := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -1714,7 +1676,6 @@ func parseBaseGlyphList(src []byte) (baseGlyphList, int, error) { return item, 0, fmt.Errorf("reading baseGlyphList: "+"EOF: expected length: 4, got %d", L) } arrayLengthPaintRecords := int(binary.BigEndian.Uint32(src[0:])) - n += 4 { @@ -1741,7 +1702,6 @@ func parseBaseGlyphPaintRecord(src []byte, parentSrc []byte) (baseGlyphPaintReco _ = src[5] // early bound checking item.GlyphID = binary.BigEndian.Uint16(src[0:]) offsetPaint := int(binary.BigEndian.Uint32(src[2:])) - n += 6 { if offsetPaint != 0 { // ignore null offset @@ -1775,7 +1735,6 @@ func parseColr0(src []byte) (colr0, int, error) { offsetBaseGlyphRecords := int(binary.BigEndian.Uint32(src[4:])) offsetLayerRecords := int(binary.BigEndian.Uint32(src[8:])) item.numLayerRecords = binary.BigEndian.Uint16(src[12:]) - n += 14 { if offsetBaseGlyphRecords != 0 { // ignore null offset diff --git a/font/opentype/tables/glyphs_cpal_gen.go b/font/opentype/tables/glyphs_cpal_gen.go index f408afd6..1d6869cb 100755 --- a/font/opentype/tables/glyphs_cpal_gen.go +++ b/font/opentype/tables/glyphs_cpal_gen.go @@ -29,7 +29,6 @@ func ParseCPAL(src []byte) (CPAL, int, error) { item.numPalettes = binary.BigEndian.Uint16(src[4:]) item.numColorRecords = binary.BigEndian.Uint16(src[6:]) offsetColorRecordsArray := int(binary.BigEndian.Uint32(src[8:])) - n += 12 { if offsetColorRecordsArray != 0 { // ignore null offset diff --git a/font/opentype/tables/glyphs_glyf_gen.go b/font/opentype/tables/glyphs_glyf_gen.go index 5ff7790f..df8b4d69 100755 --- a/font/opentype/tables/glyphs_glyf_gen.go +++ b/font/opentype/tables/glyphs_glyf_gen.go @@ -71,7 +71,6 @@ func ParseGlyph(src []byte) (Glyph, int, error) { item.YMin = int16(binary.BigEndian.Uint16(src[4:])) item.XMax = int16(binary.BigEndian.Uint16(src[6:])) item.YMax = int16(binary.BigEndian.Uint16(src[8:])) - n += 10 { @@ -113,20 +112,19 @@ func ParseSimpleGlyph(src []byte, endPtsOfContoursCount int) (SimpleGlyph, int, return item, 0, fmt.Errorf("reading SimpleGlyph: "+"EOF: expected length: n + 2, got %d", L) } arrayLengthInstructions := int(binary.BigEndian.Uint16(src[n:])) - n += 2 { - L := int(n + arrayLengthInstructions) + L := int(n + 2 + arrayLengthInstructions) if len(src) < L { return item, 0, fmt.Errorf("reading SimpleGlyph: "+"EOF: expected length: %d, got %d", L, len(src)) } - item.Instructions = src[n:L] + item.Instructions = src[n+2 : L] n = L } { - err := item.parsePoints(src[n:], endPtsOfContoursCount) + err := item.parsePoints(src[n+2:], endPtsOfContoursCount) if err != nil { return item, 0, fmt.Errorf("reading SimpleGlyph: %s", err) } diff --git a/font/opentype/tables/glyphs_misc_gen.go b/font/opentype/tables/glyphs_misc_gen.go index d7f58a12..fc124c89 100755 --- a/font/opentype/tables/glyphs_misc_gen.go +++ b/font/opentype/tables/glyphs_misc_gen.go @@ -19,7 +19,6 @@ func ParseSVG(src []byte) (SVG, int, error) { item.version = binary.BigEndian.Uint16(src[0:]) offsetSVGDocumentList := int(binary.BigEndian.Uint32(src[2:])) item.reserved = binary.BigEndian.Uint32(src[6:]) - n += 10 { if offsetSVGDocumentList != 0 { // ignore null offset @@ -45,7 +44,6 @@ func ParseSVGDocumentList(src []byte) (SVGDocumentList, int, error) { return item, 0, fmt.Errorf("reading SVGDocumentList: "+"EOF: expected length: 2, got %d", L) } arrayLengthDocumentRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -78,7 +76,6 @@ func ParseVORG(src []byte) (VORG, int, error) { item.minorVersion = binary.BigEndian.Uint16(src[2:]) item.DefaultVertOriginY = int16(binary.BigEndian.Uint16(src[4:])) arrayLengthVertOriginYMetrics := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { diff --git a/font/opentype/tables/glyphs_sbix_gen.go b/font/opentype/tables/glyphs_sbix_gen.go index 7dc38ce8..f5ff041e 100755 --- a/font/opentype/tables/glyphs_sbix_gen.go +++ b/font/opentype/tables/glyphs_sbix_gen.go @@ -19,7 +19,6 @@ func ParseBitmapGlyphData(src []byte) (BitmapGlyphData, int, error) { item.OriginOffsetX = int16(binary.BigEndian.Uint16(src[0:])) item.OriginOffsetY = int16(binary.BigEndian.Uint16(src[2:])) item.GraphicType = Tag(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -39,7 +38,6 @@ func ParseSbix(src []byte, numGlyphs int) (Sbix, int, error) { item.version = binary.BigEndian.Uint16(src[0:]) item.Flags = binary.BigEndian.Uint16(src[2:]) arrayLengthStrikes := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -79,7 +77,6 @@ func ParseStrike(src []byte, numGlyphs int) (Strike, int, error) { _ = src[3] // early bound checking item.Ppem = binary.BigEndian.Uint16(src[0:]) item.Ppi = binary.BigEndian.Uint16(src[2:]) - n += 4 { diff --git a/font/opentype/tables/kern_gen.go b/font/opentype/tables/kern_gen.go index 17388a30..bb924fb0 100755 --- a/font/opentype/tables/kern_gen.go +++ b/font/opentype/tables/kern_gen.go @@ -20,7 +20,6 @@ func ParseAATKernSubtableHeader(src []byte) (AATKernSubtableHeader, int, error) item.Coverage = src[4] item.version = kernSTVersion(src[5]) item.TupleCount = binary.BigEndian.Uint16(src[6:]) - n += 8 { var ( @@ -64,7 +63,6 @@ func ParseAATStateTable(src []byte) (AATStateTable, int, error) { offsetClassTable := int(binary.BigEndian.Uint16(src[2:])) item.stateArray = Offset16(binary.BigEndian.Uint16(src[4:])) item.entryTable = Offset16(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetClassTable != 0 { // ignore null offset @@ -107,7 +105,6 @@ func ParseClassTable(src []byte) (ClassTable, int, error) { _ = src[3] // early bound checking item.StartGlyph = binary.BigEndian.Uint16(src[0:]) arrayLengthValues := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -132,7 +129,6 @@ func ParseKernData0(src []byte) (KernData0, int, error) { item.searchRange = binary.BigEndian.Uint16(src[2:]) item.entrySelector = binary.BigEndian.Uint16(src[4:]) item.rangeShift = binary.BigEndian.Uint16(src[6:]) - n += 8 { arrayLength := int(item.nPairs) @@ -168,7 +164,6 @@ func ParseKernData1(src []byte) (KernData1, int, error) { return item, 0, fmt.Errorf("reading KernData1: "+"EOF: expected length: n + 2, got %d", L) } item.valueTable = binary.BigEndian.Uint16(src[n:]) - n += 2 { @@ -191,7 +186,6 @@ func ParseKernData2(src []byte, parentSrc []byte) (KernData2, int, error) { offsetLeft := int(binary.BigEndian.Uint16(src[2:])) offsetRight := int(binary.BigEndian.Uint16(src[4:])) item.KerningStart = Offset16(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetLeft != 0 { // ignore null offset @@ -243,7 +237,6 @@ func ParseKernData3(src []byte) (KernData3, int, error) { item.leftClassCount = src[3] item.RightClassCount = src[4] item.flags = src[5] - n += 6 { arrayLength := int(item.kernValueCount) @@ -308,7 +301,6 @@ func ParseOTKernSubtableHeader(src []byte) (OTKernSubtableHeader, int, error) { item.length = binary.BigEndian.Uint16(src[2:]) item.format = kernSTVersion(src[4]) item.Coverage = src[5] - n += 6 { var ( diff --git a/font/opentype/tables/maxp_gen.go b/font/opentype/tables/maxp_gen.go index 7639dcee..419ad300 100755 --- a/font/opentype/tables/maxp_gen.go +++ b/font/opentype/tables/maxp_gen.go @@ -18,7 +18,6 @@ func ParseMaxp(src []byte) (Maxp, int, error) { _ = src[5] // early bound checking item.version = maxpVersion(binary.BigEndian.Uint32(src[0:])) item.NumGlyphs = binary.BigEndian.Uint16(src[4:]) - n += 6 { var ( diff --git a/font/opentype/tables/name_gen.go b/font/opentype/tables/name_gen.go index ea57daa4..cf71c4f6 100755 --- a/font/opentype/tables/name_gen.go +++ b/font/opentype/tables/name_gen.go @@ -19,7 +19,6 @@ func ParseName(src []byte) (Name, int, error) { item.version = binary.BigEndian.Uint16(src[0:]) item.count = binary.BigEndian.Uint16(src[2:]) offsetStringData := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetStringData != 0 { // ignore null offset diff --git a/font/opentype/tables/os2_gen.go b/font/opentype/tables/os2_gen.go index d0f0154a..6cad4cc6 100755 --- a/font/opentype/tables/os2_gen.go +++ b/font/opentype/tables/os2_gen.go @@ -55,7 +55,6 @@ func ParseOs2(src []byte) (Os2, int, error) { item.STypoLineGap = int16(binary.BigEndian.Uint16(src[72:])) item.usWinAscent = binary.BigEndian.Uint16(src[74:]) item.usWinDescent = binary.BigEndian.Uint16(src[76:]) - n += 78 { diff --git a/font/opentype/tables/ot_gdef_gen.go b/font/opentype/tables/ot_gdef_gen.go index 74dc1da1..8fcc8168 100755 --- a/font/opentype/tables/ot_gdef_gen.go +++ b/font/opentype/tables/ot_gdef_gen.go @@ -37,7 +37,6 @@ func ParseAttachList(src []byte) (AttachList, int, error) { _ = src[3] // early bound checking offsetCoverage := int(binary.BigEndian.Uint16(src[0:])) arrayLengthAttachPoints := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { if offsetCoverage != 0 { // ignore null offset @@ -92,7 +91,6 @@ func ParseAttachPoint(src []byte) (AttachPoint, int, error) { return item, 0, fmt.Errorf("reading AttachPoint: "+"EOF: expected length: 2, got %d", L) } arrayLengthPointIndices := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -169,7 +167,6 @@ func ParseCaretValue3(src []byte) (CaretValue3, int, error) { item.caretValueFormat = binary.BigEndian.Uint16(src[0:]) item.Coordinate = int16(binary.BigEndian.Uint16(src[2:])) item.deviceOffset = Offset16(binary.BigEndian.Uint16(src[4:])) - n += 6 { @@ -217,7 +214,6 @@ func ParseClassDef1(src []byte) (ClassDef1, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) item.StartGlyphID = binary.BigEndian.Uint16(src[2:]) arrayLengthClassValueArray := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { @@ -243,7 +239,6 @@ func ParseClassDef2(src []byte) (ClassDef2, int, error) { _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthClassRangeRecords := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -295,7 +290,6 @@ func ParseCoverage1(src []byte) (Coverage1, int, error) { _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthGlyphs := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -321,7 +315,6 @@ func ParseCoverage2(src []byte) (Coverage2, int, error) { _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthRanges := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -351,7 +344,6 @@ func ParseGDEF(src []byte) (GDEF, int, error) { offsetAttachList := int(binary.BigEndian.Uint16(src[6:])) offsetLigCaretList := int(binary.BigEndian.Uint16(src[8:])) offsetMarkAttachClass := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetGlyphClassDef != 0 { // ignore null offset @@ -442,7 +434,6 @@ func ParseLigCaretList(src []byte) (LigCaretList, int, error) { _ = src[3] // early bound checking offsetCoverage := int(binary.BigEndian.Uint16(src[0:])) arrayLengthLigGlyphs := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { if offsetCoverage != 0 { // ignore null offset @@ -497,7 +488,6 @@ func ParseLigGlyph(src []byte) (LigGlyph, int, error) { return item, 0, fmt.Errorf("reading LigGlyph: "+"EOF: expected length: 2, got %d", L) } arrayLengthCaretValues := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -537,7 +527,6 @@ func ParseMarkGlyphSets(src []byte) (MarkGlyphSets, int, error) { _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthCoverages := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { diff --git a/font/opentype/tables/ot_gpos_gen.go b/font/opentype/tables/ot_gpos_gen.go index 2022ab32..d84e32f6 100755 --- a/font/opentype/tables/ot_gpos_gen.go +++ b/font/opentype/tables/ot_gpos_gen.go @@ -7,8 +7,6 @@ import ( "fmt" ) -//lint:file-ignore SA4006 The code generator is not smart enough to remove unused variables. - // Code generated by binarygen from ot_gpos_src.go. DO NOT EDIT func (item *AnchorFormat1) mustParse(src []byte) { @@ -101,7 +99,6 @@ func ParseAnchorFormat3(src []byte) (AnchorFormat3, int, error) { item.YCoordinate = int16(binary.BigEndian.Uint16(src[4:])) item.xDeviceOffset = Offset16(binary.BigEndian.Uint16(src[6:])) item.yDeviceOffset = Offset16(binary.BigEndian.Uint16(src[8:])) - n += 10 { @@ -127,7 +124,6 @@ func ParseBaseArray(src []byte, offsetsCount int) (BaseArray, int, error) { return item, 0, fmt.Errorf("reading BaseArray: "+"EOF: expected length: 2, got %d", L) } arrayLengthBaseRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -177,7 +173,6 @@ func ParseChainedContextualPos1(src []byte) (ChainedContextualPos1, int, error) item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthChainedSeqRuleSet := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -238,7 +233,6 @@ func ParseChainedContextualPos2(src []byte) (ChainedContextualPos2, int, error) offsetInputClassDef := int(binary.BigEndian.Uint16(src[6:])) offsetLookaheadClassDef := int(binary.BigEndian.Uint16(src[8:])) arrayLengthChainedClassSeqRuleSet := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetCoverage != 0 { // ignore null offset @@ -346,7 +340,6 @@ func ParseChainedContextualPos3(src []byte) (ChainedContextualPos3, int, error) _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthBacktrackCoverages := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -378,17 +371,16 @@ func ParseChainedContextualPos3(src []byte) (ChainedContextualPos3, int, error) return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: n + 2, got %d", L) } arrayLengthInputCoverages := int(binary.BigEndian.Uint16(src[n:])) - n += 2 { - if L := len(src); L < n+arrayLengthInputCoverages*2 { - return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+arrayLengthInputCoverages*2, L) + if L := len(src); L < n+2+arrayLengthInputCoverages*2 { + return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+2+arrayLengthInputCoverages*2, L) } item.InputCoverages = make([]Coverage, arrayLengthInputCoverages) // allocation guarded by the previous check for i := range item.InputCoverages { - offset := int(binary.BigEndian.Uint16(src[n+i*2:])) + offset := int(binary.BigEndian.Uint16(src[n+2+i*2:])) // ignore null offsets if offset == 0 { continue @@ -406,21 +398,20 @@ func ParseChainedContextualPos3(src []byte) (ChainedContextualPos3, int, error) } n += arrayLengthInputCoverages * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+4 { + return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: n + 4, got %d", L) } - arrayLengthLookaheadCoverages := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthLookaheadCoverages := int(binary.BigEndian.Uint16(src[n+2:])) { - if L := len(src); L < n+arrayLengthLookaheadCoverages*2 { - return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+arrayLengthLookaheadCoverages*2, L) + if L := len(src); L < n+4+arrayLengthLookaheadCoverages*2 { + return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+4+arrayLengthLookaheadCoverages*2, L) } item.LookaheadCoverages = make([]Coverage, arrayLengthLookaheadCoverages) // allocation guarded by the previous check for i := range item.LookaheadCoverages { - offset := int(binary.BigEndian.Uint16(src[n+i*2:])) + offset := int(binary.BigEndian.Uint16(src[n+4+i*2:])) // ignore null offsets if offset == 0 { continue @@ -438,21 +429,20 @@ func ParseChainedContextualPos3(src []byte) (ChainedContextualPos3, int, error) } n += arrayLengthLookaheadCoverages * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+6 { + return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: n + 6, got %d", L) } - arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n+4:])) { - if L := len(src); L < n+arrayLengthSeqLookupRecords*4 { - return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+arrayLengthSeqLookupRecords*4, L) + if L := len(src); L < n+6+arrayLengthSeqLookupRecords*4 { + return item, 0, fmt.Errorf("reading ChainedContextualPos3: "+"EOF: expected length: %d, got %d", n+6+arrayLengthSeqLookupRecords*4, L) } item.SeqLookupRecords = make([]SequenceLookupRecord, arrayLengthSeqLookupRecords) // allocation guarded by the previous check for i := range item.SeqLookupRecords { - item.SeqLookupRecords[i].mustParse(src[n+i*4:]) + item.SeqLookupRecords[i].mustParse(src[n+6+i*4:]) } n += arrayLengthSeqLookupRecords * 4 } @@ -494,7 +484,6 @@ func ParseChainedSequenceRule(src []byte) (ChainedSequenceRule, int, error) { return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: 2, got %d", L) } arrayLengthBacktrackSequence := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -512,54 +501,51 @@ func ParseChainedSequenceRule(src []byte) (ChainedSequenceRule, int, error) { return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: n + 2, got %d", L) } item.inputGlyphCount = binary.BigEndian.Uint16(src[n:]) - n += 2 { arrayLength := int(item.inputGlyphCount - 1) - if L := len(src); L < n+arrayLength*2 { - return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+arrayLength*2, L) + if L := len(src); L < n+2+arrayLength*2 { + return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+2+arrayLength*2, L) } item.InputSequence = make([]uint16, arrayLength) // allocation guarded by the previous check for i := range item.InputSequence { - item.InputSequence[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.InputSequence[i] = binary.BigEndian.Uint16(src[n+2+i*2:]) } n += arrayLength * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+4 { + return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: n + 4, got %d", L) } - arrayLengthLookaheadSequence := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthLookaheadSequence := int(binary.BigEndian.Uint16(src[n+2:])) { - if L := len(src); L < n+arrayLengthLookaheadSequence*2 { - return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+arrayLengthLookaheadSequence*2, L) + if L := len(src); L < n+4+arrayLengthLookaheadSequence*2 { + return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+4+arrayLengthLookaheadSequence*2, L) } item.LookaheadSequence = make([]uint16, arrayLengthLookaheadSequence) // allocation guarded by the previous check for i := range item.LookaheadSequence { - item.LookaheadSequence[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.LookaheadSequence[i] = binary.BigEndian.Uint16(src[n+4+i*2:]) } n += arrayLengthLookaheadSequence * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+6 { + return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: n + 6, got %d", L) } - arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n+4:])) { - if L := len(src); L < n+arrayLengthSeqLookupRecords*4 { - return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+arrayLengthSeqLookupRecords*4, L) + if L := len(src); L < n+6+arrayLengthSeqLookupRecords*4 { + return item, 0, fmt.Errorf("reading ChainedSequenceRule: "+"EOF: expected length: %d, got %d", n+6+arrayLengthSeqLookupRecords*4, L) } item.SeqLookupRecords = make([]SequenceLookupRecord, arrayLengthSeqLookupRecords) // allocation guarded by the previous check for i := range item.SeqLookupRecords { - item.SeqLookupRecords[i].mustParse(src[n+i*4:]) + item.SeqLookupRecords[i].mustParse(src[n+6+i*4:]) } n += arrayLengthSeqLookupRecords * 4 } @@ -573,7 +559,6 @@ func ParseChainedSequenceRuleSet(src []byte) (ChainedSequenceRuleSet, int, error return item, 0, fmt.Errorf("reading ChainedSequenceRuleSet: "+"EOF: expected length: 2, got %d", L) } arrayLengthChainedSeqRules := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -631,7 +616,6 @@ func ParseContextualPos1(src []byte) (ContextualPos1, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthSeqRuleSet := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -690,7 +674,6 @@ func ParseContextualPos2(src []byte) (ContextualPos2, int, error) { offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) offsetClassDef := int(binary.BigEndian.Uint16(src[4:])) arrayLengthClassSeqRuleSet := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetCoverage != 0 { // ignore null offset @@ -765,7 +748,6 @@ func ParseContextualPos3(src []byte) (ContextualPos3, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) item.glyphCount = binary.BigEndian.Uint16(src[2:]) item.seqLookupCount = binary.BigEndian.Uint16(src[4:]) - n += 6 { arrayLength := int(item.glyphCount) @@ -848,7 +830,6 @@ func ParseCursivePos(src []byte) (CursivePos, int, error) { item.posFormat = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthEntryExitRecords := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -938,7 +919,6 @@ func ParseExtensionPos(src []byte) (ExtensionPos, int, error) { item.substFormat = binary.BigEndian.Uint16(src[0:]) item.ExtensionLookupType = binary.BigEndian.Uint16(src[2:]) item.ExtensionOffset = Offset32(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -955,7 +935,6 @@ func ParseLigatureArray(src []byte, offsetsCount int) (LigatureArray, int, error return item, 0, fmt.Errorf("reading LigatureArray: "+"EOF: expected length: 2, got %d", L) } arrayLengthLigatureAttachs := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -993,7 +972,6 @@ func ParseLigatureAttach(src []byte, offsetsCount int) (LigatureAttach, int, err return item, 0, fmt.Errorf("reading LigatureAttach: "+"EOF: expected length: 2, got %d", L) } arrayLengthComponentRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -1023,7 +1001,6 @@ func ParseMark2Array(src []byte, offsetsCount int) (Mark2Array, int, error) { return item, 0, fmt.Errorf("reading Mark2Array: "+"EOF: expected length: 2, got %d", L) } arrayLengthMark2Records := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -1053,7 +1030,6 @@ func ParseMarkArray(src []byte) (MarkArray, int, error) { return item, 0, fmt.Errorf("reading MarkArray: "+"EOF: expected length: 2, got %d", L) } arrayLengthMarkRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -1090,7 +1066,6 @@ func ParseMarkBasePos(src []byte) (MarkBasePos, int, error) { item.markClassCount = binary.BigEndian.Uint16(src[6:]) offsetMarkArray := int(binary.BigEndian.Uint16(src[8:])) offsetBaseArray := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetMarkCoverage != 0 { // ignore null offset @@ -1170,7 +1145,6 @@ func ParseMarkLigPos(src []byte) (MarkLigPos, int, error) { item.MarkClassCount = binary.BigEndian.Uint16(src[6:]) offsetMarkArray := int(binary.BigEndian.Uint16(src[8:])) offsetLigatureArray := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetMarkCoverage != 0 { // ignore null offset @@ -1250,7 +1224,6 @@ func ParseMarkMarkPos(src []byte) (MarkMarkPos, int, error) { item.MarkClassCount = binary.BigEndian.Uint16(src[6:]) offsetMark1Array := int(binary.BigEndian.Uint16(src[8:])) offsetMark2Array := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetMark1Coverage != 0 { // ignore null offset @@ -1372,7 +1345,6 @@ func ParsePairPosData1(src []byte) (PairPosData1, int, error) { item.ValueFormat1 = ValueFormat(binary.BigEndian.Uint16(src[4:])) item.ValueFormat2 = ValueFormat(binary.BigEndian.Uint16(src[6:])) arrayLengthPairSets := int(binary.BigEndian.Uint16(src[8:])) - n += 10 { if offsetCoverage != 0 { // ignore null offset @@ -1435,7 +1407,6 @@ func ParsePairPosData2(src []byte) (PairPosData2, int, error) { offsetClassDef2 := int(binary.BigEndian.Uint16(src[10:])) item.class1Count = binary.BigEndian.Uint16(src[12:]) item.class2Count = binary.BigEndian.Uint16(src[14:]) - n += 16 { if offsetCoverage != 0 { // ignore null offset @@ -1489,6 +1460,7 @@ func ParsePairPosData2(src []byte) (PairPosData2, int, error) { } } { + item.classData = src[0:] } return item, n, nil @@ -1501,7 +1473,6 @@ func ParsePairSet(src []byte, valueFormat1 ValueFormat, valueFormat2 ValueFormat return item, 0, fmt.Errorf("reading PairSet: "+"EOF: expected length: 2, got %d", L) } item.pairValueCount = binary.BigEndian.Uint16(src[0:]) - n += 2 { @@ -1522,7 +1493,6 @@ func ParseSequenceRule(src []byte) (SequenceRule, int, error) { _ = src[3] // early bound checking item.glyphCount = binary.BigEndian.Uint16(src[0:]) item.seqLookupCount = binary.BigEndian.Uint16(src[2:]) - n += 4 { arrayLength := int(item.glyphCount - 1) @@ -1560,7 +1530,6 @@ func ParseSequenceRuleSet(src []byte) (SequenceRuleSet, int, error) { return item, 0, fmt.Errorf("reading SequenceRuleSet: "+"EOF: expected length: 2, got %d", L) } arrayLengthSeqRule := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -1644,7 +1613,6 @@ func ParseSinglePosData1(src []byte) (SinglePosData1, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) item.ValueFormat = ValueFormat(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -1684,7 +1652,6 @@ func ParseSinglePosData2(src []byte) (SinglePosData2, int, error) { offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) item.ValueFormat = ValueFormat(binary.BigEndian.Uint16(src[4:])) item.valueCount = binary.BigEndian.Uint16(src[6:]) - n += 8 { if offsetCoverage != 0 { // ignore null offset diff --git a/font/opentype/tables/ot_gsub_gen.go b/font/opentype/tables/ot_gsub_gen.go index 56a3e070..dbeb55c4 100755 --- a/font/opentype/tables/ot_gsub_gen.go +++ b/font/opentype/tables/ot_gsub_gen.go @@ -16,7 +16,6 @@ func ParseAlternateSet(src []byte) (AlternateSet, int, error) { return item, 0, fmt.Errorf("reading AlternateSet: "+"EOF: expected length: 2, got %d", L) } arrayLengthAlternateGlyphIDs := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -43,7 +42,6 @@ func ParseAlternateSubs(src []byte) (AlternateSubs, int, error) { item.substFormat = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthAlternateSets := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -118,7 +116,6 @@ func ParseChainedContextualSubs1(src []byte) (ChainedContextualSubs1, int, error item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthChainedSeqRuleSet := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -179,7 +176,6 @@ func ParseChainedContextualSubs2(src []byte) (ChainedContextualSubs2, int, error offsetInputClassDef := int(binary.BigEndian.Uint16(src[6:])) offsetLookaheadClassDef := int(binary.BigEndian.Uint16(src[8:])) arrayLengthChainedClassSeqRuleSet := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetCoverage != 0 { // ignore null offset @@ -287,7 +283,6 @@ func ParseChainedContextualSubs3(src []byte) (ChainedContextualSubs3, int, error _ = src[3] // early bound checking item.format = binary.BigEndian.Uint16(src[0:]) arrayLengthBacktrackCoverages := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -319,17 +314,16 @@ func ParseChainedContextualSubs3(src []byte) (ChainedContextualSubs3, int, error return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: n + 2, got %d", L) } arrayLengthInputCoverages := int(binary.BigEndian.Uint16(src[n:])) - n += 2 { - if L := len(src); L < n+arrayLengthInputCoverages*2 { - return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+arrayLengthInputCoverages*2, L) + if L := len(src); L < n+2+arrayLengthInputCoverages*2 { + return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+2+arrayLengthInputCoverages*2, L) } item.InputCoverages = make([]Coverage, arrayLengthInputCoverages) // allocation guarded by the previous check for i := range item.InputCoverages { - offset := int(binary.BigEndian.Uint16(src[n+i*2:])) + offset := int(binary.BigEndian.Uint16(src[n+2+i*2:])) // ignore null offsets if offset == 0 { continue @@ -347,21 +341,20 @@ func ParseChainedContextualSubs3(src []byte) (ChainedContextualSubs3, int, error } n += arrayLengthInputCoverages * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+4 { + return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: n + 4, got %d", L) } - arrayLengthLookaheadCoverages := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthLookaheadCoverages := int(binary.BigEndian.Uint16(src[n+2:])) { - if L := len(src); L < n+arrayLengthLookaheadCoverages*2 { - return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+arrayLengthLookaheadCoverages*2, L) + if L := len(src); L < n+4+arrayLengthLookaheadCoverages*2 { + return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+4+arrayLengthLookaheadCoverages*2, L) } item.LookaheadCoverages = make([]Coverage, arrayLengthLookaheadCoverages) // allocation guarded by the previous check for i := range item.LookaheadCoverages { - offset := int(binary.BigEndian.Uint16(src[n+i*2:])) + offset := int(binary.BigEndian.Uint16(src[n+4+i*2:])) // ignore null offsets if offset == 0 { continue @@ -379,21 +372,20 @@ func ParseChainedContextualSubs3(src []byte) (ChainedContextualSubs3, int, error } n += arrayLengthLookaheadCoverages * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+6 { + return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: n + 6, got %d", L) } - arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthSeqLookupRecords := int(binary.BigEndian.Uint16(src[n+4:])) { - if L := len(src); L < n+arrayLengthSeqLookupRecords*4 { - return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+arrayLengthSeqLookupRecords*4, L) + if L := len(src); L < n+6+arrayLengthSeqLookupRecords*4 { + return item, 0, fmt.Errorf("reading ChainedContextualSubs3: "+"EOF: expected length: %d, got %d", n+6+arrayLengthSeqLookupRecords*4, L) } item.SeqLookupRecords = make([]SequenceLookupRecord, arrayLengthSeqLookupRecords) // allocation guarded by the previous check for i := range item.SeqLookupRecords { - item.SeqLookupRecords[i].mustParse(src[n+i*4:]) + item.SeqLookupRecords[i].mustParse(src[n+6+i*4:]) } n += arrayLengthSeqLookupRecords * 4 } @@ -455,7 +447,6 @@ func ParseContextualSubs1(src []byte) (ContextualSubs1, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthSeqRuleSet := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -514,7 +505,6 @@ func ParseContextualSubs2(src []byte) (ContextualSubs2, int, error) { offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) offsetClassDef := int(binary.BigEndian.Uint16(src[4:])) arrayLengthClassSeqRuleSet := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { if offsetCoverage != 0 { // ignore null offset @@ -589,7 +579,6 @@ func ParseContextualSubs3(src []byte) (ContextualSubs3, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) item.glyphCount = binary.BigEndian.Uint16(src[2:]) item.seqLookupCount = binary.BigEndian.Uint16(src[4:]) - n += 6 { arrayLength := int(item.glyphCount) @@ -672,7 +661,6 @@ func ParseExtensionSubs(src []byte) (ExtensionSubs, int, error) { item.substFormat = binary.BigEndian.Uint16(src[0:]) item.ExtensionLookupType = binary.BigEndian.Uint16(src[2:]) item.ExtensionOffset = Offset32(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -691,7 +679,6 @@ func ParseLigature(src []byte) (Ligature, int, error) { _ = src[3] // early bound checking item.LigatureGlyph = binary.BigEndian.Uint16(src[0:]) item.componentCount = binary.BigEndian.Uint16(src[2:]) - n += 4 { arrayLength := int(item.componentCount - 1) @@ -716,7 +703,6 @@ func ParseLigatureSet(src []byte) (LigatureSet, int, error) { return item, 0, fmt.Errorf("reading LigatureSet: "+"EOF: expected length: 2, got %d", L) } arrayLengthLigatures := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -757,7 +743,6 @@ func ParseLigatureSubs(src []byte) (LigatureSubs, int, error) { item.substFormat = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthLigatureSets := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -815,7 +800,6 @@ func ParseMultipleSubs(src []byte) (MultipleSubs, int, error) { item.substFormat = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthSequences := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -873,7 +857,6 @@ func ParseReverseChainSingleSubs(src []byte) (ReverseChainSingleSubs, int, error item.substFormat = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthBacktrackCoverages := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -922,17 +905,16 @@ func ParseReverseChainSingleSubs(src []byte) (ReverseChainSingleSubs, int, error return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: n + 2, got %d", L) } arrayLengthLookaheadCoverages := int(binary.BigEndian.Uint16(src[n:])) - n += 2 { - if L := len(src); L < n+arrayLengthLookaheadCoverages*2 { - return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: %d, got %d", n+arrayLengthLookaheadCoverages*2, L) + if L := len(src); L < n+2+arrayLengthLookaheadCoverages*2 { + return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: %d, got %d", n+2+arrayLengthLookaheadCoverages*2, L) } item.LookaheadCoverages = make([]Coverage, arrayLengthLookaheadCoverages) // allocation guarded by the previous check for i := range item.LookaheadCoverages { - offset := int(binary.BigEndian.Uint16(src[n+i*2:])) + offset := int(binary.BigEndian.Uint16(src[n+2+i*2:])) // ignore null offsets if offset == 0 { continue @@ -950,21 +932,20 @@ func ParseReverseChainSingleSubs(src []byte) (ReverseChainSingleSubs, int, error } n += arrayLengthLookaheadCoverages * 2 } - if L := len(src); L < n+2 { - return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: n + 2, got %d", L) + if L := len(src); L < n+4 { + return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: n + 4, got %d", L) } - arrayLengthSubstituteGlyphIDs := int(binary.BigEndian.Uint16(src[n:])) - n += 2 + arrayLengthSubstituteGlyphIDs := int(binary.BigEndian.Uint16(src[n+2:])) { - if L := len(src); L < n+arrayLengthSubstituteGlyphIDs*2 { - return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: %d, got %d", n+arrayLengthSubstituteGlyphIDs*2, L) + if L := len(src); L < n+4+arrayLengthSubstituteGlyphIDs*2 { + return item, 0, fmt.Errorf("reading ReverseChainSingleSubs: "+"EOF: expected length: %d, got %d", n+4+arrayLengthSubstituteGlyphIDs*2, L) } item.SubstituteGlyphIDs = make([]uint16, arrayLengthSubstituteGlyphIDs) // allocation guarded by the previous check for i := range item.SubstituteGlyphIDs { - item.SubstituteGlyphIDs[i] = binary.BigEndian.Uint16(src[n+i*2:]) + item.SubstituteGlyphIDs[i] = binary.BigEndian.Uint16(src[n+4+i*2:]) } n += arrayLengthSubstituteGlyphIDs * 2 } @@ -978,7 +959,6 @@ func ParseSequence(src []byte) (Sequence, int, error) { return item, 0, fmt.Errorf("reading Sequence: "+"EOF: expected length: 2, got %d", L) } arrayLengthSubstituteGlyphIDs := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -1048,7 +1028,6 @@ func ParseSingleSubstData1(src []byte) (SingleSubstData1, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) item.DeltaGlyphID = int16(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset @@ -1080,7 +1059,6 @@ func ParseSingleSubstData2(src []byte) (SingleSubstData2, int, error) { item.format = binary.BigEndian.Uint16(src[0:]) offsetCoverage := int(binary.BigEndian.Uint16(src[2:])) arrayLengthSubstituteGlyphIDs := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { if offsetCoverage != 0 { // ignore null offset diff --git a/font/opentype/tables/ot_layout.go b/font/opentype/tables/ot_layout.go index ea146ff6..fcabf745 100644 --- a/font/opentype/tables/ot_layout.go +++ b/font/opentype/tables/ot_layout.go @@ -548,7 +548,6 @@ func parseValueRecord(format ValueFormat, data []byte, offset int) (out ValueRec return out, 0, err } } - cursor++ // useless actually } return out, offset + 2*size, err } diff --git a/font/opentype/tables/ot_layout_gen.go b/font/opentype/tables/ot_layout_gen.go index fcf1fdbb..ed9d98b3 100755 --- a/font/opentype/tables/ot_layout_gen.go +++ b/font/opentype/tables/ot_layout_gen.go @@ -35,7 +35,6 @@ func ParseConditionSet(src []byte) (ConditionSet, int, error) { return item, 0, fmt.Errorf("reading ConditionSet: "+"EOF: expected length: 2, got %d", L) } arrayLengthConditions := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -75,7 +74,6 @@ func ParseFeature(src []byte) (Feature, int, error) { _ = src[3] // early bound checking item.featureParamsOffset = binary.BigEndian.Uint16(src[0:]) arrayLengthLookupListIndices := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { @@ -99,7 +97,6 @@ func ParseFeatureList(src []byte) (FeatureList, int, error) { return item, 0, fmt.Errorf("reading FeatureList: "+"EOF: expected length: 2, got %d", L) } arrayLengthRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -133,7 +130,6 @@ func ParseFeatureTableSubstitution(src []byte) (FeatureTableSubstitution, int, e item.majorVersion = binary.BigEndian.Uint16(src[0:]) item.minorVersion = binary.BigEndian.Uint16(src[2:]) arrayLengthSubstitutions := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { @@ -160,7 +156,6 @@ func ParseFeatureTableSubstitutionRecord(src []byte, parentSrc []byte) (FeatureT _ = src[5] // early bound checking item.FeatureIndex = binary.BigEndian.Uint16(src[0:]) offsetAlternateFeature := int(binary.BigEndian.Uint32(src[2:])) - n += 6 { if offsetAlternateFeature != 0 { // ignore null offset @@ -189,7 +184,6 @@ func ParseFeatureVariation(src []byte) (FeatureVariation, int, error) { item.majorVersion = binary.BigEndian.Uint16(src[0:]) item.minorVersion = binary.BigEndian.Uint16(src[2:]) arrayLengthFeatureVariationRecords := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { @@ -216,7 +210,6 @@ func ParseFeatureVariationRecord(src []byte, parentSrc []byte) (FeatureVariation _ = src[7] // early bound checking offsetConditionSet := int(binary.BigEndian.Uint32(src[0:])) offsetSubstitutions := int(binary.BigEndian.Uint32(src[4:])) - n += 8 { if offsetConditionSet != 0 { // ignore null offset @@ -259,7 +252,6 @@ func ParseLangSys(src []byte) (LangSys, int, error) { item.lookupOrderOffset = binary.BigEndian.Uint16(src[0:]) item.RequiredFeatureIndex = binary.BigEndian.Uint16(src[2:]) arrayLengthFeatureIndices := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { @@ -288,7 +280,6 @@ func ParseLayout(src []byte) (Layout, int, error) { offsetScriptList := int(binary.BigEndian.Uint16(src[4:])) offsetFeatureList := int(binary.BigEndian.Uint16(src[6:])) offsetLookupList := int(binary.BigEndian.Uint16(src[8:])) - n += 10 { if offsetScriptList != 0 { // ignore null offset @@ -353,7 +344,6 @@ func ParseLookup(src []byte) (Lookup, int, error) { item.lookupType = binary.BigEndian.Uint16(src[0:]) item.LookupFlag = binary.BigEndian.Uint16(src[2:]) arrayLengthSubtableOffsets := int(binary.BigEndian.Uint16(src[4:])) - n += 6 { @@ -371,7 +361,6 @@ func ParseLookup(src []byte) (Lookup, int, error) { return item, 0, fmt.Errorf("reading Lookup: "+"EOF: expected length: n + 2, got %d", L) } item.MarkFilteringSet = binary.BigEndian.Uint16(src[n:]) - n += 2 { @@ -390,7 +379,6 @@ func ParseScript(src []byte) (Script, int, error) { _ = src[3] // early bound checking offsetDefaultLangSys := int(binary.BigEndian.Uint16(src[0:])) arrayLengthLangSysRecords := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { if offsetDefaultLangSys != 0 { // ignore null offset @@ -437,7 +425,6 @@ func ParseScriptList(src []byte) (ScriptList, int, error) { return item, 0, fmt.Errorf("reading ScriptList: "+"EOF: expected length: 2, got %d", L) } arrayLengthRecords := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -474,7 +461,6 @@ func parseLookupList(src []byte) (lookupList, int, error) { return item, 0, fmt.Errorf("reading lookupList: "+"EOF: expected length: 2, got %d", L) } arrayLengthLookups := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { diff --git a/font/opentype/tables/post_gen.go b/font/opentype/tables/post_gen.go index ec94d4c8..86a22bb0 100755 --- a/font/opentype/tables/post_gen.go +++ b/font/opentype/tables/post_gen.go @@ -25,7 +25,6 @@ func ParsePost(src []byte) (Post, int, error) { item.memoryUsage[1] = binary.BigEndian.Uint32(src[20:]) item.memoryUsage[2] = binary.BigEndian.Uint32(src[24:]) item.memoryUsage[3] = binary.BigEndian.Uint32(src[28:]) - n += 32 { var ( @@ -63,7 +62,6 @@ func ParsePostNames20(src []byte) (PostNames20, int, error) { return item, 0, fmt.Errorf("reading PostNames20: "+"EOF: expected length: 2, got %d", L) } arrayLengthGlyphNameIndexes := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { diff --git a/font/opentype/tables/xvar_gen.go b/font/opentype/tables/xvar_gen.go index eb194e84..6872c9ef 100755 --- a/font/opentype/tables/xvar_gen.go +++ b/font/opentype/tables/xvar_gen.go @@ -69,7 +69,6 @@ func ParseAvar(src []byte) (Avar, int, error) { item.minorVersion = binary.BigEndian.Uint16(src[2:]) item.reserved = binary.BigEndian.Uint16(src[4:]) arrayLengthAxisSegmentMaps := int(binary.BigEndian.Uint16(src[6:])) - n += 8 { @@ -161,7 +160,6 @@ func ParseAxisValue4(src []byte) (AxisValue4, int, error) { item.axisCount = binary.BigEndian.Uint16(src[2:]) item.flags = binary.BigEndian.Uint16(src[4:]) item.valueNameID = NameID(binary.BigEndian.Uint16(src[6:])) - n += 8 { arrayLength := int(item.axisCount) @@ -226,7 +224,6 @@ func ParseFvar(src []byte) (Fvar, int, error) { item.axisSize = binary.BigEndian.Uint16(src[10:]) item.instanceCount = binary.BigEndian.Uint16(src[12:]) item.instanceSize = binary.BigEndian.Uint16(src[14:]) - n += 16 { @@ -272,7 +269,6 @@ func ParseGlyphVariationData(src []byte, axisCount int) (GlyphVariationData, int _ = src[3] // early bound checking item.tupleVariationCount = binary.BigEndian.Uint16(src[0:]) offsetSerializedData := int(binary.BigEndian.Uint16(src[2:])) - n += 4 { if offsetSerializedData != 0 { // ignore null offset @@ -315,7 +311,6 @@ func ParseGvar(src []byte) (Gvar, int, error) { item.glyphCount = binary.BigEndian.Uint16(src[12:]) item.flags = binary.BigEndian.Uint16(src[14:]) item.glyphVariationDataArrayOffset = Offset32(binary.BigEndian.Uint32(src[16:])) - n += 20 { if offsetSharedTuples != 0 { // ignore null offset @@ -361,7 +356,6 @@ func ParseHVAR(src []byte) (HVAR, int, error) { offsetAdvanceWidthMapping := int(binary.BigEndian.Uint32(src[8:])) offsetLsbMapping := int(binary.BigEndian.Uint32(src[12:])) offsetRsbMapping := int(binary.BigEndian.Uint32(src[16:])) - n += 20 { if offsetItemVariationStore != 0 { // ignore null offset @@ -435,7 +429,6 @@ func ParseInstanceRecord(src []byte, coordinatesCount int) (InstanceRecord, int, _ = src[3] // early bound checking item.SubfamilyNameID = binary.BigEndian.Uint16(src[0:]) item.flags = binary.BigEndian.Uint16(src[2:]) - n += 4 { @@ -473,7 +466,6 @@ func ParseMVAR(src []byte) (MVAR, int, error) { item.valueRecordSize = binary.BigEndian.Uint16(src[6:]) item.valueRecordCount = binary.BigEndian.Uint16(src[8:]) offsetItemVariationStore := int(binary.BigEndian.Uint16(src[10:])) - n += 12 { if offsetItemVariationStore != 0 { // ignore null offset @@ -514,7 +506,6 @@ func ParseSTAT(src []byte) (STAT, int, error) { item.axisValueCount = binary.BigEndian.Uint16(src[12:]) offsetAxisValues := int(binary.BigEndian.Uint32(src[14:])) item.elidedFallbackNameID = binary.BigEndian.Uint16(src[18:]) - n += 20 { if offsetDesignAxes != 0 { // ignore null offset @@ -559,7 +550,6 @@ func ParseSegmentMaps(src []byte) (SegmentMaps, int, error) { return item, 0, fmt.Errorf("reading SegmentMaps: "+"EOF: expected length: 2, got %d", L) } arrayLengthAxisValueMaps := int(binary.BigEndian.Uint16(src[0:])) - n += 2 { @@ -622,7 +612,6 @@ func ParseTupleVariationHeader(src []byte, axisCount int) (TupleVariationHeader, _ = src[3] // early bound checking item.VariationDataSize = binary.BigEndian.Uint16(src[0:]) item.tupleIndex = binary.BigEndian.Uint16(src[2:]) - n += 4 { @@ -661,7 +650,6 @@ func ParseVVAR(src []byte) (VVAR, int, error) { return item, 0, fmt.Errorf("reading VVAR: "+"EOF: expected length: n + 4, got %d", L) } offsetVOrgMapping := int(binary.BigEndian.Uint32(src[n:])) - n += 4 { if offsetVOrgMapping != 0 { // ignore null offset diff --git a/harfbuzz/ot_shape_hangul.go b/harfbuzz/ot_shape_hangul.go index 681f4cad..f9f1c37d 100644 --- a/harfbuzz/ot_shape_hangul.go +++ b/harfbuzz/ot_shape_hangul.go @@ -296,7 +296,6 @@ func (cs *complexShaperHangul) preprocessText(_ *otShapePlan, buffer *Buffer, fo i++ if i < end { info[i].complexAux = tjmo - i++ } buffer.mergeOutClusters(start, end) diff --git a/harfbuzz/ot_shape_indic.go b/harfbuzz/ot_shape_indic.go index c1294e5f..5f6a007a 100644 --- a/harfbuzz/ot_shape_indic.go +++ b/harfbuzz/ot_shape_indic.go @@ -1319,10 +1319,6 @@ func (indicPlan *indicShapePlan) finalReorderingSyllableIndic(buffer *Buffer, st tmp := info[oldPos] copy(info[newPos+1:], info[newPos:oldPos]) info[newPos] = tmp - - if newPos <= base && base < oldPos { - base++ - } } }