Repository navigation
PyUI: fit list titles to their room by width, not 35 chars - #1900
Conversation
|
This should not block merging, but just a note to self to explicitly check behavior on the A30 after merge but before a stable release since in the past it has shown some quirks regarding asset size calculation. |
87d4fba to
3b9d61b
Compare
I wonder if glyphmetrics have the same issue |
| # up to a few pixels wider than TTF_SizeUTF8's; use get_text_dimensions where exact | ||
| # widths matter. | ||
| @classmethod | ||
| def get_text_width_from_glyphs(cls, purpose, text): |
There was a problem hiding this comment.
FYI for What @ryanmsartor is mentioning we have this as a helper method in device:
fix_device_font_height_calc_issues()
We will potentially need to use it alongside a width version.
The one being used here get_text_width_measurement_multiplier() functions the same but is set to 1 for each device, might need to set it for a30.
The difference is a multiplier vs passing the value to the device to decide. (I think passing it to the device is better if we end up needing it)
Follow-up to #1871, as discussed. Instead of a 35-char cap, the descriptive list now works out each title's room in pixels (row minus icon column, offsets and the value on the right):
Widths are measured per letter. Each character's advance is cached per font in
Display, and a title's width is just a sum. It ignores kerning, so it comes out 0–4 px wider thanTTF_SizeUTF8, never narrower. That means a cut title never runs into the hours. The same estimate letsis_text_too_longskip measuring strings that are clearly short enough, and value widths are cached per list.The activity tracker was the reason for the cap, and at 480×800 the 35 chars still overlapped the hours there. Now names end right before them at every resolution.
Measured on a Miyoo Mini+ (Spruce Nightly, 640×480, RAOfflineProxy running) with my real activity log (23 games) and Cheevos (20 games):
TTF_SizeUTF8calls per frameTTF_SizeUTF8Render is the median
DescriptiveListView._rendertime. CPU is the share of one core. A new character costs ~0.1–1 ms the first time a font draws it, then it's cached. The caches stay small: about 5 KB per font, and at most ~160 KB for a list scrolled through 1000+ rows.Also tested on desktop at all 8 resolutions in SPRUCE, MINIMAL, Pico-8 and ART_BOOK_NEXT. Settings and the other menus look pixel for pixel the same as on Development. Descriptions (70-char scroll) and values (25-char cap) are untouched.