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

Spaces in Chinese #276

Open achafer opened 5 years ago

achafer commented 5 years ago

Hi, I found that when there are spaces in Chinese paragraphs, The final output style is not what I want

pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddUTF8Font("notosanssc", "", "../webfonts/NotoSansSC-Regular.ttf")
pdf.AddPage()
pdf.SetFont("notosanssc", "", 16)
str := "gofpdf支持UTF-8 TrueType字体和“right-to-left”语言。" +
    "请注意,许多通用字体中可能不包含中文、日文和 韩文字符。对于这些语言," +
    "可以使用专门的字体(例如,NotoSansSC 简体中文的字体)。"
pdf.MultiCell(0, 16, str, "", "L", false)
if err := pdf.OutputFileAndClose("hello.pdf"); err != nil {
    log.Fatal(err)
}

Output:

image

jung-kurt commented 5 years ago

Thanks for the report, @achafer. Any insights, @DarkFreedman?

jung-kurt commented 5 years ago

@achafer, can you confirm that this works as expected now?

ArtemKor commented 4 years ago

This space is part of glyphs. I used another font and got normal result anotherfont