summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdf.go25
-rw-r--r--fpdf_test.go10
2 files changed, 18 insertions, 17 deletions
diff --git a/fpdf.go b/fpdf.go
index 18ab3b0..2c6d7c1 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -985,13 +985,13 @@ func (f *Fpdf) SetDashPattern(dashArray []float64, dashPhase float64) {
scaled[i] = value * f.k
}
dashPhase *= f.k
- if !slicesEqual(scaled, f.dashArray) || dashPhase != f.dashPhase {
- f.dashArray = scaled
- f.dashPhase = dashPhase
- if f.page > 0 {
- f.outputDashPattern()
- }
+
+ f.dashArray = scaled
+ f.dashPhase = dashPhase
+ if f.page > 0 {
+ f.outputDashPattern()
}
+
}
func (f *Fpdf) outputDashPattern() {
@@ -1234,7 +1234,7 @@ func (f *Fpdf) GetAlpha() (alpha float64, blendModeStr string) {
// To reset normal rendering after applying a blending mode, call this method
// with alpha set to 1.0 and blendModeStr set to "Normal".
func (f *Fpdf) SetAlpha(alpha float64, blendModeStr string) {
- if f.err != nil || (alpha == f.alpha && blendModeStr == f.blendMode) {
+ if f.err != nil {
return
}
var bl blendModeType
@@ -1742,10 +1742,7 @@ func (f *Fpdf) SetFont(familyStr, styleStr string, size float64) {
if size == 0.0 {
size = f.fontSizePt
}
- // Test if font is already selected
- if f.fontFamily == familyStr && f.fontStyle == styleStr && f.fontSizePt == size {
- return
- }
+
// Test if font is already loaded
fontkey := familyStr + styleStr
_, ok = f.fonts[fontkey]
@@ -1793,9 +1790,6 @@ func (f *Fpdf) SetFont(familyStr, styleStr string, size float64) {
// SetFontSize defines the size of the current font. Size is specified in
// points (1/ 72 inch). See also SetFontUnitSize().
func (f *Fpdf) SetFontSize(size float64) {
- if f.fontSizePt == size {
- return
- }
f.fontSizePt = size
f.fontSize = size / f.k
if f.page > 0 {
@@ -1806,9 +1800,6 @@ func (f *Fpdf) SetFontSize(size float64) {
// SetFontUnitSize defines the size of the current font. Size is specified in
// the unit of measure specified in New(). See also SetFontSize().
func (f *Fpdf) SetFontUnitSize(size float64) {
- if f.fontSize == size {
- return
- }
f.fontSizePt = size * f.k
f.fontSize = size
if f.page > 0 {
diff --git a/fpdf_test.go b/fpdf_test.go
index 34b824c..92ac3d9 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -2448,6 +2448,8 @@ func ExampleFpdf_SetFillColor() {
pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddPage()
+ pdf.SetFont("Arial", "", 12)
+
pdf.TransformBegin()
pdf.TransformTranslateX(5)
pdf.TransformTranslateY(5)
@@ -2455,7 +2457,11 @@ func ExampleFpdf_SetFillColor() {
pdf.SetLineWidth(2)
pdf.SetDrawColor(128, 64, 0)
pdf.SetFillColor(255, 127, 0)
+ pdf.SetAlpha(0.5, "Normal")
+ pdf.SetDashPattern([]float64{5, 10}, 0)
pdf.Rect(0, 0, 20, 20, "FD")
+ pdf.SetFontSize(8)
+ pdf.Write(10, "Test")
pdf.TransformEnd()
pdf.TransformBegin()
@@ -2465,7 +2471,11 @@ func ExampleFpdf_SetFillColor() {
pdf.SetLineWidth(2)
pdf.SetDrawColor(128, 64, 0)
pdf.SetFillColor(255, 127, 0)
+ pdf.SetAlpha(0.5, "Normal")
+ pdf.SetDashPattern([]float64{5, 10}, 0)
pdf.Rect(0, 0, 20, 20, "FD")
+ pdf.SetFontSize(8)
+ pdf.Write(10, "Test")
pdf.TransformEnd()
fileStr := example.Filename("Fpdf_SetFillColor")