From 2e803db13067e702208818c79d70bd0ad1b13370 Mon Sep 17 00:00:00 2001 From: DarkFreedman Date: Fri, 4 Oct 2019 13:24:05 +0300 Subject: Pre Merge --- fpdf.go | 2 +- utf8fontfile.go | 23 ++++++++--------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/fpdf.go b/fpdf.go index 5486842..f5062cc 100644 --- a/fpdf.go +++ b/fpdf.go @@ -4033,7 +4033,7 @@ func (f *Fpdf) putfonts() { fontName := "utf8" + font.Name usedRunes := font.usedRunes delete(usedRunes, 0) - utf8FontStream := font.utf8File.GenerateCutFont(usedRunes) + utf8FontStream := font.utf8File.GenerateСutFont(usedRunes) utf8FontSize := len(utf8FontStream) compressedFontStream := sliceCompress(utf8FontStream) CodeSignDictionary := font.utf8File.CodeSymbolDictionary diff --git a/utf8fontfile.go b/utf8fontfile.go index 85b3ce4..4d90f28 100644 --- a/utf8fontfile.go +++ b/utf8fontfile.go @@ -75,13 +75,6 @@ func (fr *fileReader) Read(s int) []byte { return b } -func (fr *fileReader) ReadLikeCopy(s int) []byte { - b := make([]byte, 0, s) - b = append(b, fr.array[fr.readerPosition:fr.readerPosition+int64(s)]...) - fr.readerPosition += int64(s) - return b -} - func (fr *fileReader) seek(shift int64, flag int) (int64, error) { if flag == 0 { fr.readerPosition = shift @@ -232,7 +225,7 @@ func (utf *utf8FontFile) insertUint16(stream []byte, offset int, value int) []by } func (utf *utf8FontFile) getRange(pos, length int) []byte { - _, _ = utf.fileReader.seek(int64(pos), 0) + utf.fileReader.seek(int64(pos), 0) if length < 1 { return make([]byte, 0) } @@ -248,8 +241,8 @@ func (utf *utf8FontFile) getTableData(name string) []byte { if desckrip.size == 0 { return nil } - _, _ = utf.fileReader.seek(int64(desckrip.position), 0) - s := utf.fileReader.ReadLikeCopy(desckrip.size) + utf.fileReader.seek(int64(desckrip.position), 0) + s := utf.fileReader.Read(desckrip.size) return s } @@ -641,8 +634,8 @@ func (utf *utf8FontFile) generateCMAPTable(cidSymbolPairCollection map[int]int, return cmapstr } -//GenerateCutFont fill utf8FontFile from .utf file, only with runes from usedRunes -func (utf *utf8FontFile) GenerateCutFont(usedRunes map[int]int) []byte { +//GenerateСutFont fill utf8FontFile from .utf file, only with runes from usedRunes +func (utf *utf8FontFile) GenerateСutFont(usedRunes map[int]int) []byte { utf.fileReader.readerPosition = 0 utf.symbolPosition = make([]int, 0) utf.charSymbolDictionary = make(map[int]int) @@ -896,10 +889,10 @@ func (utf *utf8FontFile) getMetrics(metricCount, gid int) []byte { var metrics []byte if gid < metricCount { utf.seek(start + (gid * 4)) - metrics = utf.fileReader.ReadLikeCopy(4) + metrics = utf.fileReader.Read(4) } else { utf.seek(start + ((metricCount - 1) * 4)) - metrics = utf.fileReader.ReadLikeCopy(2) + metrics = utf.fileReader.Read(2) utf.seek(start + (metricCount * 2) + (gid * 2)) metrics = append(metrics, utf.fileReader.Read(2)...) } @@ -1155,6 +1148,6 @@ func UTF8CutFont(inBuf []byte, cutset string) (outBuf []byte) { for i, r := range cutset { runes[i] = int(r) } - outBuf = f.GenerateCutFont(runes) + outBuf = f.GenerateСutFont(runes) return } -- cgit v1.2.1-24-ge1ad