Skip to content
This repository was archived by the owner on Nov 13, 2021. It is now read-only.

Commit 603f569

Browse files
committed
Merge branch 'oliverpool-master'
2 parents 16955d8 + 32ecdd9 commit 603f569

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

fpdf.go

+4
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,10 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
27092709
ls = l
27102710
ns++
27112711
}
2712+
if int(c) >= len(cw) {
2713+
f.err = fmt.Errorf("character outside the supported range: %s", string(c))
2714+
return
2715+
}
27122716
if cw[int(c)] == 0 { //Marker width 0 used for missing symbols
27132717
l += f.currentFont.Desc.MissingWidth
27142718
} else if cw[int(c)] != 65535 { //Marker width 65535 used for zero width symbols

fpdf_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -2834,6 +2834,25 @@ func TestIssue0316(t *testing.T) {
28342834
}
28352835
}
28362836

2837+
func TestMultiCellUnsupportedChar(t *testing.T) {
2838+
pdf := gofpdf.New("P", "mm", "A4", "")
2839+
pdf.AddPage()
2840+
fontBytes, _ := ioutil.ReadFile(example.FontFile("DejaVuSansCondensed.ttf"))
2841+
pdf.AddUTF8FontFromBytes("dejavu", "", fontBytes)
2842+
pdf.SetFont("dejavu", "", 16)
2843+
2844+
defer func() {
2845+
if r := recover(); r != nil {
2846+
t.Errorf("unexpected panic: %v", r)
2847+
}
2848+
}()
2849+
2850+
pdf.MultiCell(0, 5, "😀", "", "", false)
2851+
2852+
fileStr := example.Filename("TestMultiCellUnsupportedChar")
2853+
pdf.OutputFileAndClose(fileStr)
2854+
}
2855+
28372856
// ExampleFpdf_SetTextRenderingMode demonstrates embedding files in PDFs,
28382857
// at the top-level.
28392858
func ExampleFpdf_SetAttachments() {

0 commit comments

Comments
 (0)