diff options
| author | JUN JIE NAN <nanjunjie@gmail.com> | 2019-06-12 14:53:58 +0800 |
|---|---|---|
| committer | JUN JIE NAN <nanjunjie@gmail.com> | 2019-06-12 14:53:58 +0800 |
| commit | db11935940567444dd230820da9a14acef0c96c2 (patch) | |
| tree | 03ce775cb2a07c894729edbe5535013ee0b67945 /utf8fontfile.go | |
| parent | 8060f8371088d63b5935a6eeb617328705387ace (diff) | |
Added UTF8CutFont
With function `UTF8CutFont`, customized ttf font file(usually with
small size) can be generated via gofpdf.
Diffstat (limited to 'utf8fontfile.go')
| -rw-r--r-- | utf8fontfile.go | 16 |
1 files changed, 16 insertions, 0 deletions
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 +} |
