Seeking Advice for a Right-to-Left Language Bug in Unread
This is cross-posted from this Stack Overflow question. If you know the answer I’d appreciate your help.
In Unread, I’m using the NSAttributedString UIKit Additions to draw attributed strings for article summaries in a UIView subclass. The problem I have is that despite using a value of NSWritingDirectionNatural
for the baseWritingDirection
property of my paragraph style, text always defaults to left-to-right.
Here’s how I form the attributed string (simplified example):
NSString *arabic = @"العاصمة الليبية لتأمينها تنفيذا لقرار المؤتمر الوطني العام. يأتي ذلك بعدما أعلن اللواء الليبي المتقاعد خليفة حفتر أنه طلب من المجلس الأعلى للقض الدولة حتى الانتخابات النيابية القادمة"; NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init]; paragraph.baseWritingDirection = NSWritingDirectionNatural; paragraph.lineBreakMode = NSLineBreakByWordWrapping; NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init]; attributes[NSParagraphStyleAttributeName] = paragraph; NSAttributedString *string = [[NSAttributedString alloc] initWithString:arabic attributes:attributes];
And here’s how I draw the text:
- (void)drawRect:(CGRect)rect { [self.attributedText drawWithRect:rect options:NSStringDrawingUsesLineFragmentOrigin context:nil]; }
And yet it still flows from left to right:
What am I missing?