Text sizing protocol: Fix alignment/cropping issues when rendering text with a fractional scale

Also add some clarifications to the docs for exactly how alignment
operates with fractional scaling.

Fixes #9471
Fixes #9537
This commit is contained in:
Kovid Goyal 2026-02-24 08:45:21 +05:30
parent 2eb79c0a3a
commit c03e280128
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 51 additions and 20 deletions

View file

@ -243,6 +243,9 @@ Detailed list of changes
- Wayland: Add support for :code:`titlebar-only` in :opt:`hide_window_decorations`
to hide the titlebar while keeping shadows for window resizing. (:pull:`9486`)
- Text sizing protocol: Fix alignment/cropping issues when rendering text with
a fractional scale (:iss:`9471`)
0.45.0 [2025-12-24]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -77,9 +77,9 @@ There are only a handful of metadata keys, defined in the table below:
"d", "Integer from 0 to 15", "0", "The denominator for the fractional scale. Must be ``> n`` when non-zero."
"v", "Integer from 0 to 2", "0", "The vertical alignment to use for fractionally scaled text. ``0`` - top, ``1`` - bottom, ``2`` - centered"
"v", "Integer from 0 to 2", "0", "The vertical alignment to use for fractionally scaled text (n < d). ``0`` - top, ``1`` - bottom, ``2`` - centered"
"h", "Integer from 0 to 2", "0", "The horizontal alignment to use for fractionally scaled text. ``0`` - left, ``1`` - right, ``2`` - centered"
"h", "Integer from 0 to 2", "0", "The horizontal alignment to use for fractionally scaled text (n < d). ``0`` - left, ``1`` - right, ``2`` - centered"
How it works
@ -160,8 +160,11 @@ The fractional scale **does not** affect the number of cells the text occupies,
instead, it just adjusts the rendered font size within those cells.
The fraction is specified using an integer numerator and denominator (``n`` and
``d``). In addition, by using the ``v`` key one can vertically align the
fractionally scaled text at top, bottom or middle. Similarly, the ``h`` key
does horizontal alignment — left, right or centered.
fractionally scaled render area at top, bottom or middle. Similarly, the ``h`` key
does horizontal alignment — left, right or centered. Note that alignment
here is not actual text alignment, it refers to how the fractionally scaled
render area fits inside the full render area of size ``s * w`` by ``s`` cells.
Thus, alignment only applies when ``n < d``.
When using fractional scaling one often wants to fit more than a single
character per cell. To accommodate that, there is the ``w`` key. This specifies