[Lazarus] gtk2 font sizes

C Western l at c-m-w.me.uk
Sat Nov 2 18:21:34 CET 2019


I have just upgraded to Fedora 31, and noticed some odd effects with 
font sizes. With some investigation the cause seems to be that the 
underlying font sizes can be a non-integer number of pixels; with a 
'MonoSpace' example looking at gtk2widgetset.inc:5919:

TextMetric.tmAscent := pango_font_metrics_get_ascent(APangoMetrics) div 
PANGO_SCALE;

evaluates as 11406/1024 = 11.129 which is truncated to 11

TextMetric.tmDescent := pango_font_metrics_get_descent(APangoMetrics) 
div PANGO_SCALE;

evaluates asĀ  2898/1024 = 2.83 which is truncated to 2.

The effective font height seems to be 2 pixels larger in this case, ot 
at least that is what is required to fix previously working code. I 
wonder if these calculations should be rounded up rather than down?

Colin





More information about the lazarus mailing list