Created
June 19, 2020 23:27
-
-
Save macguru/0fd5642154f5e63f5ee2ab296ca635be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
NSLog(@"languages: %@", [NSLocale.preferredLanguages componentsJoinedByString: @", "]); | |
NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString: @"暗a"]; | |
[string addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize: 12] range:NSMakeRange(0, string.length)]; | |
NSFont *usedFont = [string attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; | |
NSLog(@"orginal: %@", usedFont.fontName); | |
NSLog(@"latin: %d", [usedFont.coveredCharacterSet characterIsMember: 'a']); | |
[string fixAttributesInRange: NSMakeRange(0, string.length)]; | |
usedFont = [string attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL]; | |
NSLog(@"fixed: %@", usedFont.fontName); | |
NSLog(@"latin: %d", [usedFont.coveredCharacterSet characterIsMember: 'a']); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2020-06-20 01:26:21.673229+0200 fonttest[40301:2583659] languages: en-US, zh-Hans-DE, ja-DE, de-DE, pt-DE, ru-DE, tr-DE, th-DE | |
2020-06-20 01:26:21.850740+0200 fonttest[40301:2583659] orginal: .AppleSystemUIFont | |
2020-06-20 01:26:21.851591+0200 fonttest[40301:2583659] latin: 1 | |
2020-06-20 01:26:21.897532+0200 fonttest[40301:2583659] fixed: .PingFangSC-Regular | |
2020-06-20 01:26:21.897893+0200 fonttest[40301:2583659] latin: 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2020-06-20 01:26:52.231687+0200 fonttest[40345:2585341] languages: en-US, ja-DE, zh-Hans-DE, de-DE, pt-DE, ru-DE, tr-DE, th-DE | |
2020-06-20 01:26:52.258971+0200 fonttest[40345:2585341] orginal: .AppleSystemUIFont | |
2020-06-20 01:26:52.259851+0200 fonttest[40345:2585341] latin: 1 | |
2020-06-20 01:26:52.274636+0200 fonttest[40345:2585341] fixed: .HiraKakuInterface-W3 | |
2020-06-20 01:26:52.274956+0200 fonttest[40345:2585341] latin: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment