@@ -83,10 +83,31 @@ internal static void UpdateTextHtml(this UILabel platformLabel, ILabel label)
8383 StringEncoding = NSStringEncoding . UTF8
8484 } ;
8585
86+ var uiFontAttribute = label ? . Handler ? . GetRequiredService < IFontManager > ( ) ? . GetFont ( label . Font , UIFont . LabelFontSize ) ;
87+
8688 NSError nsError = new ( ) ;
87- #pragma warning disable CS8601
88- platformLabel . AttributedText = new NSAttributedString ( text , attr , ref nsError ) ;
89- #pragma warning restore CS8601
89+ var attributedString = new NSMutableAttributedString ( new NSAttributedString ( text , attr , ref nsError ) ) ;
90+
91+ // Enumerate through the attributes in the string and update font size
92+ attributedString . EnumerateAttributes ( new NSRange ( 0 , attributedString . Length ) , NSAttributedStringEnumeration . None ,
93+ ( NSDictionary attrs , NSRange range , ref bool stop ) =>
94+ {
95+ if ( label ! . Font . Family == null )
96+ {
97+ var font = attrs [ UIStringAttributeKey . Font ] as UIFont ;
98+ if ( font != null )
99+ {
100+ font = font . WithSize ( ( nfloat ) ( label ? . Font . Size ?? UIFont . LabelFontSize ) ) ;
101+ attributedString . AddAttribute ( UIStringAttributeKey . Font , font , range ) ;
102+ }
103+ }
104+ else if ( uiFontAttribute != null )
105+ {
106+ attributedString . AddAttribute ( UIStringAttributeKey . Font , uiFontAttribute , range ) ;
107+ }
108+ } ) ;
109+
110+ platformLabel . AttributedText = attributedString ;
90111 }
91112
92113 internal static void UpdateTextPlainText ( this UILabel platformLabel , IText label )
0 commit comments