Skip to content

Commit 55a4a59

Browse files
author
Austin Hyde
committed
Build text instructions correctly
1 parent 0212c82 commit 55a4a59

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/java/com/koadweb/javafpdf/FPDF.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,16 +2761,21 @@ public void setY(final float y) {
27612761
/** Output a string */
27622762
public void Text(final float x, final float y, final String txt) {
27632763
StringBuilder s = new StringBuilder();
2764-
s.append(String.format(Locale.ENGLISH, "BT %.2f %.2f Td (%s) Tj ET",
2765-
Float.valueOf(x * this.k), Float.valueOf((this.h - y) * this.k), this._escape(txt)));
2764+
2765+
if (this.colorFlag) {
2766+
s.append("q ").append(this.textColor).append(' ');
2767+
}
2768+
2769+
s.append(String.format("BT %.2f %.2f Td (%s) Tj ET", x * this.k, (this.h - y) * this.k, this._escape(txt)));
2770+
27662771
if (this.underline && (txt != null)) {
27672772
s.append(' ').append(this._dounderline(x, y, txt));
27682773
}
2774+
27692775
if (this.colorFlag) {
2770-
s.delete(0, s.length());
2771-
s.append("q ").append(this.textColor)
2772-
.append(' ').append(s).append(" Q");
2776+
s.append(" Q");
27732777
}
2778+
27742779
this._out(s.toString());
27752780
}
27762781

0 commit comments

Comments
 (0)