changeset 2444:ba24ddb19a43

iOS: Fix font and colors on MLE imported text.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 09 Apr 2021 10:01:22 +0000
parents 42ba334cb8f7
children a773008c7c5d
files ios/dw.m
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ios/dw.m	Fri Apr 09 09:48:13 2021 +0000
+++ b/ios/dw.m	Fri Apr 09 10:01:22 2021 +0000
@@ -4836,7 +4836,13 @@
     unsigned int retval;
     NSTextStorage *ts = [mle textStorage];
     NSString *nstr = [NSString stringWithUTF8String:buffer];
-    NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr];
+    UIColor *fgcolor = [mle textColor];
+    UIFont *font = [mle font];
+    NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
+    [attributes setObject:(fgcolor ? fgcolor : [UIColor labelColor]) forKey:NSForegroundColorAttributeName];
+    if(font)
+        [attributes setObject:font forKey:NSFontAttributeName];
+    NSAttributedString *nastr = [[NSAttributedString alloc] initWithString:nstr attributes:attributes];
     NSUInteger length = [ts length];
     if(startpoint < 0)
         startpoint = 0;