determining japanese-capable fonts
determining japanese-capable fonts
- Subject: determining japanese-capable fonts
- From: email@hidden (Jody Fairchild)
- Date: Wed, 30 Jan 2002 20:03:42 +0900
does anyone know a good way to determine whether a given font can support
the display of japanese characters without substitution? my first idea
was to do something like:
NSFontManager *fm = [NSFontManager sharedFontManager];
loop, iterating through available fonts ...
{ if ([fm fontNamed:whatever
hasTraits:NSNonStandardCharacterSetFontMask]) dosomething();
}
but it seems that _every_ font in the system has that bitflag set. btw,
there's a bug in the docs where the constant is referred to as
NSNonstandardCharacterSetFontMask
(note the case difference in the "s" of "nonstandard"), which of course
breaks at compile time ...
further experimentation seems to indicate that one might be able to check
a given font's "mostCompatibleStringEncoding", and get some kind of an
idea from that. i'm not so comfortable with this approach however:
loop, iterating through fonts ...
{ NSFont *f = [NSFont fontWithName:whatever size:0.0];
NSLog(@"%@ => %u",whatever,[f mostCompatibleStringEncoding]);
}
it does seem to differentiate the fonts (excerpt):
2002-01-30 19:33:13.947 the_birdmen[658] Optima-Italic => 30
2002-01-30 19:33:14.017 the_birdmen[658] Optima-Regular => 30
2002-01-30 19:33:14.047 the_birdmen[658] Osaka => 2147483649
2002-01-30 19:33:14.077 the_birdmen[658] Osaka-Mono => 2147483649
2002-01-30 19:33:14.133 the_birdmen[658] Palatino-Bold => 30
but the values reported for the japanese fonts are rather out of control;
in fact these values do not appear at all in the declaration of
NSStringEncoding. i don't think the method call is failing, because the
docs seem to indicate that if doesn't know what to do, it just returns
NSASCIIStringEncoding (==1) ... the whole thing seems kind of kludgy to
me and i'd sure like a better way to determine this information, or at
least be assured of its reliability before i try to use it in a real app.
any suggestions?
thanks,
-jf