Detect if a font is classified

Is there a way to programmatically determine if a given font is serif or sans serif?

For example, if a user chose Palatino, it is classified. If the user selected Arial, it is sans serif.

I can determine the first and last name of the font. But for UIFont, I don't see any serifs or scripts. Without that, I think I would need to set and track the isSerif BOOL manually for every font the user can access?

+3


source to share


3 answers


There is actually no UIFont attribute that hints at the font type. If you only rely on the familys font family (50+ iOS 6.x), you can easily manipulate them in plist with all the required attributes (future). For using the third set of fonts, you can read the ttf spec if there is an attribute for the (sans) serif fonts. The last resort is to check the last name and / or name of the font for the "serif" in it, assuming they are named accordingly.



+1


source


There is UIFont

no property that is explicit to you. At this point, it might be worth adding a category to UIFont

, but it looks like you will need to set up the mapping yourself.



Might be a good project on GitHub.

0


source


You can make a plist with the font key name and boolean value. Below is a list of fonts in iOS

0


source







All Articles