Font Size differences between platforms

Dj Gilcrease wrote:

I played with Mac's anti-aliasing settings which made no visual
difference. Anyway, is there supposed to be a 1:1 correlation between
pixels and points (I didn't think so)?

No 1pt is 1/72 of an inch, so if your screen resolution is 96dpi
(Fairly standard now) an 8pt font should be 11 px high (10.7
actually), a 12pt font would be 16 px high etc (pt/.75)

Thanks for the clarification and reminder of how this stuff relates!

The hardcoded value is only really a starting point, as we already allow
for font zooming (using Ctrl++ and Ctrl+-). I'm just looking for the
starting point to be similar platform to platform given identical screen
and font resolutions.

I did some testing as I have run into issues with users complaining
about a font being too small on OSX before and found that the OSX pt
size appears to actually displays 2 lower then what you set it as.
Windows and GTK are the same, even in your image (The perceived
difference is an optical illusion due to the button size difference).
The reason I think OSX does this is because pre OSX Mac's used a 72dpi
resolution so there was a 1:1 correlation between pt and px and they
wished to maintain this with OSX (Thus they multiply the actual pt
size by .75 which negates the difference, but also reduces the font
size you actually see)

Ok, I went to Text Edit and verified that 8pt looks horribly small there, too. So, now I understand why Mac users always put things in 12 pt, which looks too big to me, especially when printed out.

My problem boils down to: if I set the font size to 12 to be nice on Mac, it will look too big when that code runs on Win or Lin. If I set it to 10 on Win/Lin, it'll be perceived as too small on Mac.

If you modify your test to include

   dc = wx.ClientDC(frm)
   print fontSize, dc.GetFullTextExtent(but.GetLabel(), font)
   del dc

in the for loop you will see the Height is the same for winXP and GTK,

> but lower on OSX. My guess (I dont have OSX) is you will get the
> following heights on OSX
> 10
> 12
> 14
> 17

On Windows, I get:
13
16
19
23

On Ubuntu:
13
17
19
23

On OS X:
9
12
15
17

So, your guess is correct. Any ideas on how to solve this cross-platform problem in a general way?

···

On 3/24/07, Paul McNett <p@ulmcnett.com> wrote:

--
pkm ~ http://paulmcnett.com

Dj Gilcrease wrote:
>> I played with Mac's anti-aliasing settings which made no visual
>> difference. Anyway, is there supposed to be a 1:1 correlation between
>> pixels and points (I didn't think so)?
>
> No 1pt is 1/72 of an inch, so if your screen resolution is 96dpi
> (Fairly standard now) an 8pt font should be 11 px high (10.7
> actually), a 12pt font would be 16 px high etc (pt/.75)

Thanks for the clarification and reminder of how this stuff relates!

[...]

On Windows, I get:
13
16
19
23

On Ubuntu:
13
17
19
23

On OS X:
9
12
15
17

So, your guess is correct. Any ideas on how to solve this cross-platform
problem in a general way?

Get the default values from the window manager?
I'm not sure how to do that (google points to "defaultGuiFont =
wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
") but I think it is the only user-friendly way to handle the situation.
Any default set by the programmer might be totally wrong:
- small font on high resolution screen -> unreadable
- big font on small screen -> OK button unreachable below visible area
I already had to deal with both cases, didn't like it at all. :wink:

If it is impossible to get a default font size from the window manager
it might be possible to adjust the values depending on screen
resolution (GetDisplaySize, GetDisplaySizeMM). That would result in
the same size on all systems without adding special code for OS X.

On at least one of my Linux boxes it's possible to set the screen
resolution to 120 dpi in the KDE settings. As these settings are used
during program startup I managed to create two console windows with
the same font size setting and different font sizes on screen. Other
operating systems/window managers might support different screen
resolutions, too.

Harald Stürzebecher

···

2007/3/24, Paul McNett <p@ulmcnett.com>:

> On 3/24/07, Paul McNett <p@ulmcnett.com> wrote: