FONT SIZE CONVERTION chart (ARRAY) GODDIE :)



/*a two dimmentionnal array  for conveting font-size
values are [pt, px, em, %]*/

var arrayConvertFontFormat=[
[6,8,0.5,50], 
[7,9,0.55,55],
[7.5,10,0.625,62.5],
[8,11,0.7,70],
[9,12,0.75,75],
[10,13,0.8,80],
[10.5,14,0.875,87.5],
[11,15,0.95,95],
[12,16,1,100],
[13,17,1.05,105],
[13.5,18,1.125,112.5],
[14,19,1.2,120],
[14.5,20,1.25,125],
[15,21,1.3,130],
[16,22,1.4,140],
[17,23,1.45,145],
[18,24,1.5,150],
[20,26,1.6,160],
[22,29,1.8,180],
[24,32,2,200],
[26,35,2.2,220],
[27,36,2.25,225],
[28,37,0.5,230],
[29,38,2.35,235],
[30,40,2.45,245],
[32,42,2.55,255],
[34,45,3.5,275],
[36,48,3,300],
];


hope this helps someone :slight_smile:

var arrayConvertFontFormat=[
[6,8,0.5,50],

On my system, no way is 8px == .5em. They are two wholly different sizes.

Converting from pt to px is nonsensical, as they are two completely different metrics. A given pixel value’s equivilant in em and % depends on the user’s local settings, as well as other font size settings on the same page, and can’t be converted reliably.

100px = 10pt = 2em = 1%
1px = 2pt = .1em = 90%

both of these are possible since they are four totally independent measuring systems.

The only one that has an almost fixed size is pt where there are 72pt in an inch on computers and 72.1pt in an inch in the printing industry.

There can be anywhere between 1000px in an inch and 1000 inches in a px (or an even wider range) depending on the screen size and the resolution it is set to.

Neither em or % have anything approaching fixed sizes as both are specifying sizes relative to something else and that something else can have any size at all.

So there is possibly one web page in existence which when displayed on the OP’s computer has those particular conversions. For every other page and every other computer they will likely be different.

http://battletech.hopto.org/html_tutorials/fontCompare/template.html

Halfway down the page is a side by side comparison of the effect of different system metrics (aka dpi), browsers, font renderers, etc on %/pt… and how px stays the same. This is why there’s NO SUCH THING as a fixed conversion – as everyone else here is telling you… making the mere notion of a conversion chart 100% nonsense.

true , still close in general .

from browser to browser and screen to screen they will change, but in general with the same browser and screen they will look the same .

claimore: you have to watch between machines, regardless of whether the browser is the same… this would be because users (like me) can set a font-size in their Desktop or OS-wide which may be larger or smaller than the default the machine ships with. You can also set it separately for applications (such as browsers).

So, I’m running Linux with the Gnome Desktop Environment. In Gnome I’ve set my Desktop Applications to default at what my machine thinks is “20px” (but again, what a machine thinks a pixel is varies anyway). So this means most of my applications start at this size by default… such as Firefox. However, other applications don’t seem to see those settings. In my case, Opera and Chrome don’t have any bindings with Gnome, so they don’t read my Gnome settings. There, the default font size seems to be around 10px (so still not the 16px everyone says is browser default).

Most browsers, when users download/install them, do have a default font size set to 16px. But the problem is, that isn’t the same size cross-system. You can get two Windows XP machines side-by-side with the same browser and not have them show the same “default” size, simply because users adjust to what they need. Even if you’re administering an Intranet where most settings are the same across machines.

So that’s why everyone is saying these measurements aren’t true. They’ll probably be somewhat correct for most machines with low/medium resolution monitors, so long as the users have never changed any settings. But since there are devices with weird measurements of “pixels” (like mobiles) and since there are a number of users who do change their default settings, relying on those measurements are quite likely to break on some pages.

These Sitepoint pages for example. They break the menu horribly in my browser (until I added Crusty’s CSS override in this browser). They look fine for many users, but break in others. If you’re more careful about how you build, you can avoid breakage in most if not all screens.

Why 72.1? Weird.

  1. you mean 72.27PtPi, right?

  2. if so most of the printing world, at least in the Americas has abandoned that since almost the entire industry works in postscript points ( the proper term for 72 dpi) nowadays… which is good since it threw away all the BS fractional bits and it results in a system that can divide large measurements by 2/3/4 without resorting to fractions… 12 points per pica, six pica’s per inch. 2^3 * 3^2 == 72.

Which is what I think the OP is missing… none of the measurements other than pixels has a defined size. It would be like saying dots == pt in print; which doesn’t work either given you could be printing as low as 72 dpi on some crappy 80’s dot-matrix, or 1200 dpi on a high end modern printer or even higher with offset lithography.

Maybe you should try using an OS that isn’t a rinky tinkertoy for desktop use where there’s zero consistency across applications? :smiley:

Though I didn’t think gnome selected font size in PX, but in PT much like windows… I’ll have to look at that again; you could be getting 24-30px and thinking it’s 20… NOT that ‘px’ is sent to any OS for font size properly since neither apple’s font renderer, windows font renderer, or cleartype actually accept px as a measurement leaving the conversion entirely in the developers hands. (which is why certain windows dev’s keep screwing that up on things like installers)

When you’re used to 20px, 16 can seem really small… what do those browsers say in their preferences?

For Opera (assuming you turned the real menu back on) that’s Tools -> preferences -> advanced -> fonts and look in the selection list for “web page normal text”.

I assume you meant that none of the measurements other than points have a defined size. There could be 1000 pisels in an inch or 1000 inches in a pixel depending on the screen size and the resolution that it is set to. Pixels are therefore the one measurement that is least defined as to how big it is. At least em and % are relative sizes so that the size of one thing will depend on the size of whatever it is defined relative to and therefore is more likely to still look right as the sizes change.

Though I didn’t think gnome selected font size in PX, but in PT much like windows…

While it states it in px, it may not really be using px at all. I’m not sure.

Re default font in Opera and Chrome: I would have to manually set in Opera, as you said… it simply doesn’t automagically accept from Desktop Application settings is all.

Chrome refuses to allow us to set the default font size. In fact that Google rant that’s been going around by a Google employee? The one posted on G+ where he went on and on about Google not “getting” it because it’s not building a platform like Amazon? He mentions the complete inability to set a default font size in that browser, meaning every page is a new CTRL++, CTRL++, CTRL++. Joy.

Anyway, I only use Chrome for testing and for logging into social bullcrap sites (let them track that browser all they want, it’s got nothing in ti : )

Thanks everyone , i have decided to use em, and % only since they suit my need.