@@ -15,8 +15,8 @@ - (void)nativeScriptSetTextDecorationAndTransform:(NSString*)text textDecoration
1515 }
1616 BOOL isTextType = [self isKindOfClass: [UITextField class ]] || [self isKindOfClass: [UITextView class ]] | [self isKindOfClass: [UILabel class ]] | [self isKindOfClass: [UIButton class ]];
1717
18- if (letterSpacing != 0 && isTextType) {
19- NSNumber *kern = [NSNumber numberWithDouble: letterSpacing];
18+ if (letterSpacing != 0 && isTextType && ((UITextView*)self). font != nil ) {
19+ NSNumber *kern = [NSNumber numberWithDouble: letterSpacing * ((UITextView*) self ).font.pointSize ];
2020 attrDict[NSKernAttributeName ] = kern;
2121 if ([self isKindOfClass: [UITextField class ]]) {
2222 [((UITextField*)self ).defaultTextAttributes setValue: kern forKey: NSKernAttributeName ];
@@ -31,13 +31,13 @@ - (void)nativeScriptSetTextDecorationAndTransform:(NSString*)text textDecoration
3131 if ([self isKindOfClass: [UIButton class ]]) {
3232 paragraphStyle.alignment = ((UIButton*)self).titleLabel .textAlignment ;
3333
34- if (((UIButton*)self).titleLabel .font ) {
34+ if (((UIButton*)self).titleLabel .font != nil ) {
3535 paragraphStyle.lineSpacing = fmax (lineHeight - ((UIButton*)self).titleLabel .font .lineHeight , 0 );
3636 }
3737 } else {
3838 paragraphStyle.alignment = ((UILabel*)self).textAlignment ;
3939
40- if (((UILabel*)self).font ) {
40+ if (((UILabel*)self).font != nil ) {
4141 paragraphStyle.lineSpacing = fmax (lineHeight - ((UILabel*)self).font .lineHeight , 0 );
4242 }
4343 }
@@ -86,7 +86,7 @@ - (void)nativeScriptSetTextDecorationAndTransform:(NSString*)text textDecoration
8686-(void )nativeScriptSetFormattedTextDecorationAndTransform : (NSDictionary *)details letterSpacing : (CGFloat)letterSpacing lineHeight : (CGFloat)lineHeight {
8787 NSMutableAttributedString *attrText = [NativeScriptUtils createMutableStringWithDetails: details];
8888 if (letterSpacing != 0 ) {
89- NSNumber *kern = [NSNumber numberWithDouble: letterSpacing];
89+ NSNumber *kern = [NSNumber numberWithDouble: letterSpacing * ((UITextView*) self ).font.pointSize ];
9090 [attrText addAttribute: NSKernAttributeName value: kern range: (NSRange ){
9191 0 ,
9292 attrText.length
@@ -101,14 +101,14 @@ -(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details
101101 if ([self isKindOfClass: [UIButton class ]]) {
102102 paragraphStyle.alignment = ((UIButton*)self).titleLabel .textAlignment ;
103103
104- if (((UIButton*)self).titleLabel .font ) {
104+ if (((UIButton*)self).titleLabel .font != nil ) {
105105 paragraphStyle.lineSpacing = fmax (lineHeight - ((UIButton*)self).titleLabel .font .lineHeight , 0 );
106106 }
107107 } else {
108108 // Paragraph alignment is also important for tappable spans as NSTextContainer takes it into account
109109 paragraphStyle.alignment = ((UILabel*)self).textAlignment ;
110110
111- if (((UILabel*)self).font ) {
111+ if (((UILabel*)self).font != nil ) {
112112 paragraphStyle.lineSpacing = fmax (lineHeight - ((UILabel*)self).font .lineHeight , 0 );
113113 }
114114 }
0 commit comments