jung-kurt / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/jung-kurt/gofpdf
MIT License
4.31k stars 777 forks source link

Fix for not concating already defined filepath #256

Closed toncek345 closed 5 years ago

toncek345 commented 5 years ago

With recent utf-8 support it is somewhat forgotten to add already defined font base dir. This fix is not backward compatible with already committed code in master.

pdf := gofpdf.NewCustom(&gofpdf.InitType{
    UnitStr: "mm",
    Size: gofpdf.SizeType{
        Wd: 100,
        Ht: 62,
    },
    FontDirStr: "./gofpdf/font",
})
pdf.AddUTF8Font("TimesNewRoman", "", "Times_New_Roman.ttf")
pdf.AddUTF8Font("TimesNewRoman", "B", "Times_New_Roman_Bold.ttf")
pdf.AddUTF8Font("TimesNewRoman", "I", "Times_New_Roman_Italic.ttf")
pdf.AddUTF8Font("TimesNewRoman", "BI", "Times_New_Roman_Bold_Italic.ttf")`

The code above didn't load fonts properly but with this fix code above will work.

jung-kurt commented 5 years ago

Thanks for the correction, @toncek345.