GNOME Bugzilla – Bug 309868
Incorrect font sizes
Last modified: 2005-10-20 00:34:47 UTC
Please describe the problem: Hi, if you check on win32 GTK+ apps such as The GIMP or Gaim and then compare them to AIM or a word processor you will notice the the font sizes seem to be a point size off of what they should be. This is a bug I have noticed for a long time in the win32 GTK port and its really annoying. Especially if you're doing work in The GIMP and the font sizes are all wrong. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
So are all other Windows apps consistent with each others regarding font size? Is it only GTK+ apps that stand out?
Yeah, Windows apps have no problems with font sizes as far as I can tell. It's just that with GTK+ apps for Windows there has always been a problem where the fonts are either 1 pt size too large or too small.
Hmm, yes. For instance wordpad and notepad seem to agree very closely on the size of chars in "tahoma 12", while in GTK+ "tahoma 12" is *much* smaller. This definitely is against user expectation, yes.
Yeah, I loaded up Gaim and AIM and send messages to two accounts from both clients and the font sizes were way off.
The same problem still exists in GTK+ 2.8, but here the code path is quite different, and the root cause presumably also. In GTK+ 2.8 the problems seems to be that cairo-win32-font.c in _win32_scaled_font_get_scaled_hfont() sets logfont.lfHeight to the (positive) value of scaled_font->logical_size. (And correspondingly in _win32_scaled_font_get_unscaled_hfont() sets logfont.lfHeight to the (positive) value of scaled_font->em_square.) If it would set lfHeight to the negative of those values the font sizes would match what for instance Wordpad uses.
This should be fixed now in the upcoming cairo 1.0.2, and will thus help GTK+ 2.8. GTK+ 2.6 is not maintained any longer.
Are you certain this is fixed? I'm running Gimp 2.3.4 with GTK+ 2.8.6 which is supposed to have Cairo 1.0.2 but after comparing a 10pt arial font in Gimp to a 10pt arial font in WordPad they're way off.
Pretty sure, yes. Is the libcairo-2.dll you are using 336102 bytes in size? In which part of the GIMP are you comparing the font sizes, in the GTK GUI or the text produced by the GIMP's text tool? This bug concerns only the first kind of text. The GIMP's text tool uses a quite different API (PangoFT2) and goes through a quite different code path. Please open another bug for that, if you feel it is a problem. Please note though that Wordpad is not an image editor. The GIMP is, and the only thing that matters, really, sizewise is the pixel size of the image (and parts of it, like text). You can print an image at any size you want anyway, no matter what size in "points" text on it is supposed to be.
Yosh points out to me that the GIMP's text tool uses the image's dpi setting to interpret what a font size in physical units like points or inches means in pixels. The default dpi when creating a new image in the GIMP is 72. If you want the font sizes used by the GIMP's text tool to correspond to the font size of text-based applications like WordPad, or GTK+ font sizes, set the image's dpi to the dpi of your display. Typically that would be 96 on current Windows boxes, I think. Check Display Settings to be sure. Then the font size (in the vertical direction) will closely correspond to what you see in WordPad, or in GTK+ GUI text (like the text in the GIMP's dialogs). See attached image for an example. The leftmost text is produced by GIMP's text tool with font "arial" size 10 points, the middle one is GIMP's GUI (with gtk-font-name="arial 10" in the gtkrc), and the rightmost is WordPad. As one sees, the glyphs produced by the GIMP's text tool are shaped differently and have different horizontal dimensions. That is because the GIMP's text tool uses FreeType, while GTK+ and WordPad use GDI.
Created attachment 53671 [details] Screenshot