Is a 12pt font the same height at any resolution/OS?

Is it possible to specify a font that is the same height irregardless
of resolution/OS?

Mark

Depends on what you mean by same height. The same physical size on screen is probably not possible because most systems do not report an accurate screen DPI and I think that different platforms translate point size to pixels differently. If you want the same number of pixels then you can use the alternate font constructor FontFromPixelSize and pass a wx.Size object instead of the point size.

···

On 8/4/10 12:10 AM, Mark wrote:

Is it possible to specify a font that is the same height irregardless
of resolution/OS?

--
Robin Dunn
Software Craftsman

This is what I meant. Its so basic I'm stunned its not possible. I
assume 12pt was meant to be some standard height in mm...

Mark

···

On Aug 5, 12:08 am, Robin Dunn <ro...@alldunn.com> wrote:

On 8/4/10 12:10 AM, Mark wrote:

> Is it possible to specify a font that is the same height irregardless
> of resolution/OS?

Depends on what you mean by same height. The same physical size on
screen is probably not possible because most systems do not report an
accurate screen DPI and I think that different platforms translate point
size to pixels differently.

12pt *is* a standard height. One point is 1/72 of an inch or .3527 mm.
In order to translate points to pixels, software needs to know how
many pixels on the screen make up one inch. Back in the good old days
you could buy a mac that was 72 dpi so there was no translation
necessary (and why macs could claim wysiwyg with a straight face).

If the system has the wrong information about the physical
capabilities of the device it will naturally do the wrong computation.
OTOH, if you have two devices that are properly configured, no matter
what size the physical screen is, a 12 point font should look the
same.

···

On Wed, Aug 4, 2010 at 1:13 PM, Mark <markreed99@gmail.com> wrote:

On Aug 5, 12:08 am, Robin Dunn <ro...@alldunn.com> wrote:

On 8/4/10 12:10 AM, Mark wrote:

> Is it possible to specify a font that is the same height irregardless
> of resolution/OS?

Depends on what you mean by same height. The same physical size on
screen is probably not possible because most systems do not report an
accurate screen DPI and I think that different platforms translate point
size to pixels differently.

This is what I meant. Its so basic I'm stunned its not possible. I
assume 12pt was meant to be some standard height in mm...

Hi Robin and all,

Is it possible to specify a font that is the same height irregardless
of resolution/OS?

Depends on what you mean by same height. The same physical size on screen is probably not possible because most systems do not report an accurate screen DPI and I think that different platforms translate point size to pixels differently.

That's not quite correct. wx is at fault here. At least the three major platforms have APIs that help with point -> pixel conversion, and the conversion is a standard one. wx doesn't use them, though, except on Windows. On other platforms, it uses a "generic" implementation that guesstimates the appropriate point size from the pixel size specified. (And it uses dc.GetCharHeight(), which doesn't return the font's pixel size, it measures the height of one of the characters in the font.) The funny part is that, on GTK and Mac, 1 point == 1 pixel (they probably did this for simplicity's sake), so ironically, on Mac and GTK, you'll get the right pixel size by using the point constructor, NOT the pixel constructor.

I tried to convince Vadim that we ought to fix SetPixelSize and the pixel constructor on GTK / Mac, but he apparently couldn't see what was wrong with it. Of course, if he had actually wrote a test on GTK and Mac and used it, he would have seen that it didn't give the right size (as is obvious if you try it with wxWebKit), but anyway, that got added to the list of things I couldn't get agreement to fix. (And even if I could get agreement that it was broken, there'd then probably be the argument that lots of people rely on the broken behavior so we can't fix it. :wink:

If you want the same number of pixels then you can use the alternate font constructor FontFromPixelSize and pass a wx.Size object instead of the point size.

To get correct results using pixels instead of points, one really needs to actually construct the font using pixels on Win and points on GTK / Mac. What's worse is that MSW actually has two different height measurement for pixels, "cell height" and "character height", and the latter is the one used when you pass the size to the wx constructor. Of course, on GTK and Mac, there is only the former, so it's always used. So, on MSW, the only way to get the correct pixel size that matches what you'd use on GTK and Mac, you have to (rather non-intuitively) pass in the negative of the pixel size, which is basically a 'flag' that tells Windows to consider it as the "cell height".

To summarize, font size handling in wx is really a big bag of hurt. :frowning: In 2.9, the MSW implementation has switched the default to "cell height" so that users can pass in the unmodified pixel size and get the expected result, but the pixel size "guesstimation" issue on non-Windows platforms is not fixed and probably won't be, so the pixel constructor will do the wrong thing on any platform other than Windows.

Regards,

Kevin

···

On Aug 4, 2010, at 9:08 AM, Robin Dunn wrote:

On 8/4/10 12:10 AM, Mark wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Thanks for setting me straight. I should have remembered some of that myself.

···

On 8/4/10 3:00 PM, Kevin Ollivier wrote:

Hi Robin and all,

On Aug 4, 2010, at 9:08 AM, Robin Dunn wrote:

On 8/4/10 12:10 AM, Mark wrote:

Is it possible to specify a font that is the same height irregardless
of resolution/OS?

Depends on what you mean by same height. The same physical size on screen is probably not possible because most systems do not report an accurate screen DPI and I think that different platforms translate point size to pixels differently.

That's not quite correct.

--
Robin Dunn
Software Craftsman