phpdave11 / gofpdf

A PDF document generator with high level support for text, drawing and images
http://godoc.org/github.com/phpdave11/gofpdf
MIT License
215 stars 43 forks source link

Charset weirdness despite using core PDF fonts #19

Open dmoles opened 3 years ago

dmoles commented 3 years ago

Steps to reproduce:

  1. create a new *gofpdf.FPDF:

    pdf := gofpdf.New("P", "pt", "Letter", "")
  2. set the font to Courier 12:

    pdf.SetFont("courier", "", 12)
  3. write a bullet character, (U+2022):

    pdf.Write("•", 12)
  4. write the PDF to a file:

    f, err := os.Create("/tmp/output.pdf")
    if err != nil {
    t.Fatal(err)
    }
    defer f.Close()
    
    pdf.Output(f)

Expected:

Actual:

Discussion:

I admit, I haven't dug deep enough to quite get the state of GoFPF UTF-8 support. My first thought was that I needed to add UTF-8 font, but according to the AddUTF8Font docs,

It is not necessary to call this function for the core PDF fonts (courier, helvetica, times, zapfdingbats).

Regardless, is that the workaround? Or is there a workaround? Are we currently limited to certain code pages?