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

toHtml() ignores <font size="x"> if outer element specified a size in points

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4: Low P4: Low
    • None
    • 4.7.4
    • GUI: Text handling
    • None

      This code:
      QString str = "<div style=\"font-size: 16pt;\">large<font size=\"2\">small</font>large again</div>";
      QTextDocument doc;
      doc.setHtml(str);
      QString result = doc.toHtml();
      leaves 'result' with this:
      ...
      <span style=" font-size:16pt;">large</span>
      <span style=" font-size:16pt;">small</span>
      <span style=" font-size:16pt;">large again</span>
      ...
      Which is wrong, since the middle span should have "font-size: small" instead of "font-size; 16pt;". During toHtml(), the QTextCharFormat object that holds the format for that span has both the QTextFormat::FontPointSize property set and the QTextFormat::FontSizeAdjustment property set, when I think it should only have the latter. As a result, the toHtml() call makes its way to QTextHtmlExporter::emitCharFormatStyle(), finds the FontPointSize property, and writes this out while incorrectly ignoring the FontSizeAdjustment property.

        1. test.cpp
          0.7 kB
          Kevin Puetz
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Unassigned Unassigned
            dustinksmith Dustin Smith
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes