1
- // Copyright (c) Microsoft Corporation. All rights reserved.
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT License.
3
3
4
4
using ReactNative . Reflection ;
@@ -23,7 +23,7 @@ namespace ReactNative.Views.Text
23
23
public class ReactSpanShadowNode : ReactInlineShadowNode
24
24
{
25
25
private double ? _fontSize ;
26
- private int _letterSpacing ;
26
+ private int ? _letterSpacing ;
27
27
28
28
private FontStyle ? _fontStyle ;
29
29
private FontWeight ? _fontWeight ;
@@ -99,13 +99,11 @@ public void SetFontStyle(string fontStyleValue)
99
99
/// </summary>
100
100
/// <param name="letterSpacing">The letter spacing.</param>
101
101
[ ReactProp ( ViewProps . LetterSpacing ) ]
102
- public void SetLetterSpacing ( int letterSpacing )
102
+ public void SetLetterSpacing ( int ? letterSpacing )
103
103
{
104
- var spacing = 50 * letterSpacing ; // TODO: Find exact multiplier (50) to match iOS
105
-
106
- if ( _letterSpacing != spacing )
104
+ if ( _letterSpacing != letterSpacing )
107
105
{
108
- _letterSpacing = spacing ;
106
+ _letterSpacing = letterSpacing ;
109
107
MarkUpdated ( ) ;
110
108
}
111
109
}
@@ -135,15 +133,51 @@ public override Inline MakeInline(IList<Inline> children)
135
133
public override void UpdateInline ( Inline inline )
136
134
{
137
135
#if WINDOWS_UWP
138
- inline . CharacterSpacing = _letterSpacing ;
139
- inline . FontStyle = _fontStyle ?? FontStyle . Normal ;
140
- inline . FontFamily = _fontFamily != null ? new FontFamily ( _fontFamily ) : FontFamily . XamlAutoFontFamily ;
141
- #else
142
- inline . FontStyle = _fontStyle ?? new FontStyle ( ) ;
143
- inline . FontFamily = _fontFamily != null ? new FontFamily ( _fontFamily ) : new FontFamily ( ) ;
136
+ if ( _letterSpacing . HasValue )
137
+ {
138
+ var spacing = 50 * _letterSpacing . Value ; // TODO: Find exact multiplier (50) to match iOS
139
+ inline . CharacterSpacing = spacing ;
140
+ }
141
+ else
142
+ {
143
+ inline . ClearValue ( Inline . CharacterSpacingProperty ) ;
144
+ }
144
145
#endif
145
- inline . FontSize = _fontSize ?? 15 ;
146
- inline . FontWeight = _fontWeight ?? FontWeights . Normal ;
146
+ if ( _fontStyle . HasValue )
147
+ {
148
+ inline . FontStyle = _fontStyle . Value ;
149
+ }
150
+ else
151
+ {
152
+ inline . ClearValue ( Inline . FontStyleProperty ) ;
153
+ }
154
+
155
+ if ( ! string . IsNullOrEmpty ( _fontFamily ) )
156
+ {
157
+ inline . FontFamily = new FontFamily ( _fontFamily ) ;
158
+ }
159
+ else
160
+ {
161
+ inline . ClearValue ( Inline . FontFamilyProperty ) ;
162
+ }
163
+
164
+ if ( _fontSize . HasValue )
165
+ {
166
+ inline . FontSize = _fontSize . Value ;
167
+ }
168
+ else
169
+ {
170
+ inline . ClearValue ( Inline . FontSizeProperty ) ;
171
+ }
172
+
173
+ if ( _fontWeight . HasValue )
174
+ {
175
+ inline . FontWeight = _fontWeight . Value ;
176
+ }
177
+ else
178
+ {
179
+ inline . ClearValue ( Inline . FontWeightProperty ) ;
180
+ }
147
181
}
148
182
149
183
/// <summary>
0 commit comments