Skip to content

Commit f3771f1

Browse files
Support exponent notation for numbers with capital E for SVG parsing
DEVSIX-6645
1 parent 32c1b31 commit f3771f1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

styled-xml-parser/src/main/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private static boolean isDigit(char ch) {
441441
}
442442

443443
private static boolean isExponentNotation(String s, int index) {
444-
return index < s.length() && s.charAt(index) == 'e' &&
444+
return index < s.length() && Character.toLowerCase(s.charAt(index)) == 'e' &&
445445
// e.g. 12e5
446446
(index + 1 < s.length() && isDigit(s.charAt(index + 1)) ||
447447
// e.g. 12e-5, 12e+5

styled-xml-parser/src/test/java/com/itextpdf/styledxmlparser/css/util/CssDimensionParsingUtilsTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void parseAbsoluteLengthFromNull() {
166166
}
167167

168168
@Test
169-
public void parseAboluteLengthExponential01() {
169+
public void parseAbsoluteLengthExponentialPtTest() {
170170
String value = "1e2pt";
171171
float actual = CssDimensionParsingUtils.parseAbsoluteLength(value);
172172
float expected = 1e2f;
@@ -175,14 +175,23 @@ public void parseAboluteLengthExponential01() {
175175
}
176176

177177
@Test
178-
public void parseAboluteLengthExponential02() {
178+
public void parseAbsoluteLengthExponentialPxTest() {
179179
String value = "1e2px";
180180
float actual = CssDimensionParsingUtils.parseAbsoluteLength(value);
181181
float expected = 1e2f * 0.75f;
182182

183183
Assert.assertEquals(expected, actual, 0);
184184
}
185185

186+
@Test
187+
public void parseAbsoluteLengthExponentialCapitalTest() {
188+
String value = "1E-4";
189+
float actual = CssDimensionParsingUtils.parseAbsoluteLength(value);
190+
float expected = 1e-4f * 0.75f;
191+
192+
Assert.assertEquals(expected, actual, 1e-9);
193+
}
194+
186195
@Test
187196
public void parseAbsoluteLength12cmTest() {
188197
// Calculations in CssUtils#parseAbsoluteLength were changed to work

0 commit comments

Comments
 (0)