It seems like you are actually messing with widths when dealing with whitespaces and not the actual characters. Cause when using clipstring = 2 max number of white spaced lines at starting are two, no matter how many spaces you actually have.
And the trailing white spaces are not included in the ending with ClipString=2.
Screenshot 2021-11-05 160641.png
StringAlign=Right is messed up as the "spaces" which aren't really spaces appear at the right hand side. ClipString=1: Incorrect:
Screenshot 2021-11-05 162038.png
Correct:
Screenshot 2021-11-05 162144.png
ClipString=2: Incorrect:
Screenshot 2021-11-05 161151.png
Correct:
Screenshot 2021-11-05 161457.png
In my opinion, if we can't actually add literal whitespace characters to a string, then we shouldn't.
P.S. isn't there any other library we can use to render string meter? Ofc, you don't have to do it if the cost-benefit ratio is greater than 1. Just saying cause ActiveColors posted this:
Screenshot 2021-11-05 163007.png
[/url]
a while back, which won't be a bad thing I guess...
Also I was trying to embed a link to the image above, which partially works lol.
You do not have the required permissions to view the files attached to this post.
The ClipString=1 issue can be fixed easily enough. However, the ClipString=2 issue is more difficult at this time.
[Technical details]
The issue is the way DirectWrite calculates the text metrics for a layout. By default, DirectWrite ignores trailing whitespaces altogether. They provided a way to calculate the correct width when trailing whitespace is present. This method is available from Windows 7 and on.
Here is the structure (note the "widthIncludingTrailingWhitespace" member): https://docs.microsoft.com/en-us/windows/win32/api/dwrite/ns-dwrite-dwrite_text_metrics
However, because multiline text is delimited on whitespace, the remaining text is moved to the next line. If additional whitespace is all that is moved to the next line, DirectWrite just ignores it. Obviously Microsoft realized the mistake of not calculating the correct height for trailing whitespace and added a function to get it. But...it's only available for Windows 8.1 or later.
Here is the structure: https://docs.microsoft.com/en-us/windows/win32/api/dwrite_2/ns-dwrite_2-dwrite_text_metrics1
[/Technical details]
death.crafter wrote: ↑November 5th, 2021, 11:03 am
In my opinion, if we can't actually add literal whitespace characters to a string, then we shouldn't.
I am starting to agree with this. DirectWrite seems to be the culprit with some of this, which unfortunately, we cannot really fix until we drop support for Windows 7 and 8.
Drat.
PS -
death.crafter wrote: ↑November 5th, 2021, 11:03 amP.S. isn't there any other library we can use to render string meter?
I don't know of any other library that is build-in and seemlessly integrates with D2D. Anything else will be a massive rewrite to this part of the code, and doesn't seem warranted.
Brian wrote: ↑November 5th, 2021, 7:10 pm
I am starting to agree with this. DirectWrite seems to be the culprit with some of this, which unfortunately, we cannot really fix until we drop support for Windows 7 and 8.
Well, I am not being reasonable, but let's weight the options here.
If you add this option then we won't be facing backwards compatibility issues, since it is a completely new feature.
And we could always follow Microsoft, if you won't upgrade your thing, then you can't use new features.