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

Hope it can be solved. Font file error, throw an exception or skip #330

Open givetimetolife opened 4 years ago

givetimetolife commented 4 years ago

When I use a font file to write PDF, when the file contains unsupported characters. Expect to return an obvious error instead of an error "jung-kurt/gofpdf/fpdf.go:2789". Or you can skip unsupported data,Continue to write。

location: jung-kurt/gofpdf/fpdf.go:2789 ==》 l += float64(cw[int(c)])

error: panic: runtime error: index out of range [127775] with length 65536 [recovered] panic: runtime error: index out of range [127775] with length 65536

jung-kurt commented 4 years ago

This is related to a shortcoming discussed in #255. The contributor of the UTF-8 code has not made any comments about this.

Or you can skip unsupported data,Continue to write

I think this is the most practical expedient at this point.

jung-kurt commented 4 years ago

337 fixes this when it occurs within a call to MultiCell(). An error will be returned in the case of an out-of-range rune. Errors can be handled as described in the documentaiton.