Bug 26120 - [Cairo] Honor Desired Weight and Italic State for Fonts in Windows Cairo Build
Summary: [Cairo] Honor Desired Weight and Italic State for Fonts in Windows Cairo Build
Status: RESOLVED DUPLICATE of bug 21492
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-01 11:47 PDT by Brent Fulgham
Modified: 2009-07-20 15:04 PDT (History)
3 users (show)

See Also:


Attachments
Honor weight/italic in HFONT structure (3.18 KB, patch)
2009-06-01 11:56 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2009-06-01 11:47:12 PDT
The attached patch from Joonghoon Kim modifes FontCacheWin.cpp so that the HFONT is created with the desired weight and italic state.

The "matchImprovingEnumProc" method is also modified to take weight and italic state into account.
Comment 1 Brent Fulgham 2009-06-01 11:56:10 PDT
Created attachment 30837 [details]
Honor weight/italic in HFONT structure

Proposed change from Joonghoon Kim to handle font weight and italic state under the Cairo build of Windows.
Comment 2 Brent Fulgham 2009-06-01 11:57:47 PDT
The patch seems valid, but I think Dave Hyatt should review and comment on this.

I'm not sure if the changes to matchImprovingEnumProc are valid/desirable.  I'm also not sure why the standard CG font handling doesn'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.
Comment 3 Eric Seidel (no email) 2009-06-18 17:42:32 PDT
Hyatt is really your man here.
Comment 4 Dave Hyatt 2009-06-19 00:56:06 PDT
Comment on attachment 30837 [details]
Honor weight/italic in HFONT structure

Hard for me to plus this one without being sure about what it's changing.  Can this maybe be elaborated upon?
Comment 5 Brent Fulgham 2009-06-19 10:10:07 PDT
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:
> In the CG port, we need the LOGFONT and resulting HFONT to correspond to an actual font,
> not a synthesized one, so that we can apply synthetic oblique and synthetic boldface in the
> 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.
Comment 6 mitz 2009-06-19 10:15:51 PDT
(In reply to comment #5)
> 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.

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.
Comment 7 Joonghoon Kim 2009-06-21 03:59:06 PDT
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't need to improve anything other than italic & weight, it can
be stopped when it's proposed same weight & 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 '!' operators comparing lfitalic fields, 
but it is my mistake. The original code implies much more complex 
(and hard to understand) logic. 

I think it's better to keep current matchImprovingEnumProc() if there'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' during font rendering. Cairo looks to be able
to handle synthetic bold rendering by itself.  
Comment 8 Joonghoon Kim 2009-06-21 04:30:15 PDT
r44268 from Bug 21492 corrected the problem of Korean bold font rendering. 
Since most of Korean fonts (bundled with MS Windows) don'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't need to improve anything other than italic & weight, it can
be stopped when it's proposed same weight & 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 '!' operators comparing lfitalic fields, 
but it is my mistake. The original code implies much more complex 
(and hard to understand) logic. 

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

But, about the other changes to creatGDIFont(), 
I'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't know yet? 

Anyway, This issue can be closed. Thank you.  
Comment 9 Brent Fulgham 2009-07-16 09:07:58 PDT
Per original reporters request, closing this issue as resolved by Bug 21492.

*** This bug has been marked as a duplicate of bug 21492 ***
Comment 10 Eric Seidel (no email) 2009-07-20 15:04:34 PDT
Comment on attachment 30837 [details]
Honor weight/italic in HFONT structure

Since this is marked fix, clearing review flag.