Fixed: #2424 DefineEditText handling of letterSpacing, font size on incorrect values

This commit is contained in:
Jindra Petřík
2025-03-08 09:33:45 +01:00
parent 71cddc1704
commit a685050dff
2 changed files with 23 additions and 12 deletions

View File

@@ -450,20 +450,24 @@ public class DefineEditTextTag extends TextTag {
}
}
String size = unescape(attributes.getValue("size"));
if (size != null && size.length() > 0) {
char firstChar = size.charAt(0);
if (firstChar != '+' && firstChar != '-') {
int fontSize = Integer.parseInt(size);
style.fontHeight = (int) Math.round(fontSize * SWF.unitDivisor);
} else {
int fontSizeDelta = (int) Math.round(Integer.parseInt(size.substring(1)) * SWF.unitDivisor);
if (firstChar == '+') {
style.fontHeight = style.fontHeight + fontSizeDelta;
if (size != null && size.length() > 0) {
try {
char firstChar = size.charAt(0);
if (firstChar != '+' && firstChar != '-') {
int fontSize = Integer.parseInt(size);
style.fontHeight = (int) Math.round(fontSize * SWF.unitDivisor);
} else {
style.fontHeight = style.fontHeight - fontSizeDelta;
int fontSizeDelta = (int) Math.round(Integer.parseInt(size.substring(1)) * SWF.unitDivisor);
if (firstChar == '+') {
style.fontHeight = style.fontHeight + fontSizeDelta;
} else {
style.fontHeight = style.fontHeight - fontSizeDelta;
}
}
style.fontLeading = leading;
} catch (NumberFormatException nfe) {
//do not change fontHeight or leading
}
style.fontLeading = leading;
}
String face = unescape(attributes.getValue("face"));
@@ -473,7 +477,11 @@ public class DefineEditTextTag extends TextTag {
String letterspacing = unescape(attributes.getValue("letterSpacing"));
if (letterspacing != null && letterspacing.length() > 0) {
style.letterSpacing = Double.parseDouble(letterspacing);
try {
style.letterSpacing = Double.parseDouble(letterspacing);
} catch (NumberFormatException nfe) {
//do not change letterSpacing
}
}
String kerning = unescape(attributes.getValue("kerning"));