Skip to content

Commit f0dd1a0

Browse files
fix: setting letterSpacing prop (#2807)
# Summary Fixes: #2806 This PR fixes calculating `letterSpacing` for `Text` when `letterSpacing` prop type is `Number`. ## Test Plan Run example from issue: #2806
1 parent 9713a85 commit f0dd1a0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

android/src/main/java/com/horcrux/svg/FontData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private double toAbsolute(
136136
ReadableMap font, String prop, double scale, double fontSize, double relative) {
137137
ReadableType propType = font.getType(prop);
138138
if (propType == ReadableType.Number) {
139-
return font.getDouble(prop);
139+
return font.getDouble(prop) * scale;
140140
} else {
141141
String string = font.getString(prop);
142142
return PropHelper.fromRelative(string, relative, scale, fontSize);

apple/Text/RNSVGFontData.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ + (instancetype)initWithNSDictionary:(NSDictionary *)font parent:(RNSVGFontData
184184
id letterSpacing = [font objectForKey:LETTER_SPACING];
185185
if ([letterSpacing isKindOfClass:NSNumber.class]) {
186186
NSNumber *ls = letterSpacing;
187-
data->wordSpacing = (CGFloat)[ls doubleValue];
187+
data->letterSpacing = (CGFloat)[ls doubleValue];
188188
} else {
189189
data->letterSpacing =
190190
letterSpacing ? [RNSVGFontData toAbsoluteWithNSString:letterSpacing fontSize:fontSize] : parent->letterSpacing;

0 commit comments

Comments
 (0)