Re: Leopard's Font Collection based on user's language
Re: Leopard's Font Collection based on user's language
- Subject: Re: Leopard's Font Collection based on user's language
- From: Aki Inoue <email@hidden>
- Date: Fri, 15 Feb 2008 10:53:27 -0800
Duh. In the clear light of morning I can see that
com.apple.UserFonts does not refer to fonts in the user's Library/
Fonts folder, but rather to fonts appropriate for the user's
language preference. I guess the name of the collection can be
obtained like this:
I'm glad that you found about this 8-).
NSString *languageCode = [[NSLocale preferredLanguages]
objectAtIndex:0];
NSLocale *locale = [NSLocale currentLocale];
NSString *collectionDisplayName = [locale
displayNameForKey:NSLocaleLanguageCode value:];
Actually the locale used to dynamically construct the collection is
based on the user interface language, not on the regional locale
returned from +currentLocale.
So, you should do:
NSArray *preferredLanguages = [NSLocale preferredLanguage];
NSString *language = ((0 == [preferredLanguages count]) ? @"en" :
[preferredLanguages objectAtIndex:0]);
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:language];
NSString *collectionDisplayName = [locale
displayNameForKey:NSLocaleLanguageCode value:language];
[locale release];
We do have plans to enhance NSFontManager API to make the info more
easily accessible.
Enhancement requests from 3rd developers don't hurt as usual, though.
Thank you,
Aki
On Feb 15, 2008, at 8:22 AM, Ross Carter wrote:
On Feb 14, 2008, at 8:58 PM, Ross Carter wrote:
Leopard added a new font collection to the font manager panel: a
collection comprising fonts appropriate for the user's language
setting. (E.g., my collections are now All Fonts, English,
Favorites, etc.)
NSFontManager's collectionNames method does not return a name for
that collection. Is there any way to retrieve that collection's
contents, perhaps by using
fontDescriptorsInCollection:theSecretCollectionName ?
Duh. In the clear light of morning I can see that
com.apple.UserFonts does not refer to fonts in the user's Library/
Fonts folder, but rather to fonts appropriate for the user's
language preference. I guess the name of the collection can be
obtained like this:
NSString *languageCode = [[NSLocale preferredLanguages]
objectAtIndex:0];
NSLocale *locale = [NSLocale currentLocale];
NSString *collectionDisplayName = [locale
displayNameForKey:NSLocaleLanguageCode value:];
Sorry for the noise.
Ross
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden