diff options
author | Kurt Jung <kurt.w.jung@code.google.com> | 2014-08-22 20:02:52 -0400 |
---|---|---|
committer | Kurt Jung <kurt.w.jung@code.google.com> | 2014-08-22 20:02:52 -0400 |
commit | 5212485284df2c6ad88f2af101af38e3852c1004 (patch) | |
tree | 83cdd96c7718e3687a4993e64d9a6079dd0dbf08 /fpdf.go | |
parent | e869d1301c550b65bb6b9720a5ba98423861a735 (diff) |
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.
Diffstat (limited to 'fpdf.go')
-rw-r--r-- | fpdf.go | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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 } |