diff options
Diffstat (limited to 'utf8fontfile.go')
-rw-r--r-- | utf8fontfile.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/utf8fontfile.go b/utf8fontfile.go index 964e919..4d90f28 100644 --- a/utf8fontfile.go +++ b/utf8fontfile.go @@ -377,7 +377,7 @@ func (utf *utf8FontFile) parseHHEATable() int { } func (utf *utf8FontFile) parseOS2Table() int { - weightType := 0 + var weightType int scale := 1000.0 / float64(utf.fontElementSize) if _, OK := utf.tableDescriptions["OS/2"]; OK { utf.SeekTable("OS/2") @@ -831,9 +831,9 @@ func (utf *utf8FontFile) getSymbols(originalSymbolIdx int, start *int, symbolSet } func (utf *utf8FontFile) parseHMTXTable(numberOfHMetrics, numSymbols int, symbolToChar map[int][]int, scale float64) { + var widths int start := utf.SeekTable("hmtx") arrayWidths := 0 - widths := 0 var arr []int utf.CharWidths = make([]int, 256*256) charCount := 0 @@ -863,8 +863,6 @@ func (utf *utf8FontFile) parseHMTXTable(numberOfHMetrics, numSymbols int, symbol } } } - data := utf.getRange(start+numberOfHMetrics*4, numSymbols*2) - arr = unpackUint16Array(data) diff := numSymbols - numberOfHMetrics for pos := 0; pos < diff; pos++ { symbol := pos + numberOfHMetrics @@ -949,7 +947,7 @@ func (utf *utf8FontFile) generateSCCSDictionaries(runeCmapPosition int, symbolCh for i := 0; i < segmentSize; i++ { positions = append(positions, utf.readUint16()) } - symbol := 0 + var symbol int for n := 0; n < segmentSize; n++ { completePosition := completers[n] + 1 for char := beginners[n]; char < completePosition; char++ { @@ -1140,3 +1138,16 @@ func keySortArrayRangeMap(s map[int][]int) []int { sort.Ints(keys) return keys } + +// UTF8CutFont is a utility function that generates a TrueType font composed +// only of the runes included in cutset. The rune glyphs are copied from This +// function is demonstrated in ExampleUTF8CutFont(). +func UTF8CutFont(inBuf []byte, cutset string) (outBuf []byte) { + f := newUTF8Font(&fileReader{readerPosition: 0, array: inBuf}) + runes := map[int]int{} + for i, r := range cutset { + runes[i] = int(r) + } + outBuf = f.GenerateСutFont(runes) + return +} |