Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-06

Real Font Size

7 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vojtěch Čihák

Hello,
is there a cross-platform way how to obtain real font size ? Currently all components has default size 0. But in real numbers it is usually 9 ~ 12 - depends on system setting. I would like to use smaller font, for example 2/3 of the default size. Is there something like: ?
Canvas.Font.Size := 2 * GetRealFontSize(Font.Size) div 3; (Of course there are many system setting for fonts. I'm interested in font-size of the most common components like TLabel). ?
Thanks.?
?
?
?

Reply by email

zeljko
to Vojtěch Čihák
Vojt?ch ?ih?k wrote 5 lines
Hello, is there a cross-platform way how to obtain real font size ? Currently all components has default size 0. But in real numbers it is usually 9 ~ 12 - depends on system setting. I would like to use smaller font, for example 2/3 of the default size. Is there something like: Canvas.Font.Size := 2 * GetRealFontSize(Font.Size) div 3; (Of course there are many system setting for fonts. I'm interested in font-size of the most common components like TLabel).

There's no such function, but I guess that you can use LCLIntf.GetObject(MyControl.Font.Reference.Handle .....) and read lfHeight from there ?

zeljko

Reply by email

Mattias Gaertner
to zeljko
Show quoted text 10 lines
On 06/16/2013 05:03 PM, Vojt?ch ?ih?k wrote: > Hello, > is there a cross-platform way how to obtain real font size ? Currently all components has default size 0. But in real numbers it is usually 9 ~ 12 - depends on system setting. I would like to use smaller font, for example 2/3 of the default size. Is there something like: > > Canvas.Font.Size := 2 * GetRealFontSize(Font.Size) div 3; > (Of course there are many system setting for fonts. I'm interested in font-size of the most common components like TLabel). There's no such function, but I guess that you can use LCLIntf.GetObject(MyControl.Font.Reference.Handle .....) and read lfHeight from there ?

Problem is that the real font size requires the real font handle. We need some more flexible property to define the size relative to the default.

Mattias

Reply by email

Vojtěch Čihák
to zeljko: There's no such function, but I guess that you can use…

Thanks, I tried:
?
uses ... LCLIntf, LCLType;?
?
var aLogFont: TLogFont;
begin
? ? LCLIntf.GetObject(Label1.Font.Reference.Handle, sizeof(TLogFont), @aLogFont); ? ? WriteLn(aLogFont.lfHeight); ??
?
but it doesn't work (returns -1 on Qt and 0 on GTK). lfFaceName works well, returns correctly "DejaVu Sans" for both Qt and GTK here.? ?
Vojt?ch?
______________________________________________________________

There's no such function, but I guess that you can use LCLIntf.GetObject(MyControl.Font.Reference.Handle .....) and read lfHeight from there ?

zeljko

Reply by email

zeljko
to Vojtěch Čihák
Vojt?ch ?ih?k wrote 10 lines
Thanks, I tried: uses ... LCLIntf, LCLType; var aLogFont: TLogFont; begin LCLIntf.GetObject(Label1.Font.Reference.Handle, sizeof(TLogFont), @aLogFont); WriteLn(aLogFont.lfHeight); but it doesn't work (returns -1 on Qt and 0 on GTK). lfFaceName works well, returns correctly "DejaVu Sans" for both Qt and GTK here.
hm  .... this is from qtwinapi:
  ALogFont^.lfHeight := AFont.getPixelSize;

Qt returns pixelSize, but in case if it's -1 then getPointSize should be returned.
Pls open issue about this, I'll fix it.

Gtk2 returns only font name (other info isn't implemented) , so separate issue about this would be a "nice to have".

zeljko

Reply by email

zeljko
to Vojtěch Čihák: Thanks, I tried: ? uses ... LCLIntf, LCLType;? ? var aLogFont: TLogFont; begin ? ?…
Vojt?ch ?ih?k wrote 10 lines
Thanks, I tried: uses ... LCLIntf, LCLType; var aLogFont: TLogFont; begin LCLIntf.GetObject(Label1.Font.Reference.Handle, sizeof(TLogFont), @aLogFont); WriteLn(aLogFont.lfHeight); but it doesn't work (returns -1 on Qt and 0 on GTK). lfFaceName works well, returns correctly "DejaVu Sans" for both Qt and GTK here.

Qt is fixed and issue is resolved :)

z.

Reply by email

Vojtěch Čihák
to zeljko

Thanks, I tested and closed.
______________________________________________________________

Od: "zeljko" Komu: "Vojt?ch ?ih?k" Datum: 17.06.2013 13:35 P?edm?t: Re: [Lazarus] Real Font Size

Qt is fixed and issue is resolved :)

z.

Reply by email