Recent

Author Topic: TForm.ScaleBy bug?  (Read 1710 times)

Handoko

  • Hero Member
  • *****
  • Posts: 3547
  • My goal: build my own game engine using Lazarus
TForm.ScaleBy bug?
« on: December 31, 2017, 09:30:28 am »
Did I do it wrong or is it a bug?  TForm.ScaleBy seems to work correctly on images and buttons but not on texts. Tested on Lazarus 1.8.0 Gtk2 on Ubuntu Mate 17.10 64-bit.

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, ExtCtrls, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     btnSmaller: TButton;
  16.     btnBigger: TButton;
  17.     Image1: TImage;
  18.     Label1: TLabel;
  19.     Shape1: TShape;
  20.     procedure btnBiggerClick(Sender: TObject);
  21.     procedure btnSmallerClick(Sender: TObject);
  22.     procedure FormCreate(Sender: TObject);
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.btnSmallerClick(Sender: TObject);
  35. begin
  36.   ScaleBy(1, 2);
  37. end;
  38.  
  39. procedure TForm1.btnBiggerClick(Sender: TObject);
  40. begin
  41.   ScaleBy(2, 1);
  42. end;
  43.  
  44. procedure TForm1.FormCreate(Sender: TObject);
  45. begin
  46.   Image1.Picture.LoadFromFile(ExtractFilePath(ParamStr(0))+'project1.ico');
  47.   Image1.Stretch := True;
  48. end;
  49.  
  50. end.

Handoko

  • Hero Member
  • *****
  • Posts: 3547
  • My goal: build my own game engine using Lazarus
Re: TForm.ScaleBy bug?
« Reply #1 on: December 31, 2017, 09:44:36 am »
It is a bug. I found someone already reported it on the bug tracker forum:
https://bugs.freepascal.org/view.php?id=26652

jamie

  • Hero Member
  • *****
  • Posts: 3116
Re: TForm.ScaleBy bug?
« Reply #2 on: December 31, 2017, 08:27:11 pm »
in the windows environment the fonts are scaled by the OS to fit the current Dots per inch..

so font scaling there should not be touched unless its a non-windows managed control but
even then, if that type of control is using the parent canvas, which most likely it is, then the
scaling for the font should carry over..

 As  for the  other platforms, I can't say, but if you are using the scaleBy to change the
scene, then I think you'll also need to scale the fonts too.

 I come from a Windows environment and that is how it's done..

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018