Arbitrary Attributes affect text layout
Arbitrary Attributes affect text layout
- Subject: Arbitrary Attributes affect text layout
- From: Philip White <email@hidden>
- Date: Tue, 02 Feb 2010 11:48:50 -0600
Hello,
I have a problem I can't quite figure out. I have a program that displays some Hebrew text. I notice that at times some of the vowel markings are not displayed in the correct place. I figured out that this happened when I had applied some arbitrary attributes to that range of text.
I was under the impression that one could set any key value pair not used by the Cocoa text system to a part of an attributed string without consequence.
Anyway, I wrote a test program that illustrates this quite dramatically. All the program does is this basically:
-(IBAction)work:(id)sender
{
NSTextStorage *ts = [textView textStorage];
NSRange r = {0,1};
for (;r.location+r.length<=[ts length]; r.location++)
{
[ts addAttribute:[NSString stringWithFormat:@"Nonsense%u",r.location]
value:[NSString stringWithFormat:@"Gibberish%u",r.location]
range:r];
}
}
The results can be seen in the two images on this webpage: http://www.rivulus-sw.com/junk/hebrew_text_test.html
The xcode project for the test program can be downloaded from http://www.rivulus-sw.com/junk/hebrew_text_tester.zip
Note that copying the garbled text into another program, like TextEdit, where the additional attributes are presumably stripped out, causes the test to display normally again.
With Latin text I haven't seen any problems, even when using diacriticals.
The problems in my actual program have been much more subtle than those in the test program, probably because I haven't been applying different attributes to each character.
Could someone give me some tips on what I'm doing wrong here or how I can avoid this text mangling?
Many Thanks,
Philip White
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden