Forum Feature requests

Please support CSS unit "ch"

Johann
We often generate documentation containing annotated source code listings. Currently it would be helpful if we could define an inline box with exactly, for example, a width of 16 characters.

Could you please support CSS unit "ch", at least for "width" property of (inline) blocks!

The unit seems to be defined here: https://drafts.csswg.org/css-values-3/#ch
It is already supported by browsers Chrome and Firefox.

Thank You

- - -
Johann

mikeday
It's a bit tricky to get the font right for this, but for monospace text perhaps you could use suitably scaled em units in the meantime? (or ex units, which Prince treats as 0.5em).
Johann
Correct, using "16ex" instead of "16ch" was suitable for our (monospace) font.

Silly question from a layman: Can't you simply copy the code for the "ex" unit and take the width of the "0" in place of the height of the "x"?

- - -
Johann

mikeday
Actually Prince does not correctly implement ex units at this time, it just treats them as equivalent to 0.5em without measuring the actual x-height from the font.

The reason for this is that "the font" is not known yet when Prince computes styles, evaluating the font stack is not performed until much later, when text content is seen in the element. Changing this ends up requiring more architectural work, hence the delay.