[Lazarus] Font sizes on various platforms

Hans-Peter Diettrich DrDiettrich1 at aol.com
Wed Jul 8 08:24:17 CEST 2009


JoshyFun schrieb:

> GG> Now as far as I know this makes fonts look difference in size for the
> GG> same font height. Is this only true when the font size is defined as
> GG> pixel heigh, or does it also apply when font sizes are defined in points
> GG> height as well?
> 
> And also default font could be very different across platforms and
> even in the same platform.

The dpi and default font size should be considered together, because 
they make standard text appear to the user in *his* preferred size. 
While every platform has a different opinion about *how* the user should 
specify his preferences, the resulting default font size in pixels 
should be understood as a *user* specific constant.

Unfortunately multiple monitors can have different resolutions, so that 
they may have different dpi values. But IMO this should not require to 
scale forms differently for every monitor, because the desktop 
management of every platform most probably will use common parameters 
for the entire desktop.


> To "solve" both problems in my cross
> platform applications (Linux and Windows) I'm using a self designed
> ScaleBy function which in the design platform takes some parameters,
> like a test string width, and scales all visual elements in the form
> to preserve look.

This is why Microsoft in Visual Studio uses Twips (1/20 pt) instead of 
pixels, for all component positions and extents. In Delphi such scaling 
is implemented by the Scaled and PixelsPerInch form properties.


> Of course it will change the width and height of the
> scaled forms. The main problem is that some visual objects must not be
> scaled for any reason, and there is no way to prevent it, anyway they
> are not common.

Delphi controls have a ScalingFlags property, indicating which 
properties already have been scaled. A second property of that type 
could indicate *which* of these properties should [not] be scaled at 
all, so that scaling could be turned off for graphical controls which 
contain neither text nor scale nicely (bitmaps...). Or a single boolean 
value [Scaled?] could specify whether the control has to be resized at 
all, while its position always should scale together with all other 
controls.

> Maybe something like this functions can be added to the LCL to get
> compatibility with "ScaleBy"'s Delphi.
> 
> Attached is the current code, it has not been finished and only
> checked in in some quite simple forms.

Nice concept :-)

DoDi





More information about the Lazarus mailing list