TIWFont and size in pixels - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: TIWFont and size in pixels (/thread-3313.html) |
TIWFont and size in pixels - Lenfors - 06-14-2023 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 RE: TIWFont and size in pixels - Alexandre Machado - 06-15-2023 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); RE: TIWFont and size in pixels - Lenfors - 06-20-2023 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 RE: TIWFont and size in pixels - Alexandre Machado - 06-20-2023 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. RE: TIWFont and size in pixels - Lenfors - 06-20-2023 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 |