Search code examples
linuxpluginsgimprcgimpfu

Font size rendering is different depending upon login using Gimp?


I am using Gimp python-fu plugin. The plug-in written correctly renders a text block:

(GIMP_UNIT_POINT = 3)
titleBlockLayer = pdb.gimp_text_layer_new(img, title, <font_name>, 40, GIMP_UNIT_POINT)

but only if gimp is invoked from the X window manager (or a terminal window) when logged in on the computer's console (Fedora, various releases, same behavior; various releases of GIMP, same behavior). However, when logged in via ssh, (using X11 forwarding to display locally), the fonts are rendered HUGE by comparison.

I am confused because (supposedly) the same login .profile and .rc files have been run regardless.

Does anyone have a clue as to what/where/how GIMP determines what a POINT means, because it is obviously not coded in but dependent upon some resource file.


Solution

  • For Gimp a point is 1/72 of an inch, according to the doc of gimp_text_get_extents_fontname() in the PDB browser:

    If you need to display a font in points, divide the size in points by 72.0 and multiply it by the vertical resolution of the image you are taking into account.

    Experimentally, when using points in gimp_text_layer_new() the size depends on the image print definition. This value can depend on user settings (72DPI by default) but you can control/set it using gimp_image_get_resolution(...) and gimp_image_set_resolution(...). What bothers me though it that it seems that at least on my Ubuntu 16.04 gimp_text_layer_new() works in inches and not in points (at 72DPI, points and pixels should be equivalent), so I would stick to using pixels and to the point<->pixels conversions using the image resolution.

    Btw, what are the versions of Gimp and the Pango and Cairo libs on your various systems?

    Edit: Possible explanation: it appears that in recent versions (since 2.8 at least), gimp_text_layer_new() accepts more than units than just pixels and points. It also takes millimeters, inches, and picas. So it's no longer 0 for pixels and 1 for points, and you can use the predefined UNIT_* values. The catch: 1 is no longer the value for points but is now the value for inches:

    UNIT_PIXEL=0
    UNIT_INCH=1 
    UNIT_MM=2
    UNIT_POINT=3
    UNIT_PICA=4