From 5212485284df2c6ad88f2af101af38e3852c1004 Mon Sep 17 00:00:00 2001 From: Kurt Jung Date: Fri, 22 Aug 2014 20:02:52 -0400 Subject: Embed core font definition files and the 1252 code page in the application. Only if a non-core font or non-default code page is used does an actual font directory need to be specified when creating an Fpdf instance. --- fpdf.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'fpdf.go') diff --git a/fpdf.go b/fpdf.go index dd7d957..db59b3d 100644 --- a/fpdf.go +++ b/fpdf.go @@ -200,7 +200,10 @@ func NewCustom(init *InitType) (f *Fpdf) { // "Letter", or "Legal". An empty string will be replaced with "A4". // // fontDirStr specifies the file system location in which font resources will -// be found. An empty string is replaced with ".". +// be found. An empty string is replaced with ".". This argument only needs to +// reference an actual directory if a font other than one of the core +// fonts is used. The core fonts are "courier", "helvetica" (also called +// "arial"), "times", and "zapfdingbats" (also called "symbol"). func New(orientationStr, unitStr, sizeStr, fontDirStr string) (f *Fpdf) { return fpdfNew(orientationStr, unitStr, sizeStr, fontDirStr, SizeType{0, 0}) } @@ -1386,13 +1389,19 @@ func (f *Fpdf) SetFont(familyStr, styleStr string, size float64) { } _, ok = f.coreFonts[familyStr] if ok { - if familyStr == "symbol" || familyStr == "zapfdingbats" { + if familyStr == "symbol" { + familyStr = "zapfdingbats" + } + if familyStr == "zapfdingbats" { styleStr = "" } fontkey = familyStr + styleStr _, ok = f.fonts[fontkey] if !ok { - f.AddFont(familyStr, styleStr, "") + rdr := f.coreFontReader(familyStr, styleStr) + if f.err == nil { + f.AddFontFromReader(familyStr, styleStr, rdr) + } if f.err != nil { return } -- cgit v1.2.1-24-ge1ad