Skip to content

Commit

Permalink
Merge branch 'oliverpool-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jung-kurt committed Nov 19, 2019
2 parents 16955d8 + 32ecdd9 commit 603f569
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fpdf.go
Expand Up @@ -2709,6 +2709,10 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
ls = l
ns++
}
if int(c) >= len(cw) {
f.err = fmt.Errorf("character outside the supported range: %s", string(c))
return
}
if cw[int(c)] == 0 { //Marker width 0 used for missing symbols
l += f.currentFont.Desc.MissingWidth
} else if cw[int(c)] != 65535 { //Marker width 65535 used for zero width symbols
Expand Down
19 changes: 19 additions & 0 deletions fpdf_test.go
Expand Up @@ -2834,6 +2834,25 @@ func TestIssue0316(t *testing.T) {
}
}

func TestMultiCellUnsupportedChar(t *testing.T) {
pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddPage()
fontBytes, _ := ioutil.ReadFile(example.FontFile("DejaVuSansCondensed.ttf"))
pdf.AddUTF8FontFromBytes("dejavu", "", fontBytes)
pdf.SetFont("dejavu", "", 16)

defer func() {
if r := recover(); r != nil {
t.Errorf("unexpected panic: %v", r)
}
}()

pdf.MultiCell(0, 5, "😀", "", "", false)

fileStr := example.Filename("TestMultiCellUnsupportedChar")
pdf.OutputFileAndClose(fileStr)
}

// ExampleFpdf_SetTextRenderingMode demonstrates embedding files in PDFs,
// at the top-level.
func ExampleFpdf_SetAttachments() {
Expand Down

0 comments on commit 603f569

Please sign in to comment.