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

Richtext's CSSParser does not accept Fonts with extra spaces in name.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 4.6.0
    • 4.5.2
    • Widgets: Style Sheets
    • None
    • 8d01f436451071a917c147a96a979ccdaee106f9

    Description

      Some fonts have extra spaces in thier names dividing the family from the font name, for example "VIC MODERN CURSIVE". Web pages that name this font in css are parsed correctly, but Qt's rich text support does not.

      The following patch fixes this behavior :

      — a/src/gui/text/qcssparser.cpp
      +++ b/src/gui/text/qcssparser.cpp
      @@ -1181,7 +1181,9 @@ static bool setFontFamilyFromValues(const QVector<Value> &
      family += str;
      family += QLatin1Char(' ');
      }

      • family = family.simplified();
        + // family = family.simplified();
        if (family.isEmpty())
        return false;
        font->setFamily(family);

      Here is a sample html file, it loads fine in broswers, but needs the above patch to load ok in richtext:

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
      <html>
      <head>
      <meta name="qrichtext" content="1"/>
      </head>
      <body style=" font-family:'Arial'; font-size:20pt; font-weight:400; font-style:normal;">
      <table border="0" style= "-qt-table-type: root; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;">
      <tr>
      <td style="border: none;">
      <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; color:#000000;">
      <span style=" font-family:'VIC MODERN CURSIVE';">hello MODERN world<br/></span>
      <span style=" font-family:'Times New Roman Bold';">hello Roman world<br/></span>
      <span >hello rest of the world<br/></span>
      </p>
      </td>
      </tr>
      </table>
      </body>
      </html>

      Attachments

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

        Activity

          People

            goffart Olivier Goffart (closed Nokia identity) (Inactive)
            dettman Dean Dettman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes