Recent

Author Topic: Default font size  (Read 4035 times)

ps

  • Full Member
  • ***
  • Posts: 136
    • CSS
Default font size
« on: December 13, 2017, 05:54:15 pm »
I need paint bigger and smaller fonts based on "default" font. So how to get real "default" font size multiplatform and multi DPI.

Default Font.Size and Font.Height is 0. So how to get real size and work with it.
Small simple CSS/box model implementation: https://github.com/pst2d/csscontrols/tree/dev

lainz

  • Hero Member
  • *****
  • Posts: 4461
    • https://lainz.github.io/
Re: Default font size
« Reply #1 on: December 13, 2017, 06:01:04 pm »
Here you go:
Code: Pascal  [Select][+][-]
  1. FBaseHeight := abs(GetFontData(Font.Reference.Handle).Height);

Ramona G. Smith

  • Newbie
  • Posts: 5
Re: Default font size
« Reply #2 on: December 13, 2017, 06:14:12 pm »
Thanks Lainz! I was also looking for fonts. This is useful stuff.

ps

  • Full Member
  • ***
  • Posts: 136
    • CSS
Re: Default font size
« Reply #3 on: December 13, 2017, 06:33:56 pm »
thanks lainz. Full code for Font.Size:

Code: Pascal  [Select][+][-]
  1. RealFontSize := Round((- GetFontData(b.Font.Handle).Height * 72 / b.Font.PixelsPerInch))

Tested only on Windows 10 with different scale and with multimonitor DPI (Font.Size is allways same). Font.Height is changing to real pixels.

Update: Lol now I see "bug" in my code, forgot Font.Reference.Handle from your code and code works. What's difference?
« Last Edit: December 13, 2017, 06:37:19 pm by ps »
Small simple CSS/box model implementation: https://github.com/pst2d/csscontrols/tree/dev

 

TinyPortal © 2005-2018