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.29k stars 772 forks source link

How to support Chinese, Japanese, Korean and other languages at the same time? #323

Closed givetimetolife closed 4 years ago

givetimetolife commented 4 years ago

As title,Hope to get a solution, thank you

jung-kurt commented 4 years ago

If you cannot find a TrueType font that contains all of the glyphs you need, you will have to load them separately.

pdf.AddUTF8Font("Chinese", "", "/path/to/chinese_font.ttf")
pdf.AddUTF8Font("Japanese", "", "/path/to/japanese_font.ttf")
pdf.AddUTF8Font("Korean", "", "/path/to/korean_font.ttf")
pdf.SetFont("Chinese", "", 12)
pdf.Write(16, "你好 ")
pdf.SetFont("Japanese", "", 12)
pdf.Write(16, "こんにちは ")
pdf.SetFont("Korean", "", 12)
pdf.Write(16, "여보세요 ")
givetimetolife commented 4 years ago

Thank you for your reply! Let me try

givetimetolife commented 4 years ago

unfortunately, i can ' t find a font that has all the truetypes i need, and a single load doesn ' t fit my needs。pdf.Write(16, "샤오케您好シャオ・ケ")

jung-kurt commented 4 years ago

One manually intensive, fragile solution would be to write a script that identifies each UTF-8 code point that you need. Then you could use some font tool to generate your own custom font. I am not familiar with any tools that can do this, but I imagine they are out there.

givetimetolife commented 4 years ago

Yes, I can use multiple language TTF files to generate the font files I need. Thank you again for