trim text in TextLine drawAligned
This commit is contained in:
parent
a58f1e6c83
commit
0f3f8d488a
2 changed files with 6 additions and 4 deletions
|
@ -1,3 +1,3 @@
|
|||
group = org.xbib.graphics
|
||||
name = graphics
|
||||
version = 5.5.1
|
||||
version = 5.5.2
|
||||
|
|
|
@ -210,17 +210,19 @@ public class TextLine implements TextSequence {
|
|||
if (transform != null) {
|
||||
matrix = matrix.multiply(transform.getMatrix());
|
||||
}
|
||||
if (!styledText.getText().isEmpty()) {
|
||||
// always trim to prevent leading spaces to allow getSelectedFont() to work
|
||||
String text = styledText.getText().trim();
|
||||
if (!text.isEmpty()) {
|
||||
contentStream.beginText();
|
||||
beginText = true;
|
||||
contentStream.setTextMatrix(matrix);
|
||||
lastFontDesc = styledText.getFontDescriptor();
|
||||
contentStream.setFont(lastFontDesc.getSelectedFont(styledText.getText()), lastFontDesc.getSize());
|
||||
contentStream.setFont(lastFontDesc.getSelectedFont(text), lastFontDesc.getSize());
|
||||
if (!styledText.getColor().equals(lastColor)) {
|
||||
lastColor = styledText.getColor();
|
||||
contentStream.setNonStrokingColor(lastColor);
|
||||
}
|
||||
contentStream.showText(styledText.getText());
|
||||
contentStream.showText(text);
|
||||
contentStream.endText();
|
||||
beginText = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue