summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2019-05-06 21:22:13 -0400
committerKurt <kurt.w.jung@gmail.com>2019-05-06 21:22:13 -0400
commit641cda87ac3cf98cf58400cb3ce7513b6cc74295 (patch)
tree47d47bfe0e719b94d8852cece5522fa3db7a610c
parent7e2fd5e62062f910ad6fe58dcca97a7e69b85bb3 (diff)
Check for errors when loading UTF-8 font
-rw-r--r--fpdf.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/fpdf.go b/fpdf.go
index cd87ad9..0195cd3 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -1599,17 +1599,26 @@ func (f *Fpdf) addFont(familyStr, styleStr, fileStr string, isUTF8 bool) {
if ok {
return
}
- ttfStat, _ := os.Stat(fileStr)
+ var ttfStat os.FileInfo
+ var err error
+ ttfStat, err = os.Stat(fileStr)
+ if err != nil {
+ f.SetError(err)
+ return
+ }
originalSize := ttfStat.Size()
Type := "UTF8"
-
- utf8Bytes, _ := ioutil.ReadFile(fileStr)
+ var utf8Bytes []byte
+ utf8Bytes, err = ioutil.ReadFile(fileStr)
+ if err != nil {
+ f.SetError(err)
+ return
+ }
reader := fileReader{readerPosition: 0, array: utf8Bytes}
utf8File := newUTF8Font(&reader)
-
- err := utf8File.parseFile()
+ err = utf8File.parseFile()
if err != nil {
- fmt.Printf("get metrics Error: %e\n", err)
+ f.SetError(err)
return
}