Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIWFont and size in pixels
#1
Hello!

I need a function to get the height and width of a string in pixels if I know the TIWFont used.


Best regards, Mikael
Reply
#2
When you set the size of the font in points (property Size) IntraWeb automatically calculates and updates the property PxSize which contains the font size in pixels.

You can also use

class function TIWFont.PtToPx(AFontSize: Integer): Integer;

Just use it like:

PxSize := TIWFont.PtToPx(12);
Reply
#3
Hello!

I Don't understand how this can help me :-) What I need is the length AND height of a string in pixels!
Your function doesn't even contain the string!
And there is no PtToPy function for calculating the height!

Best regards, Mikael
Reply
#4
There is no way to predict the size of the text when rendered in a browser using a specific font, if that's what you want.

The only way is effectively rendering the text on the browser side and retrieving the dimensions after applied the style, meaning that you first render it and then you find out the size.
Reply
#5
Ok, thanks!

The reason for asking is that I have a TIWRegion with 2 TIWLabelConfused inside, both aligned Top. Now I want to set the size of the Region to exactly fit the two labels.
Is this possible?

Best regards, Mikael
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)