Skip to content

Commit

Permalink
Fixed: #2424 DefineEditText handling of letterSpacing, font size on i…
Browse files Browse the repository at this point in the history
…ncorrect values
  • Loading branch information
jindrapetrik committed Mar 8, 2025
1 parent 71cddc1 commit a685050
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
All notable changes to this project will be documented in this file.

## [Unreleased]
### Fixed
- [#2424] DefineEditText handling of letterSpacing, font size on incorrect values

## [22.0.2] - 2025-01-17
### Added
Expand Down Expand Up @@ -3688,6 +3690,7 @@ Major version of SWF to XML export changed to 2.
[alpha 9]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha8...alpha9
[alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
[#2424]: https://www.free-decompiler.com/flash/issues/2424
[#2375]: https://www.free-decompiler.com/flash/issues/2375
[#2374]: https://www.free-decompiler.com/flash/issues/2374
[#2389]: https://www.free-decompiler.com/flash/issues/2389
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,20 +450,24 @@ public void startElement(String uri, String localName, String qName, Attributes
}
}
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"));

Expand All @@ -473,7 +477,11 @@ public void startElement(String uri, String localName, String qName, Attributes

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"));
Expand Down

0 comments on commit a685050

Please sign in to comment.