From d0f2d2e94a89ab84c0c647ebb0873f43593d89fd Mon Sep 17 00:00:00 2001
From: Stanislav Seletskiy <s.seletskiy@gmail.com>
Date: Thu, 18 Jul 2019 15:41:13 +0300
Subject: fix bug introduced in #279

---
 fpdf.go | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fpdf.go b/fpdf.go
index b3d0b0e..f46680b 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -2819,7 +2819,6 @@ func (f *Fpdf) WriteAligned(width, lineHeight float64, textStr, alignStr string)
 		lineStr := string(lineBt)
 		lineWidth := f.GetStringWidth(lineStr)
 
-		f.SetLeftMargin(lMargin + (width - lineWidth) - 2.01*f.cMargin)
 		switch alignStr {
 		case "C":
 			f.SetLeftMargin(lMargin + ((width - lineWidth) / 2))
@@ -2830,9 +2829,10 @@ func (f *Fpdf) WriteAligned(width, lineHeight float64, textStr, alignStr string)
 			f.Write(lineHeight, lineStr)
 			f.SetLeftMargin(lMargin)
 		default:
+			f.SetRightMargin(pageWidth - lMargin - width)
 			f.Write(lineHeight, lineStr)
+			f.SetRightMargin(rMargin)
 		}
-		f.SetRightMargin(rMargin)
 	}
 }
 
-- 
cgit v1.2.1-24-ge1ad