<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>114618</bug_id>
          
          <creation_ts>2013-04-15 04:36:13 -0700</creation_ts>
          <short_desc>Monospace fonts are not working in QtWebKit 2.3.0</short_desc>
          <delta_ts>2014-03-19 10:33:32 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Qt</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>88186</blocked>
          <everconfirmed>0</everconfirmed>
          <reporter name="Dmitry Shachnev">mitya57</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>allan.jensen</cc>
    
    <cc>anonymous</cc>
    
    <cc>thiago</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>875650</commentid>
    <comment_count>0</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-15 04:36:13 -0700</bug_when>
    <thetext>With QtWebKit 2.3.0, any QtWebKit-based browser displays &quot;font-family: monospace&quot; blocks using non-monospace font. I can reproduce this Ubuntu 13.04, which has this QtWebKit version. User agent version is 537.20.

This didn&apos;t happen with QtWebKit 2.2 and does not happen with Qt 5.

- A screenshot: https://ubuntuone.com/6JmFjyEcqrxkSZ8CDS31N1.
- A minimal test case: https://gist.github.com/mitya57/5312601.

Severity Major because it breaks a lot of web sites and other apps (at least ReText is affected).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>876875</commentid>
    <comment_count>1</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-04-16 14:45:35 -0700</bug_when>
    <thetext>It works fine here. Perhaps you are missing the default monospace font, so it falls back to sans-serif?

Note, that the web-inspector is also rendered using webkit and correctly uses a monospace font.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>876888</commentid>
    <comment_count>2</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-04-16 15:05:41 -0700</bug_when>
    <thetext>The default monospace font can be set by the application, but if your test example is failing it means the default default is not working in your case.

The default fonts in qtwebkit is set using this code:

    QFont defaultFont;
    defaultFont.setStyleHint(QFont::Serif);
    d-&gt;fontFamilies.insert(QWebSettings::StandardFont, defaultFont.defaultFamily());
    d-&gt;fontFamilies.insert(QWebSettings::SerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Fantasy);
    d-&gt;fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Cursive);
    d-&gt;fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::SansSerif);
    d-&gt;fontFamilies.insert(QWebSettings::SansSerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Monospace);
    d-&gt;fontFamilies.insert(QWebSettings::FixedFont, defaultFont.defaultFamily());

Could you test what font you get on your machine with a QFont::setStyleHint(QFont::Monospace) and QFont::defaultFamily() ? 

It sounds like an issue in Qt, fontconfig, or probably their configuration on Ubuntu 13.04.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>877396</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-17 11:24:21 -0700</bug_when>
    <thetext>defaultFamily() of QFont::Monospace is &quot;Courier New&quot;, but that font doesn&apos;t exist in the system, so probably this is the issue.

But, for some reason, monospace font works in Web Inspector and other widgets. In example, this works OK (and the font is really monospace):

QFont font;
QTextEdit edit;
font.setFamily (&quot;monospace&quot;);
edit.setFont (font);

I tested this on Kubuntu 13.04 live image, will test on my home PC tomorrow.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>877405</commentid>
    <comment_count>4</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-17 11:36:49 -0700</bug_when>
    <thetext>Oh, I just found this in qfont_x11.cpp:

QString QFont::defaultFamily() const
{
...
    case QFont::Monospace:
        return QString::fromLatin1(&quot;Courier New&quot;);
...
}

If (for some reasons) Qt doesn&apos;t use font from system settings, maybe it&apos;ll make sense to use &quot;monospace&quot; instead of &quot;Courier New&quot;, that works in GNOME, KDE and Windows (at least).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>877762</commentid>
    <comment_count>5</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-04-18 02:35:00 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Oh, I just found this in qfont_x11.cpp:
&gt; 
&gt; QString QFont::defaultFamily() const
&gt; {
&gt; ...
&gt;     case QFont::Monospace:
&gt;         return QString::fromLatin1(&quot;Courier New&quot;);
&gt; ...
&gt; }
&gt; 
&gt; If (for some reasons) Qt doesn&apos;t use font from system settings, maybe it&apos;ll make sense to use &quot;monospace&quot; instead of &quot;Courier New&quot;, that works in GNOME, KDE and Windows (at least).

Yes. Is that the same in the official Qt 4.8 release? If so, I would suggest opening a bug report on it at qt-project.org</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>877936</commentid>
    <comment_count>6</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-18 09:25:57 -0700</bug_when>
    <thetext>Probably this should fix the issue:

--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -285,6 +285,7 @@ static const char *getFcFamilyForStyleHint(const QFont::StyleHint style)
         stylehint = &quot;serif&quot;;
         break;
     case QFont::TypeWriter:
+    case QFont::Monospace:
         stylehint = &quot;monospace&quot;;
         break;
     default:

Not tested yet, will test and submit to codereview later.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>878744</commentid>
    <comment_count>7</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-20 02:50:47 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; Probably this should fix the issue:

No, it didn’t help :(

I have now reported https://bugreports.qt-project.org/browse/QTBUG-30785.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>879132</commentid>
    <comment_count>8</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-22 07:37:58 -0700</bug_when>
    <thetext>After some debugging, I would say that this is *not* a Qt issue. Though there is no “Courier New” font in my system, FontConfig considers it as an alias for “Liberation Mono” font, using the rule defined in /etc/fonts/conf.d/30-metric-aliases.conf.

If I create a QFont with family “Courier New” and apply it to a widget (i.e. QTextEdit), it will work properly. Even more, if I create an HTML block with “font-family: &apos;Courier New&apos;” style, QtWebKit *will render it properly*.

So, I believe it is a bug in QtWebKit. To be precise, QtWebKit is able to render that font properly (as we can see in the web inspector), but doesn’t do that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>879840</commentid>
    <comment_count>9</comment_count>
    <who name="Dmitry Shachnev">mitya57</who>
    <bug_when>2013-04-23 07:46:49 -0700</bug_when>
    <thetext>Sorry for the noise, I’m going to correct an error in my previous comment:

&gt; Even more, if I create an HTML block with “font-family: &apos;Courier New&apos;” style, QtWebKit *will render it properly*.

That’s not true. QTextEdit will render it, but QtWebKit won’t (which again indicates that it is a bug in QtWebKit).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>982917</commentid>
    <comment_count>10</comment_count>
    <who name="Thiago Macieira">thiago</who>
    <bug_when>2014-02-20 11:41:54 -0800</bug_when>
    <thetext>Allan, do you have any further ideas? I can confirm this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>992164</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2014-03-19 10:33:32 -0700</bug_when>
    <thetext>Marking INVALID, as Qt port no longer exists in WebKit trunk.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>