Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions fpdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2939,7 +2939,7 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
}
continue
}
if c == ' ' || isChinese(c) {
if c == ' ' {
sep = i
ls = l
ns++
Expand Down Expand Up @@ -3073,7 +3073,12 @@ func (f *Fpdf) write(h float64, txtStr string, link int, linkStr string) {
if c == ' ' {
sep = i
}
l += float64(cw[int(c)])

if cw[int(c)] == 0 { //Marker width 0 used for missing symbols
l += float64(f.currentFont.Desc.MissingWidth)
} else if cw[int(c)] != 65535 { //Marker width 65535 used for zero width symbols
l += float64(cw[int(c)])
}
if l > wmax {
// Automatic line break
if sep == -1 {
Expand Down
4 changes: 2 additions & 2 deletions splittext.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func (f *Fpdf) SplitText(txt string, w float64) (lines []string) {
if int(c) >= len(cw) {
// Decimal representation of c is greater than the font width's array size so it can't be used as index.
l += cw[f.currentFont.Desc.MissingWidth]
} else {
} else if cw[c] != 65535 { //Marker width 65535 used for zero width symbols
l += cw[c]
}

if unicode.IsSpace(c) || isChinese(c) {
if unicode.IsSpace(c) {
sep = i
}
if c == '\n' || l > wmax {
Expand Down
8 changes: 0 additions & 8 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,14 +415,6 @@ func remove(arr []int, key int) []int {
return append(arr[:n], arr[n+1:]...)
}

func isChinese(rune2 rune) bool {
// chinese unicode: 4e00-9fa5
if rune2 >= rune(0x4e00) && rune2 <= rune(0x9fa5) {
return true
}
return false
}

// Condition font family string to PDF name compliance. See section 5.3 (Names)
// in https://resources.infosecinstitute.com/pdf-file-format-basic-structure/
func fontFamilyEscape(familyStr string) (escStr string) {
Expand Down