From db11935940567444dd230820da9a14acef0c96c2 Mon Sep 17 00:00:00 2001 From: JUN JIE NAN Date: Wed, 12 Jun 2019 14:53:58 +0800 Subject: Added UTF8CutFont With function `UTF8CutFont`, customized ttf font file(usually with small size) can be generated via gofpdf. --- utf8fontfile.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'utf8fontfile.go') diff --git a/utf8fontfile.go b/utf8fontfile.go index 794bae2..07cf169 100644 --- a/utf8fontfile.go +++ b/utf8fontfile.go @@ -1138,3 +1138,19 @@ func keySortArrayRangeMap(s map[int][]int) []int { sort.Ints(keys) return keys } + +// UTF8CutFont cuts a set in cutset and returns the customized font bytes +// Parameters: +// in - the ttf bytes in, +// cutset - the cutset runes in string, +// Returns: +// out - the ttf bytes out, +func UTF8CutFont(in []byte, cutset string) (out []byte) { + f := newUTF8Font(&fileReader{readerPosition: 0, array: in}) + runes := map[int]int{} + for i, r := range cutset { + runes[i] = int(r) + } + out = f.GenerateСutFont(runes) + return +} -- cgit v1.2.1-24-ge1ad