microsoft / WinObjC

Objective-C for Windows
MIT License
6.24k stars 808 forks source link

UI control can not correctly display the UTF8 Chinese character string #553

Closed yaveymao closed 8 years ago

yaveymao commented 8 years ago

repro steps: step 1) convert source file to UTF8 page code(65001) step 2) add UIButton:

UIButton *button = ....
[button setTitle:@"简单按钮" forState:UIControlStateNormal];

button just shows "简单" instead of "简单按钮"

The same situation occurs in UIAlterView:

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" message:@"Hello Alert"
                                                   delegate:self 
                                                   cancelButtonTitle:@"取消"
                                                   otherButtonTitles:@"好的", nil];
    [alert show];

the cancel button just shows "取" instead of "取消" the ok button just shows "好" instead of "好的"

msft-Jeyaram commented 8 years ago

I'm doing an initial investigation on this, but @ms-jihua do you think it might be an issue with the old version of icu we are using. (we saw issues with Chinese character ranges)

ms-jihua commented 8 years ago

It seems likely? You can probably confirm it by breaking on the range function during the repro.

aballway commented 8 years ago

The issue is happening because UIButton is using CGFontFitChars to determine the size of the text, but FreeType isn't recognizing the characters, so it just adds some generic width, which seems to be about half of one of these characters. This will be resolved once we switch over to DWrite

rajsesh commented 8 years ago

This should be addressed as part of #925