I am trying to display font information on the user interface of my 
application, and have come across some hidden fonts that are obviously there in 
the system, but not listed in the UIFont familyNames. This can happen when the 
user has pasted rich text into my application and it is in a hidden system font.

And I know at least some of where this comes from - for example, when I use 
UIFont systemFontOfSize:, the font name is ".HelveticaNeueInterface-M3” and the 
family name is ".Helvetica Neue Interface”.

When I use [UIFont familyNames] there is nothing named ".Helvetica Neue 
Interface”, although there is "Helvetica Neue”. My conclusion is that this is 
somehow a hidden font.

I have a list of all the fonts as returned by UIFont, and want to put a 
checkmark beside the font the user is using in the text. But of course, the 
hidden system fonts are not in the list, so what am I supposed to do to 
indicate as the selected font? 

We have the seemingly impossible situation where the text is drawn in a font 
face that is not in the list returned by [UIFont familyNames].

By looking at the UIFont preferredFontForTextStyle: return values, I can see 
that there are at least the following hidden fonts:
".HelveticaNeueInterface-M3”
".HelveticaNeueInterface-MediumP4”
".HelveticaNeueInterface-Bold”

I wondered about using the font descriptors to turn it into a font that 
actually exists as far as the user is concerned, but asking for the font’s font 
descriptor for ".HelveticaNeueInterface-M3” and then asking for matching font 
descriptors only gave me a font name of ".AppleSystemUIFont”, and of course if 
I pass that into fontWithName, it returns the ".HelveticaNeueInterface-M3”, so 
that just took me in a circle back to where I started.

I’m thinking that when someone pastes text into my application, I could perhaps 
have a check in my code that the font is in the list returned by UIFont, and if 
not, I could probably have a lookup for the known system hidden fonts and 
replace them with suitable visible alternatives, and for anything unknown, I 
could have a fallback to a known font.

It all seems a bit messy, so any feedback would be welcome.

Thanks

Gideon


_______________________________________________

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

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

Reply via email to