same font size different appearance.

my earlier questions did not elicit any reply ! may be it was too long.


my simple problem is if i use a font Avenir-Roman [ttf] size 17.8 in iphone, why does it look smaller in ipad and galaxy s6 ?

what is the best practice ?


does the best practice say that use different size font for different size of the screens ? how to handle the resolution then ? iphone [320 x 460] and iphone [640 x 920] font same size in code looks different size ! how many sets i need to consider if i need to define separate font size ?

Honestly, the best practice is to make sure the layout looks good and is consistent with other apps on that same device. Other devices are irrelevant. The vast majority of users do not have the same app running side by side in front of them on two different platforms so they can compare tiny differences in font size. They have one device that they use all the time and are familiar with.


On the iOS side there are only a few variants to worry about. You can compute the "points per inch" value on different devices (ratio of display points to physical screen size) and you will see that it's pretty similar (about 163) on most iPhones. The iPad and iPhone 6 Plus are the only outliers at present. Once you start talking Android devices there is almost infinite variation. Good luck trying to keep track of the physical screen size on all possible devices there.

Hello junkpile,


Thanks for the reply. Again is it like


#define fontsize IF_IPAD ? 26 :18.7


is this the best practice ? Would you be able to point me to a piece of code somewhere ?


thanks and regards

A #define wouldn't work since that's compile time, while you would need to determine it at runtime since the same code would be running on different devices. You can't just inspect your view's bounds either, since for example an iPad mini has the same screen size in points but different points-per-inch from a full size iPad. You would have to inspect the model number from UIDevice - I think you have to use some quasi-private API to get a model string like "iPhone7,1" out of it then map that to something your code expects. It's a fragile approach that is not officially supported or recommended.


Something like the code you posted earlier is probably what you are going to end up with... make the font size proportional to something (could be a Dynamic Type font like the code you posted, or could be the size of your view) with a minimum and maximum hard coded.


Or hopefully someone else will come along with a better idea.

same font size different appearance.
 
 
Q