Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75865

Style Sheets. Font size "em" support

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 5.12.2
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      All

      Description

      Qt currently supports only 'px' and 'pt' values for font-size Style Sheets parameter.
      This is very inconvenient for application development, when app should look similar in multiple environments with different screen resolutions, different pixel sizes of system font and different px/pt ratio.

      Please find below code proposal to add this support in qcssparser.cpp, setFontSizeFromValue() func, at line 1128:

      else if (s.endsWith(QLatin1String("em"), Qt::CaseInsensitive)) {
          s.chop(2);
          value.variant = s;
          if (value.variant.convert((QVariant::Type)qMetaTypeId<qreal>())) { 
              font->setPixelSize(qRound(QFontMetrics(QFont()).height() * value.variant.toReal()));
              valid = true; 
          } 
      }
      

       
      Proposed approach is similar to what already used in CSS parser in lengthValueFromData function.

      Am I miss why 'em' is still not supported for font size in Qt?

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            esabraha Eskil Abrahamsen Blomfeldt
            Reporter:
            viktor.kolesnyk Viktor Kolesnyk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes