gofpdf icon indicating copy to clipboard operation
gofpdf copied to clipboard

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

Open givetimetolife opened this issue 5 years ago • 2 comments

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

givetimetolife avatar Nov 01 '19 07:11 givetimetolife

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 avatar Nov 01 '19 11:11 jung-kurt

#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.

jung-kurt avatar Nov 19 '19 18:11 jung-kurt