开发者

NSTextView Chinese/Unicode Characters

I have a piece of text drawn in my cocoa app but I also need to draw it in a NSTextField and a NSTextView and look exactly the same, they all usually draw fine but if there are unicode or Chinese characters in the text then the NSTextView has large line spaces between the lines, it works perfectly in the nstextfield and when drawing normally.

I have tried every setting that I can find but none affect this issue, has anyone run into this issue before and know of a fix?

You can see the issue in a screenshot at http://cl.ly/3e0U1T2U2G2z341j3O3T

NSTextView Chinese/Unicode Characters

Here is my test code to show the issue

NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(5, 50, 100, 100)];
[textField setStringValue:@"え?移転!? TESTTestTer 友達の旦那の店 THIS IS A TEST THIS IS A TEST"];
[textField setBordered:NO];
[textField setBezeled:NO];
[textField setAllowsEditingTextAttributes:YES];
[textField setDelegate:self];
[textField setFont:[NSFont fontWithName:@"LucidaGrande" size:12.0]];
[textField setTextColor:[NSColor colorWithDeviceRed:(74.0/255.0) green:(74.0/255.0) blue:(74.0/255.0) alpha:1.0]];
[[window contentView] add开发者_如何学GoSubview: textField];

NSTextView *textView = [[NSTextView alloc] initWithFrame:NSMakeRect(200, 50, 100, 100)];
[textView setString:@"え?移転!? TEST TestTer 友達の旦那の店 THIS IS A TEST THIS IS A TEST"];
[textView setDelegate:self];
[textView setFont:[NSFont fontWithName:@"LucidaGrande" size:12.0]];
[textView setTextColor:[NSColor colorWithDeviceRed:(74.0/255.0) green:(74.0/255.0) blue:(74.0/255.0) alpha:1.0]];
[[textView layoutManager] setTypesetterBehavior:NSTypesetterBehavior_10_2_WithCompatibility];
[[textView textContainer] setLineFragmentPadding:0.0];
[[window contentView] addSubview: textView];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜