|
<< Click to Display Table of Contents >> Navigation: Forum > TIWFont and size in pixels |
06-14-2023, 11:49 AM:
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
06-15-2023, 05:03 AM:
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);
06-20-2023, 05:53 AM:
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
06-20-2023, 06:09 AM:
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.
06-20-2023, 09:39 AM:
Ok, thanks!
The reason for asking is that I have a TIWRegion with 2 TIWLabel 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