gofpdf
gofpdf copied to clipboard
Add Chinese support
I've seen some suggestions for adding Chinese support, but all have been closed. So, I raise it once again because that will benefit a lot of people! And I found that another package (https://github.com/signintech/gopdf) has supported some utf-8 languages. Does that help in fixing this issue here?
Does that help in fixing this issue here?
It may. But since font management touches so much of gofpdf, it may be more beneficial to consider a new branch that carries over features from gofpdf and lays them on top of gopdf.
pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddUTF8Font("NotoSansSC-Regular", "", "NotoSansSC-Regular.ttf")
pdf.SetFont("NotoSansSC-Regular", "", 16)
pdf.Cell(49, 10, "中文,你好!")
You can download the NotoSansSC-Regular.ttf
file from https://github.com/jsntn/webfonts/, put it under your current directory.
Just ran into this problem, thanks the hints from @nanjj.
I would like to provide another open source family "Source Han Sans" font for Japanese, Korean, Simplified Chinese, and Traditional Chinese.
Note for Traditional Chinese and Japanese developers, there is a TTF converted version base on Source Han Sans. Download .ttf
from here https://github.com/ButTaiwan/gensen-font