Recent

Author Topic: Difference in formatting TForm Windows - Linux  (Read 609 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 886
Difference in formatting TForm Windows - Linux
« on: January 21, 2026, 09:20:22 pm »
Hi
I'm making a tool that will work on Windows 11 and Linux (Ubuntu, Lazarus on Ubuntu uses QT5). I run into the fact that if I align the components neatly on TForm in Windows, they will overlap in Linux. See the attachements. One difference I see is the font size. It seems to be larger in Linux than in Windows, but reducing it does not seem to solve the overlap.

What are the tips to build a form (view) neatly so that it looks good in Windows and Linux. Should I start thinking about the anchor editor?


Bart

  • Hero Member
  • *****
  • Posts: 5675
    • Bart en Mariska's Webstek
Re: Difference in formatting TForm Windows - Linux
« Reply #1 on: January 21, 2026, 09:49:01 pm »
Should I start thinking about the anchor editor?

Yes.

Bart

Hansvb

  • Hero Member
  • *****
  • Posts: 886
Re: Difference in formatting TForm Windows - Linux
« Reply #2 on: January 22, 2026, 07:27:23 pm »
Quote
Yes.
Great, work to be done :)

cdbc

  • Hero Member
  • *****
  • Posts: 2611
    • http://www.cdbc.dk
Re: Difference in formatting TForm Windows - Linux
« Reply #3 on: January 22, 2026, 08:10:04 pm »
Hi
That's good advice from Bart =^
I can say, that I've tried quite a few different widgetsets ...and window-managers in Linux and it's kind of a rule, that they differ, some much and some not so much, but differ -- That they do!
I guess that, to completely alleviate that, we'd have to resort to 'fpGUI' or 'mseGUI', as they're drawn from scratch...  <<Oh Boy>>
Well, I wish you a fun time, coming to grips with Anchor(s) & -docking  8)
Tjuh, Tjuh, Tjuuuhhhh...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Fred vS

  • Hero Member
  • *****
  • Posts: 3780
    • StrumPract is the musicians best friend
Re: Difference in formatting TForm Windows - Linux
« Reply #4 on: January 22, 2026, 09:09:29 pm »
I guess that, to completely alleviate that, we'd have to resort to 'fpGUI' or 'mseGUI', as they're drawn from scratch...

And without any dependencies, with source code written in Pascal...  :-X
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Hartmut

  • Hero Member
  • *****
  • Posts: 1072
Re: Difference in formatting TForm Windows - Linux
« Reply #5 on: January 23, 2026, 09:30:18 am »
I had the same problem when I ported my existing Windows GUI programs later to Linux (Ubuntu GTK2). I solved it mostly with the following 2 procedures:

Code: Pascal  [Select][+][-]
  1. procedure setFormFonts_Default(F: TForm);
  2.    {sets on Linux the Font and Font Height of all GUI-Controls of a Form to my personal Defaults}
  3.    begin
  4. {$IFDEF LINUX}
  5.    F.Font.Name:='Noto Sans';
  6.    F.Font.Height:=12;
  7. {$ENDIF}
  8.    end;

The 1st procedure changes on Linux the Font and Font Height for 1 Form, which normally is inherited to all GUI-Controls of that Form, because they normally have 'ParentFont=True'. In many cases that's all what I need to call this procedure once for every Form.

But if you change something in the Font of a GUI-Control (e.g. the 'Font.Color'), then this automatically changes it's 'ParentFont:=False' and above procedure does not longer work for that GUI-Control. In this case I call the following procedure afterwards:

Code: Pascal  [Select][+][-]
  1. procedure setFormControls_Font_Height(F: TForm; name: string; height: integer);
  2.    {sets for all GUI-Controls of a Form a certain Font Name and Font Height}
  3.    var C: TComponent;
  4.        i: integer;
  5.    begin
  6.    for i:=0 to F.ComponentCount-1 do
  7.       begin
  8.       C:=F.Components[i];
  9.       if C is TControl then
  10.          begin
  11.          TControl(C).Font.Name:=name;
  12.          TControl(C).Font.Height:=height;
  13.          end;
  14.       end;
  15.    end;

 

TinyPortal © 2005-2018