mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
@@ -100,7 +100,11 @@ public class TextRenderer {
|
||||
lastSpaceIdx = text.length();
|
||||
nextSpaceIdx = boundary.next();
|
||||
}
|
||||
try {
|
||||
ch = fullText.charAt(i);
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
ch = Character.MIN_VALUE;
|
||||
}
|
||||
switch (ch) {
|
||||
case '\r':
|
||||
continue; //skip '\r' character
|
||||
@@ -231,6 +235,7 @@ public class TextRenderer {
|
||||
}
|
||||
}
|
||||
if (inKeywordCount > 0) {
|
||||
try {
|
||||
inKeywordCount--;
|
||||
if (inKeywordCount == 0 && text.length() > 0) {
|
||||
String keyword, value;
|
||||
@@ -238,14 +243,12 @@ public class TextRenderer {
|
||||
if (text.charAt(0) == '/') {
|
||||
keyword = text.substring(1);
|
||||
value = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
int idx = text.indexOf(" ");
|
||||
if (idx != -1) {
|
||||
keyword = text.substring(0, idx);
|
||||
value = text.substring(idx + 1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
keyword = text.toString();
|
||||
value = null;
|
||||
}
|
||||
@@ -278,6 +281,7 @@ public class TextRenderer {
|
||||
continue; //skip '>' character
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
break;
|
||||
case '(':
|
||||
@@ -415,10 +419,12 @@ public class TextRenderer {
|
||||
}
|
||||
}
|
||||
if (lastPieceIdx >= 0) {
|
||||
try {
|
||||
Piece lastPiece = pieces.get(lastPieceIdx);
|
||||
lineWidths.add(lastPiece.x + lastPiece.w);
|
||||
x = 0;
|
||||
for (int j = lastPieceIdx + 1; j < pieces.size(); j++) {
|
||||
int size = pieces.size();
|
||||
for (int j = lastPieceIdx + 1; j < size; j++) {
|
||||
Piece piece = pieces.get(j);
|
||||
piece.x = x;
|
||||
piece.y += lineHeight;
|
||||
@@ -436,6 +442,9 @@ public class TextRenderer {
|
||||
}
|
||||
needClip = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (font.canShrink()) {
|
||||
//try next font size down if out of space
|
||||
@@ -483,7 +492,10 @@ public class TextRenderer {
|
||||
|
||||
private void setProps(String text, FSkinFont skinFont, float w, float h, boolean wrap0) {
|
||||
boolean needUpdate = false;
|
||||
if (!fullText.equals(text)) {
|
||||
if (fullText == null) {
|
||||
fullText = text;
|
||||
needUpdate = true;
|
||||
} else if (!fullText.equals(text)) {
|
||||
fullText = text;
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -538,11 +550,13 @@ public class TextRenderer {
|
||||
if (needClip) { //prevent text flowing outside region if couldn't shrink it to fit
|
||||
g.startClip(x, y, w, h);
|
||||
}
|
||||
try {
|
||||
if (height > totalHeight && centerVertically) {
|
||||
y += (height - totalHeight) / 2;
|
||||
}
|
||||
float[] alignmentOffsets = new float[lineWidths.size()];
|
||||
for (int i = 0; i < lineWidths.size(); i++) {
|
||||
int size = lineWidths.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
switch (horzAlignment) {
|
||||
case Align.left:
|
||||
alignmentOffsets[i] = 0;
|
||||
@@ -568,6 +582,9 @@ public class TextRenderer {
|
||||
}
|
||||
piece.draw(g, color, x + alignmentOffsets[piece.lineNum], y);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
if (needClip) {
|
||||
g.endClip();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user