diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-07-16 13:44:19 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-10 19:43:02 +0200 |
commit | 33f9591e378a2162378d8be5e75a47adf034536b (patch) | |
tree | b3e93e71dd609d213155ddaf333ec912673581d3 /src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | |
parent | 1a8de144b64fe665d3c0b34e329c9454d97e1523 (diff) |
Implement missing support for 'em' and 'ex' lengths in style sheet
The Qt style sheet reference claimed that Length properties can be
specified in 'em' or 'ex' units, but that was never implemented.
Add the missing implementation. Since the sizes depend on the size of
the font of the current element, we cannot convert the units in the CSS
parser, but have to do so in the QRenderRule constructor, where we can
make a decision about which font to use if the style sheet itself doesn't
specify a font. Fall back to the widget font if possible; otherwise it
will be the application default font.
The implementation translates em into QFontMetrics.height, identical to
what is already done in the QCssParser. This is in line with the CSS
specification, but contradicts our previous documentation which stated
that 'em' means "width of M". Fix the documentation.
Fixes: QTBUG-8096
Pick-to: 6.2
Change-Id: I145e2504ae3b19101a0d0dd63653466b6c2cec1d
Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc')
-rw-r--r-- | src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index f4edfb92dc..44f20ca0ae 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -3027,7 +3027,8 @@ \list \li \c px: pixels \li \c pt: the size of one point (i.e., 1/72 of an inch) - \li \c em: the em width of the font (i.e., the width of 'M') + \li \c em: the size relative to the font size of the element + (e.g., 2em means 2 times the size of the font) \li \c ex: the x-height of the font (i.e., the height of 'x') \endlist |