Jump to content

Measuretext not doing a great job :(


Recommended Posts

The function 


function TW3FontDetector.MeasureText(const FontName: string;   const FontSize: integer; const Text: string): TW3TextMetric;

 

in SmartCL.Fonts.Detector; replace spaces with _ resulting in spaces being way over estimated. The problem is when trying to right justify the measured width is much larger than the space required to render the font. So you cannot right justify text.

Replacing the _ with a ! gives a closer result but it is still a hack - is there a proper solution to calculating the width a given text?

 

I have attached a simple project to demonstrate the issue.

The two sentences are supposed to be right aligned, however, the extra spaces in the second line causes the width to be over estimated.

 

ImageMouseDown.rar

2018-09-04_12-29-46.gif

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...