Utilize measureText to determine title length.#159
Utilize measureText to determine title length.#159AustinMroz wants to merge 1 commit intoComfy-Org:masterfrom
Conversation
While measureText is used frequently throughout LiteGraph, computeSize calls did not make use of it. As a result, the node size calculations are consistently incorrect for long titles, short titles, or titles that utilize characters of abnormal width such as emojis. My assumption is that this was purely because a context with the required title font isn't available when the call is made, but it's easy to add one just for ensuring the accuracy of text sizing.
|
Given LiteGraph's age, there's a good chance measureText was intentionally avoided for performance reasons, and non-uniformly patched in later. Probably no impact on modern hardware, though? |
|
I did some quick profiling since it was an underlying conern of mine as well and am seeing a time cost of ~4μs per call. Even when performing an action that makes frequent calls to compute size (like resizing a node) the impact seems negligable (<.1% time utilization). I'm not sure of an easy way to check if the memory utilization, though. |
|
Even less than I was expecting. Memory would be negligible, if even measurable. |
|
Please fix the test failures. Thanks! Some how the |
|
Replaced by #962 |
While measureText is used frequently throughout LiteGraph, computeSize calls did not make use of it. As a result, the node size calculations are consistently incorrect for long titles, short titles, or titles that utilize characters of abnormal width such as emojis.
My assumption is that this was purely because a context with the required title font isn't available when the call is made, but it's easy to add one just for ensuring the accuracy of title text sizing.