<?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>26120</bug_id>
          
          <creation_ts>2009-06-01 11:47:12 -0700</creation_ts>
          <short_desc>[Cairo] Honor Desired Weight and Italic State for Fonts in Windows Cairo Build</short_desc>
          <delta_ts>2009-07-20 15:04:34 -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 Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>21492</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Brent Fulgham">bfulgham</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>hyatt</cc>
    
    <cc>lunaris</cc>
    
    <cc>mitz</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>123859</commentid>
    <comment_count>0</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-06-01 11:47:12 -0700</bug_when>
    <thetext>The attached patch from Joonghoon Kim modifes FontCacheWin.cpp so that the HFONT is created with the desired weight and italic state.

The &quot;matchImprovingEnumProc&quot; method is also modified to take weight and italic state into account.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123862</commentid>
    <comment_count>1</comment_count>
      <attachid>30837</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-06-01 11:56:10 -0700</bug_when>
    <thetext>Created attachment 30837
Honor weight/italic in HFONT structure

Proposed change from Joonghoon Kim to handle font weight and italic state under the Cairo build of Windows.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123863</commentid>
    <comment_count>2</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-06-01 11:57:47 -0700</bug_when>
    <thetext>The patch seems valid, but I think Dave Hyatt should review and comment on this.

I&apos;m not sure if the changes to matchImprovingEnumProc are valid/desirable.  I&apos;m also not sure why the standard CG font handling doesn&apos;t make use of the weight and italic members of the HFONT structure.  It seems like this should not have to be conditionalized for PLATFORM(CAIRO) at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126835</commentid>
    <comment_count>3</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-06-18 17:42:32 -0700</bug_when>
    <thetext>Hyatt is really your man here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126909</commentid>
    <comment_count>4</comment_count>
      <attachid>30837</attachid>
    <who name="Dave Hyatt">hyatt</who>
    <bug_when>2009-06-19 00:56:06 -0700</bug_when>
    <thetext>Comment on attachment 30837
Honor weight/italic in HFONT structure

Hard for me to plus this one without being sure about what it&apos;s changing.  Can this maybe be elaborated upon?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126954</commentid>
    <comment_count>5</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-06-19 10:10:07 -0700</bug_when>
    <thetext>The changes in this bug were proposed by a team using WebKit on some kind of mobile computing device.  They apparently ran into problems with bold and italic fonts (Korean fonts IIRC) not displaying properly.  They found that the following change (around line 440) provided proper font display:

#if PLATFORM(CAIRO)
     matchData.m_chosen.lfWeight = desiredWeight;
     matchData.m_chosen.lfItalic = desiredItalic;
#endif 

The underlying problem may be completely resolved by Bug 21492, which is already in the tree.

Mitz separately wrote me:
&gt; In the CG port, we need the LOGFONT and resulting HFONT to correspond to an actual font,
&gt; not a synthesized one, so that we can apply synthetic oblique and synthetic boldface in the
&gt; engine when rendering with CG (see createFontPlatformData()).

The original reporter indicated that the changes to the matchImprovingEnumProc were done to help get exact matching once they added the BOLD/ITALIC state to the HFONT, since otherwise it iterates over every font structure proposed by GDI.

I see two possible states for this issue:
(1) If the fix in Bug 21492 provides correct rendering, then this issue is unneeded and we can close it out.
(2) If Bug 21492 did NOT correct the problem, then we probably want to make sure that the HFONT settings are included with the guards, so the bold/italic state is properly synthesized in the CG implementation.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126955</commentid>
    <comment_count>6</comment_count>
    <who name="">mitz</who>
    <bug_when>2009-06-19 10:15:51 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; The original reporter indicated that the changes to the matchImprovingEnumProc
&gt; were done to help get exact matching once they added the BOLD/ITALIC state to
&gt; the HFONT, since otherwise it iterates over every font structure proposed by
&gt; GDI.

That’s the part of the change that I didn’t understand. While it’s true that the current code iterates over all candidates, it still prefers the closest match, including an exact match if there is one. The change looks like it may be an optimization attempt (stop iterating if the best match is an exact match), but I am not sure it’s warranted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127211</commentid>
    <comment_count>7</comment_count>
    <who name="Joonghoon Kim">lunaris</who>
    <bug_when>2009-06-21 03:59:06 -0700</bug_when>
    <thetext>r44268 from Bug 21492 corrected the problem of Korean bold font rendering. 
Thank you. 

The changes to the matchImprovingEnumProc() is just a little optimization. 

Currently, matchImprovingEnumProc enumerates all fonts proposed by GDI.
If it don&apos;t need to improve anything other than italic &amp; weight, it can
be stopped when it&apos;s proposed same weight &amp; italic by GDI. 

Sorry for the bugs in the changes. First if block need to be modified 
to return 1 when firstMatch is true to keep original logic. 
(candidate is always chosen in first match) And, in second if block, 
the change removes all &apos;!&apos; operators comparing lfitalic fields, 
but it is my mistake. The original code implies much more complex 
(and hard to understand) logic. 

I think it&apos;s better to keep current matchImprovingEnumProc() if there&apos;s
no clear evidence it slows down font creation. 

But, about the other changes to creatGDIFont(), I still wonder why we
have to embolden manually&apos; during font rendering. Cairo looks to be able
to handle synthetic bold rendering by itself.  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127212</commentid>
    <comment_count>8</comment_count>
    <who name="Joonghoon Kim">lunaris</who>
    <bug_when>2009-06-21 04:30:15 -0700</bug_when>
    <thetext>r44268 from Bug 21492 corrected the problem of Korean bold font rendering. 
Since most of Korean fonts (bundled with MS Windows) don&apos;t have bold data,   
they should be rendered as synthetic-bold. 

The changes to the matchImprovingEnumProc() is just a little optimization. 

Currently, matchImprovingEnumProc enumerates all fonts proposed by GDI.
If it don&apos;t need to improve anything other than italic &amp; weight, it can
be stopped when it&apos;s proposed same weight &amp; italic by GDI. 

Sorry for the bugs in the changes. First if block need to be modified 
to return 1 when firstMatch is true to keep original logic. 
(candidate is always chosen in first match) And, in second if block, 
the change removes all &apos;!&apos; operators comparing lfitalic fields, 
but it is my mistake. The original code implies much more complex 
(and hard to understand) logic. 

I think it&apos;s better to keep current matchImprovingEnumProc() if there&apos;s
no clear evidence it slows down font creation. 

But, about the other changes to creatGDIFont(), 
I&apos;m still wonder why we have to embolden fonts manually. 
I changed the createGDIFont() before r44268 landed, and saw it works. 
That means cairo can draw synthtic-bold fonts by itself. 
Is there any reason that I don&apos;t know yet? 

Anyway, This issue can be closed. Thank you.  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>132272</commentid>
    <comment_count>9</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-07-16 09:07:58 -0700</bug_when>
    <thetext>Per original reporters request, closing this issue as resolved by Bug 21492.

*** This bug has been marked as a duplicate of bug 21492 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>133246</commentid>
    <comment_count>10</comment_count>
      <attachid>30837</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-07-20 15:04:34 -0700</bug_when>
    <thetext>Comment on attachment 30837
Honor weight/italic in HFONT structure

Since this is marked fix, clearing review flag.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>30837</attachid>
            <date>2009-06-01 11:56:10 -0700</date>
            <delta_ts>2009-07-20 15:04:34 -0700</delta_ts>
            <desc>Honor weight/italic in HFONT structure</desc>
            <filename>font_cache_cairo.patch</filename>
            <type>text/plain</type>
            <size>3261</size>
            <attacher name="Brent Fulgham">bfulgham</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYkNvcmUvQ2hhbmdlTG9n
CShyZXZpc2lvbiA0NDMyNSkKKysrIFdlYkNvcmUvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBA
IC0xLDMgKzEsMTYgQEAKKzIwMDktMDYtMDEgIEpvb25naG9vbiBLaW0gPGx1bmFyaXNAdG1heC5j
by5rcj4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBC
dWcgMjYxMjA6IEhvbm9yIGRlc2lyZWQgd2VpZ2h0IGFuZCBpdGFsaWMgc3RhdGUgZm9yIEZvbnRz
CisgICAgICAgIGluIFdpbmRvd3MgQ2Fpcm8gYnVpbGQuCisgICAgICAgIGh0dHBzOi8vYnVncy53
ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0yNjEyMC4KKworICAgICAgICAqIHBsYXRmb3JtL2dy
YXBoaWNzL3dpbi9Gb250Q2FjaGVXaW4uY3BwOiBCdWlsZCBIRk9OVCBzdHJ1Y3R1cmUKKyAgICAg
ICAgICB3aXRoIHdlaWdodCBhbmQgaXRhbGljIHN0YXRlIHNwZWNpZmllZC4gIEV4dGVuZCBsb2dp
YyBpbiB0aGUKKyAgICAgICAgICBtYXRjaEltcHJvdmluZ0VudW1Qcm9jIHRvIHRha2Ugd2V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