It is currently April 19th, 2024, 7:44 am

[Suggestion] Word Spacing To Achieve Straight Column Edges On Each Side

Report bugs with the Rainmeter application and suggest features.
nesherman
Posts: 18
Joined: June 17th, 2020, 4:00 am

Re: [Suggestion] Word Spacing To Achieve Straight Column Edges On Each Side

Post by nesherman »

Brian wrote: May 1st, 2022, 6:19 am I think something can be done in this area. Maybe.

Here is a simple test:
Justified.png


There are 2 potential "issues", if you want to call them that.

FIrst, D2D seems to increase the spacing between characters within the same word in some cases instead of just the spacing between words. It isn't too bad, but there doesn't seem to be a way to just use the "normal" space between characters in the same word like you would think.

Second, it's difficult to calculate the correct width of the meter when no W is defined - so a width needs to be defined to make this work.

I'll look into these issues and hopefully come up with a solution.

-Brian
This looks really great, Brian. I'll echo all of @Yincognito's first couple of points. I have no idea how you have figured this out so far but I'm definitely here for it. Great work!
nesherman
Posts: 18
Joined: June 17th, 2020, 4:00 am

Re: [Suggestion] Word Spacing To Achieve Straight Column Edges On Each Side

Post by nesherman »

Brian wrote: May 1st, 2022, 6:19 am I think something can be done in this area. Maybe.

Here is a simple test:
Justified.png


There are 2 potential "issues", if you want to call them that.

FIrst, D2D seems to increase the spacing between characters within the same word in some cases instead of just the spacing between words. It isn't too bad, but there doesn't seem to be a way to just use the "normal" space between characters in the same word like you would think.

Second, it's difficult to calculate the correct width of the meter when no W is defined - so a width needs to be defined to make this work.

I'll look into these issues and hopefully come up with a solution.

-Brian
Hey Brian! Just wondering if you ever made any further progress with this. It looked great!
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: [Suggestion] Word Spacing To Achieve Straight Column Edges On Each Side

Post by Brian »

nesherman wrote: November 10th, 2022, 2:14 pm Hey Brian! Just wondering if you ever made any further progress with this. It looked great!
I did make progress on this and had it all ready to go, however, a unresolvable issue came up. The specific issue is a little hard to describe, but it basically has to do with multiline text.

If the text has no line endings, the text will show as you would expect with the appropriate extra space between characters and word clusters.
Example:

Code: Select all

Text=Something too short for the width.
W=500
It would look something like this:

Code: Select all

S o m e t h i n g   t o o   s h o r t   f o r   t h e   w i d t h.
If the text has line endings, and all the "text clusters between each line ending" wraps to the next line, everything is shown as you would expect with the appropriate extra space bewtween characters and word clusters - even on the "wrapped" portion of the "text cluster".
Example:

Code: Select all

Text=Something too long for the width.#CRLF##CRLF#Another sentence too long for the width.
W=100
It would look something like this:

Code: Select all

S o m e t h i n g  t o o  l o n g
f o r    t h e    w i d t h .

A n o t h e r     s e n t e n c e
t o o   l o n g   f o r   t h e
w i d t h.
If the text has line endings and if any of the "text clusters between line endings" DO NOT wrap, they will not get the justified alignment. It looks okay if the "short text" is on the last line, but it looks weird everywhere else.
Example:

Code: Select all

Text=Something short.#CRLF##CRLF#Another sentence too long for the width.
W=100
It would look something like this:

Code: Select all

Something short.

A n o t h e r     s e n t e n c e
t o o   l o n g   f o r   t h e
w i d t h.
Sorry for the lack of proper examples, but hopefully that gives enough of a "visual" aide to show the issue.


I am not sure there is anything that can be done to fix it, but if something "new" comes up, I will definitely look into it.

-Brian
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [Suggestion] Word Spacing To Achieve Straight Column Edges On Each Side

Post by Yincognito »

Brian wrote: November 11th, 2022, 8:13 pm I did make progress on this and had it all ready to go, however, a unresolvable issue came up. The specific issue is a little hard to describe, but it basically has to do with multiline text.

If the text has line endings and if any of the "text clusters between line endings" DO NOT wrap, they will not get the justified alignment. It looks okay if the "short text" is on the last line, but it looks weird everywhere else.
Example:

Code: Select all

Text=Something short.#CRLF##CRLF#Another sentence too long for the width.
W=100
It would look something like this:

Code: Select all

Something short.

A n o t h e r     s e n t e n c e
t o o   l o n g   f o r   t h e
w i d t h.
I am not sure there is anything that can be done to fix it, but if something "new" comes up, I will definitely look into it.
So basically, the issue is that the "text cluster" is left aligned (instead of justified) if the line ending (aka the #CRLF#) location occurs before the wrapping one, right? Some ideas which might or might not work or be optimal would be to strip the text of line endings initially and add them after the character placement is established (I have no idea if this is doable, just saying), or using / designing some kind of plugin similar to InputText based on justifying capable text boxes or even WebView2 technology. The latter, while possible, unfortunately adds more dependencies to Rainmeter (like the specific runtime redistributable, writing in HTML and such) and I imagine that not being desirable.

Anyway, I might be wrong here, but isn't the behavior you mentioned "normal" in these cases? Consider this test environment on W3Schools (I chose this cause it's easy to experiment with, not necessarily because of the possible connection with the WebView2 environment) and the following HTML code on the left side of the window:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<style>
div {
  text-align: justify;
  text-justify: inter-word;
}
</style>
</head>
<body>

<h1>The text-justify Property</h1>

<div>Something short.<br><br>Another sentence too long for the width.</div>

<p><b>Tip:</b> Resize the browser window to see how the value "justify" works.</p>

</body>
</html>
The result, if one places the dragbar between the code and result "windows" properly, is something like this:
Justified Web Text.jpg
Now of course, justification implementations might differ between environments (e.g. MS Word vs browser, etc.), but isn't the result quite similar to what you just described? I mean, if the "line" is too short, it gets left aligned, and only if the line is long enough (and usually wrapped) the text gets justified (i.e. "distributed" or "spread" to cover entire lines having the same "margins").
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth