On 28 Feb 2011, at 19:36, cocoa-dev-requ...@lists.apple.com wrote:

> There are quite a few characters, which OS X cannot print. 
> E.g. ›« ≈ 0x2b809 (CJK Unified Ideographs Extension D) 
> 
> I would like to have a function or method like:
> BOOL myComputerCanDisplayThisUnicodeCodePoint( unsigned int codePoint);
> 
> How can I get this information?

To answer my own question: this code seems to work:

+ (BOOL)weCanDisplayTheFirstCharacterIn: (NSString *)aString ;
{
        NSRange oneChar = [ aString rangeOfComposedCharacterSequenceAtIndex: 0 
];
        NSString *firstChar = [ aString substringWithRange: oneChar ];
        NSMutableAttributedString *attributedString = [ [ 
NSMutableAttributedString alloc ] initWithString: firstChar ];
        [ attributedString fixFontAttributeInRange: NSMakeRange(0,1) ]; 
        NSFont *aFont = [ attributedString attribute: NSFontAttributeName  
atIndex: 0  effectiveRange: NULL ];
        NSString *fontName = [aFont fontName];
        [ attributedString release ];
        //NSLog(@"%s \"%@\" → %@",__FUNCTION__, firstChar, fontName);
        BOOL weCan = ![ fontName isEqualToString: @"LastResort" ];
        return weCan;   
}

But as the font name "LastResort" is nowhere documented (or is it?), Apple is 
free to change it to "LionsLastResort" this summer.
Also, this method does not look too efficient.

So: is there an efficient, non-hackish way to get this information?

Kind regards,

Gerriet.




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to