[Lazarus] Font sizes on various platforms

JoshyFun joshyfun at gmail.com
Tue Jul 7 20:36:19 CEST 2009

Hello Lazarus,

Tuesday, July 7, 2009, 2:33:07 PM, you wrote:

GG> DPI Differences
GG> ===============
GG> As far as I know this is the following default DPI settings on various
GG> platforms.

GG>   - 75 dpi for Mac OS
GG>   - 96 dpi for MS Windows
GG>   - auto detect or 110 dpi for X11, though I have seem many
GG>     applications an distros force a 96 dpi setting like Windows.

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. 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. 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.

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.

I'm usually developing in Windows environment with 96 dpi and a font
"normal" for Windows XP. In the formCreate event I'm writting:


procedure TfrmMain.FormCreate(Sender: TObject);
  //Scale for Pixels per inch, designed is shown in the form properties (96).
  //Now scale for a font proportion
  ScaleByRecursive(Self,LAZYFOXSTRING,Self.Canvas.TextWidth('Lazy Fox Jumps'));

Where the "LAZYFOXSTRING" is the "Lazy Fox Jumps" width in my
development environment.

Best regards,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uscalebycomctrls.pas
Type: application/octet-stream
Size: 1048 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20090707/1a98ff1d/attachment-0008.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uscaleby.pas
Type: application/octet-stream
Size: 4524 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20090707/1a98ff1d/attachment-0009.obj>

More information about the Lazarus mailing list