[Lazarus] Font sizes on various platforms

Bruce Tulloch bruce at causal.com
Wed Jul 8 01:27:26 CEST 2009


Graeme Geldenhuys wrote:
> Also does that mean I need to apply the same font size hack as the guy
> in the CSS article.
>
> eg:
>   ifdef MacOS
>      NormalFontSize = 13
>   elseif Windows
>      NormalFontSize = 8
>   elseif Linux
>      NormalFontSize = 10
>   else
>      NormalFontSize = 8  // ??? What would be correct as a default?
>
>   Label.Font.Size = NormalFontSize;
A solution similar to this is what I have adopted for cross-platform
font size compatibility.

However to avoid polluting the code too much I make almost universal use
of the ParentFont property (ie, assigned True) and assign the font at
the root of the visual hierarchy (usually the form) at runtime based on
the platform DPI. It works well when all your widgets use the same font.

On a related note, I asked this questions a while back but got no
replies. Anyone?

Bruce Tulloch wrote:
> My apologies if I've missed the obvious somewhere but how is the default
> font used by the form designer specified?
>
> If a form is created with the ParentFont property set to TRUE, from
> where does it get its font spec when it is open in the form designer?
> And how do I change this font spec without having to define it
> explicitly for every form (or frame) I create?
>
> Thx, Bruce.
Cheers, Bruce.




More information about the Lazarus mailing list