UITextView doesn't display custom font correctly in iOS 7

My application uses a UITextView to enter Syrian text (Estrangelo font), but a UITextView doesn’t display some letters correctly as follows:

enter image description here

I tested it with UILabel and UITextView. The UILabel displays it correctly, but the UITextView does not display the top points correctly and moves them down (see the result above).

This problem occurs only in iOS 7 and does not occur in iOS 6. Please tell me if there is a way to fix the problem.

This is my test code.

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; label.center = CGPointMake(self.view.center.x, self.view.center.y-40); label.font = [UIFont fontWithName:@"East Syriac Adiabene" size:24]; label.text = @"ܩ̈ ܡ̄ ܬ̇ ܒ̃"; [self.view addSubview:label]; UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; textView.center = CGPointMake(self.view.center.x, self.view.center.y+40); textView.font = [UIFont fontWithName:@"East Syriac Adiabene" size:24]; textView.text = @"ܩ̈ ܡ̄ ܬ̇ ܒ̃"; [self.view addSubview:textView]; 
+48
ios7 right-to-left uitextview multilingual
Jan 21 '14 at 4:05
source share
2 answers

I debugged this problem a bit and it seems to be a bug in the NSLayoutManager way of NSLayoutManager layout. As pointed out in other answers, a UITextView is built around TextKit with iOS7 and thus uses the NSLayoutManager inside the layout text. UILabel directly uses body text for layout text. Both end up using Core Text to display glyphs.

You should open an error report with Apple and publish the number so that people can duplicate it. The issue has not yet been fixed in the beta version of iOS7.1.

As a workaround, you can replace UITextView other alternative Core Text editors that compose and render directly with Core Text, where the problem does not exist.

I tested SECoreTextView and it shows the text correctly. It implements a similar API for UITextView , but internally uses Core Text.

Here's what it looks like after replacing a UITextView with a SECoreTextView :

 SETextView *textView = [[SETextView alloc] initWithFrame:CGRectMake(0, 0, 100, 40)]; textView.center = CGPointMake(self.view.center.x, self.view.center.y+40); textView.font = [UIFont fontWithDescriptor:desc size:24]; textView.text = @"ܩ̈ ܡ̄ ܬ̇ ܒ̃"; textView.textColor = [UIColor blackColor]; textView.backgroundColor = [UIColor whiteColor]; textView.editable = YES; [self.view addSubview:textView]; 

Using Core Text, the layout issue does not exist.

+6
Feb 14 '14 at 18:44
source share

A few days ago, I had the same problem as you did in iOS 7 (but the font was different) . I installed FONT after installing TEXT and it worked for me. So for your case:

 textView.text = @"ܩ̈ ܡ̄ ܬ̇ ܒ̃"; // Setting the text. textView.font = [UIFont fontWithName:@"East Syriac Adiabene" size:24]; // Setting the font and it size. 

This may sound silly, but it worked for me.

Also see this question / answer . There are many tips for using custom fonts with UITextView that can help you.

EDIT:

iOS 7 also introduced a new selectable property on a UITextView to enable text selection. So make sure you do the following:

 self.textField.editable = YES; self.textField.selectable = ON; 
+2
Feb 12 '14 at 6:13
source share



All Articles