Dynamic text: new line/paragraph rendering fixed

This commit is contained in:
honfika@gmail.com
2015-02-12 17:53:47 +01:00
parent 7d75d0c4ea
commit bbf33e461c
2 changed files with 18 additions and 8 deletions

View File

@@ -883,10 +883,8 @@ public class DefineEditTextTag extends TextTag {
lastWasWhiteSpace = true;
}
} else {
if (c == '\r' || prevChar != '\r') {
if (multiline) {
textModel.newParagraph();
}
if (multiline) {
textModel.newParagraph();
}
}
prevChar = c;
@@ -950,14 +948,21 @@ public class DefineEditTextTag extends TextTag {
textModel.calculateTextWidths();
List<TEXTRECORD> allTextRecords = new ArrayList<>();
int lastHeight = 0;
int yOffset = 0;
for (List<SameStyleTextRecord> line : lines) {
int width = 0;
int currentOffset = 0;
for (SameStyleTextRecord tr : line) {
width += tr.width;
if (tr.style.fontHeight + tr.style.fontLeading > currentOffset) {
currentOffset = tr.style.fontHeight + tr.style.fontLeading;
if (line.isEmpty()) {
currentOffset = lastHeight;
} else {
for (SameStyleTextRecord tr : line) {
width += tr.width;
int lineHeight = tr.style.fontHeight + tr.style.fontLeading;
lastHeight = lineHeight;
if (lineHeight > currentOffset) {
currentOffset = lineHeight;
}
}
}
yOffset += currentOffset;

View File

@@ -50,6 +50,11 @@ public class DynamicTextModel {
public void newParagraph() {
if (paragraph == null) {
// add empty paragraph
paragraph = new Paragraph(this);
paragraphs.add(paragraph);
}
paragraph = null;
}