summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorWilk <flibustenet@users.noreply.github.com>2018-11-16 12:21:38 +0100
committerKurt Jung <kurt.w.jung@gmail.com>2018-11-16 06:21:38 -0500
commit76dbd3f09366910f918201e7efb42b9da1aaffe4 (patch)
tree05258ded46e214ac6691a21398786713cb1fb4a3 /fpdf.go
parent2969a68dc5e762d0d5b8aac519058a9f73320316 (diff)
Make SplitLines and MultiCell split at the same place (#210)
* Make SplitLines and MultiCell split at the same place * Use integer math for SplitLines and MultiCell
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/fpdf.go b/fpdf.go
index 1e324b1..fbe980b 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -2180,7 +2180,7 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
if w == 0 {
w = f.w - f.rMargin - f.x
}
- wmax := (w - 2*f.cMargin) * 1000 / f.fontSize
+ wmax := int(math.Ceil((w - 2*f.cMargin) * 1000 / f.fontSize))
s := strings.Replace(txtStr, "\r", "", -1)
nb := len(s)
// if nb > 0 && s[nb-1:nb] == "\n" {
@@ -2214,8 +2214,8 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
sep := -1
i := 0
j := 0
- l := 0.0
- ls := 0.0
+ l := 0
+ ls := 0
ns := 0
nl := 1
for i < nb {
@@ -2244,7 +2244,7 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
ls = l
ns++
}
- l += float64(cw[c])
+ l += cw[c]
if l > wmax {
// Automatic line break
if sep == -1 {
@@ -2259,7 +2259,7 @@ func (f *Fpdf) MultiCell(w, h float64, txtStr, borderStr, alignStr string, fill
} else {
if alignStr == "J" {
if ns > 1 {
- f.ws = (wmax - ls) / 1000 * f.fontSize / float64(ns-1)
+ f.ws = float64((wmax-ls)/1000) * f.fontSize / float64(ns-1)
} else {
f.ws = 0
}