forked from mirrors/gecko-dev
This is somewhat arbitrary, as the behavior of the 'size' attribute is not clearly specified for non-fixed-width fonts where "character width" is a vague concept. So there's no absolute "right" or "wrong" result, but there are cases where our current behavior feels quite wrong to authors. There are two adjustments here that aim to make the behavior more consistent and predictable. First, rather than using the font's "average" char width (which is itself not a clearly- defined or reliably-set metric) as the basic multiplier for the 'size' attribute, prefer to use the width of the zero glyph (0), if present. This makes size-attribute-based input fields behave more consistently with fields sized using the CSS 'ch' unit, rather than having apparently-random inconsistencies between the two. Second, the existing code adds a "padding" factor based on the font's maxAdvance, but this can be quite excessive with modern fonts, where there may be outliers such as logo glyphs or long ligatures that are much wider than typical characters. E.g. the macOS system font has a triple-em-dash ligature; or the Ubuntu font, which declares an advanceWidthMax of 3511 units, although the widest glyph I can find is the "ffl" ligature with a width of 1053 units. To limit the effect that such outliers (or incorrect metadata) can have, I'm proposing to clamp the "max" width that we use here to twice the "char width" derived from the zero glyph or the font's declared average. So we're still doing the "IE-like" addition of some extra width when using non-fixed-space fonts, but it won't become as huge as it currently does in some cases (depending on font details). Differential Revision: https://phabricator.services.mozilla.com/D176922 |
||
|---|---|---|
| .. | ||
| 2d | ||
| angle | ||
| cairo | ||
| config | ||
| docs | ||
| gl | ||
| graphite2 | ||
| harfbuzz | ||
| ipc | ||
| layers | ||
| ots | ||
| qcms | ||
| skia | ||
| src | ||
| tests | ||
| thebes | ||
| vr | ||
| webrender_bindings | ||
| wgpu_bindings | ||
| wr | ||
| ycbcr | ||
| metrics.yaml | ||
| moz.build | ||