gofpdf icon indicating copy to clipboard operation
gofpdf copied to clipboard

Charset weirdness despite using core PDF fonts

Open dmoles opened this issue 3 years ago • 0 comments

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:

  • Bullet is written to rendered PDF

Actual:

  • Rendered PDF shows •

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?

dmoles avatar Jun 20 '21 07:06 dmoles