*I just wanted to directly respond to this message (sorry to keep hi-jacking)*
SilverAzide wrote: ↑
October 15th, 2019, 10:36 pm
I don't mean to hijack this thread, but this is a great example of a feature request I made quite a long time ago here: https://forum.rainmeter.net/viewtopic.php?f=14&t=26338
. In short, it is annoying (to me) to have the string "Cloudy" scrolling when it isn't needed (as in the above GIF) since there is plenty of room to display the full text. If we had a convenient way to measure text length (via Win32 GetTextExtentPoint32, IDWriteTextLayout::GetMetrics, et al.), then if the weather was "Cloudy" we would know there is plenty of room to display the text without scrolling, but if it was "Thunder in the Vicinity", then we could activate the measures needed to scroll.
Please accept my apologies, xenium! Keep up the good work!
I have actually wanted to do this as well for several years now, but haven't found the time yet. In fact it was one of the reasons I added the String Measure
, and I hoped to find a way to add some basic functions to that measure (like the ability to select a substring, string length in characters, pixel length of string from its displayed text metrics, and others). Some of that can be done with Lua or Regex, so I think we moved onto other more high profile features.
It might be good to revisit this.
One of the major issues I will have to think about is dealing with how directwrite creates the underlying text layout so it can get the text metrics. It is an expensive operation, so creating a layout, getting its metrics, then destroying it, is fairly large waste of resources. If we bind it to the String meter somehow, it might be easier on resources and allow the use of the inline string metrics to be calculated correctly. Maybe we could do section variable(s) such as: [StringMeter:TextMetricsWidth]
. Or maybe some hybrid function call like this: [StringMeter:TextMetrics(Width)]
or something similar.
We would also have to think about multi-line text, whitespace, whether to measure clipped text or not (or both), etc.
I think I just turned this into a large project.
Anyway, I just wanted to let you know we thought about this, but have struggled to "place" it somewhere and deal with all the complexities and performance issued involved. Nothing is in the works
yet, and we would need to carefully think through all the details beforehand. Thanks for the reminder!