bug 594078 - fix handling of regular vs italic during font fallback search. r=jdaggett a=benjamin
authorJonathan Kew <jfkthame@gmail.com>
Thu, 25 Nov 2010 15:36:49 +0000
changeset 58220 8545045acca27b494f7eb353a8270a31d6e5092c
parent 58219 215657c24079bbb00b4008d88d761369abdfc5d6
child 58221 eb8d110a117aa494b073edeb50ba7383cfb218c9
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersjdaggett, benjamin
bugs594078
milestone2.0b8pre
bug 594078 - fix handling of regular vs italic during font fallback search. r=jdaggett a=benjamin
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -577,36 +577,41 @@ gfxFontFamily::FindFontForChar(FontSearc
             
         // omitting from original windows code -- family name, lang group, pitch
         // not available in current FontEntry implementation
 
         if (aMatchData->mFontToMatch) { 
             const gfxFontStyle *style = aMatchData->mFontToMatch->GetStyle();
             
             // italics
-            if (fe->IsItalic() && 
-                    (style->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0) {
+            PRBool wantItalic =
+                ((style->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0);
+            if (fe->IsItalic() == wantItalic) {
                 rank += 5;
             }
             
             // weight
             PRInt32 targetWeight = style->ComputeWeight() * 100;
 
             PRInt32 entryWeight = fe->Weight();
             if (entryWeight == targetWeight) {
                 rank += 5;
             } else {
                 PRUint32 diffWeight = abs(entryWeight - targetWeight);
                 if (diffWeight <= 100)  // favor faces close in weight
                     rank += 2;
             }
         } else {
             // if no font to match, prefer non-bold, non-italic fonts
-            if (!fe->IsItalic() && !fe->IsBold())
-                rank += 5;
+            if (!fe->IsItalic()) {
+                rank += 3;
+            }
+            if (!fe->IsBold()) {
+                rank += 2;
+            }
         }
         
         // xxx - add whether AAT font with morphing info for specific lang groups
         
         if (rank > aMatchData->mMatchRank
             || (rank == aMatchData->mMatchRank &&
                 Compare(fe->Name(), aMatchData->mBestMatch->Name()) > 0)) 
         {