It is currently April 18th, 2024, 5:55 am

Wrong character spacing on aliased fonts

General topics related to Rainmeter.
User avatar
arlong_pete
Posts: 4
Joined: March 6th, 2021, 2:17 pm

Wrong character spacing on aliased fonts

Post by arlong_pete »

I'm coming back to Rainmeter after more than 10 years but I see that what I was trying to do back in the day still has the same issues.

So these are my settings:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[TextStyle]
FontFace=Tahoma
FontSize=8
AntiAlias=0
And this is the result:

kerning.png

As you can see the character spacing is pretty messed up and I cannot adjust it with individual CharacterSpacing settings for each letter because the same letter behaves differently in different words as far as I can see.

Is there something that can be done about this or I have to give up?

I really like how Tahoma looks aliased and at this size but I never managed to use it in a Rainmeter skin.
You do not have the required permissions to view the files attached to this post.
Last edited by arlong_pete on March 7th, 2021, 4:21 pm, edited 1 time in total.
The sinful crown spinning the hearts of people into real form.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2602
Joined: March 23rd, 2015, 5:26 pm

Re: Wrong character spacing on aliased fonts

Post by SilverAzide »

Any particular reason you are turning off anti-aliasing (AntiAlias=0)? You'll never get any font at this point size to look right, unless it is especially designed for small sizes and/or for monitors (instead of printing). "Segoe UI" is an example of a font intended for UIs, and it is fairly close to Tahoma.

Tahoma with antialiasing off at top, on at bottom:
Annotation 2021-03-06 104749.png
Segoe UI with antialiasing off at top, on at bottom:
Annotation 2021-03-06 105542.png
P.S.: This issue does not have anything to do with Rainmeter. It's Windows that is drawing the text.
You do not have the required permissions to view the files attached to this post.
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Wrong character spacing on aliased fonts

Post by jsmorley »

I think this works better if you put a tiny space between each letter...

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeasureString]
Measure=String
String=qwertyoalkwserildkasiekdk
RegExpSubstitute=1
Substitute="(.)":"\1 "

[MeterString]
Meter=String
MeasureName=MeasureString
FontFace=Tahoma
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=8
AntiAlias=0
InlineSetting=Size | 1
InlinePattern=[\x20]
1.jpg

2.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Brian
Developer
Posts: 2678
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Wrong character spacing on aliased fonts

Post by Brian »

Another option is using the CharacterSpacing option for InlineSettings.
https://docs.rainmeter.net/manual/meters/string/inline/#InlineCharacterSpacing

Code: Select all

[Test]
Meter=String
FontFace=Tahoma
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=8
AntiAlias=0
Text=qwertyoalkwserildkasiekdk
InlineSetting=CharacterSpacing | 0.5 | 0.5
CharacterSpacing.png
-Brian
You do not have the required permissions to view the files attached to this post.
User avatar
arlong_pete
Posts: 4
Joined: March 6th, 2021, 2:17 pm

Re: Wrong character spacing on aliased fonts

Post by arlong_pete »

SilverAzide wrote: March 6th, 2021, 3:54 pm Any particular reason you are turning off anti-aliasing?
Yes, anti-aliased fonts at this size just look bad and blurred to me, and I personally like the pixel perfect look.
SilverAzide wrote: March 6th, 2021, 3:54 pm ...You'll never get any font at this point size to look right...
...This issue does not have anything to do with Rainmeter. It's Windows that is drawing the text...
And yet Windows 10 itself (like any previous version) it's perfectly capable to draw aliased Tahoma 8:

win10_icon_alias.png
Besides it's not only about Windows, aliased Tahoma 8 looks (correctly) like that in HTML, in a text editor, even in Photoshop.
This is just like it's supposed to look.

What I'm trying to achieve is exactly that, the correct spacing of exactly one pixel between one character and the other.
And I can't figure out why Rainmeter displays it like that.

Thank you very much for the replies and suggestions Brian and jsmorley, those are both interesting workarounds but they still can't help in what I'm trying to do.
You do not have the required permissions to view the files attached to this post.
The sinful crown spinning the hearts of people into real form.
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Wrong character spacing on aliased fonts

Post by Active Colors »

It is in fact strange that the spacing for the same letter gets off after some interval. I tried turning AccurateText on and off and the results are different but with the same spacing issue.
1.PNG
0.PNG
You do not have the required permissions to view the files attached to this post.
User avatar
arlong_pete
Posts: 4
Joined: March 6th, 2021, 2:17 pm

Re: Wrong character spacing on aliased fonts

Post by arlong_pete »

Exactly, there's something strange going on.
I even tried monospaced sans serif fonts with the same result.
This is DejaVu Sans Mono for example:

dejavu_spacing.png
For this reason even adjusting manually the spacing with the suggested workarounds leads to uneven results, less evident but still visible.
You do not have the required permissions to view the files attached to this post.
The sinful crown spinning the hearts of people into real form.
User avatar
Brian
Developer
Posts: 2678
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Wrong character spacing on aliased fonts

Post by Brian »

I think what is happening is when we switched from GDI+ rendering to D2D rendering (specifically DirectWrite), it was important for existing skins to render as close as possible to the previous GDI+ rendering. We didn't want the thousands of existing skins to look "off" with different spacing, so we attempted to correct this as best as we could. Nothing was pixel perfect, but we got it close as we could.

I believe this is one of the few side effects of this "emulation" code. In fact, this is one of the reasons we did the CharacterSpacing inline setting, so that you could tweak things to your liking.

The fact of the matter is, there is just a ton of options when rendering text with different rendering engines. We chose to have a consistent look across platforms since one of our greatest strengths is our existing skins library. I could only imagine the complaints if all the sudden all those skins didn't align correctly and look "off". Other programs have made other rendering decisions without that restriction.



Unfortunately, I think the only solution is to use the CharacterSpacing inline setting. I spent a little more time tweaking things, and you can get really close (in my opinion).

Code: Select all

[Test]
Meter=String
FontFace=Tahoma
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
FontSize=8
AntiAlias=0
Text=qwertyuiopl#CRLF#abcdefghijklmnopqrstuvwxyz012345679-=_+`~!@#$%^&*()[]{};':",./<>?\|
InlineSetting=CharacterSpacing | 0.14 | 0.14 | 2
Here is a side-by-side with your picture above.
small.png
Here is a zoomed in version (click on the image).
large.png
There is an extra 1 pixel space between characters in a few instances, and a few characters "touching" other characters (mainly the v and w). This might be corrected with further tweaking, but it is really close. You may also look into different typography settings (assuming the Tahoma font supports them) using the Typography inline setting.
https://docs.rainmeter.net/manual/meters/string/inline/#InlineTypography
https://docs.rainmeter.net/tips/font-features/

-Brian

PS - The AccurateText option mainly adjusts the extra leading/trailing space when calculating the "width" of the rendered text. This is another setting we used to emulate GDI+ rendering.
You do not have the required permissions to view the files attached to this post.
User avatar
arlong_pete
Posts: 4
Joined: March 6th, 2021, 2:17 pm

Re: Wrong character spacing on aliased fonts

Post by arlong_pete »

Thank you very much Brian for the explanation and the time you took to show those adjustments, it's really appreciated! 👍🏻
Knowing what's going on and why makes a difference, at least now I know that's not something on my part.
The sinful crown spinning the hearts of people into real form.