bug 728518 - improve the handling of weight in FindFontForChar. r=jdaggett
authorJonathan Kew <jfkthame@gmail.com>
Mon, 20 Feb 2012 08:55:07 +0000
changeset 87225 4ad3d672bf460cac00b2c30b9d94b0444a6c43df
parent 87224 3588de29a03f649140ade4a58d84a382f38b0d9a
child 87226 81c166bac966d0b225b78220264cbef5256266c5
push id22103
push userbmo@edmorley.co.uk
push dateTue, 21 Feb 2012 12:01:45 +0000
treeherdermozilla-central@4038ffaa5d82 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett
bugs728518
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 728518 - improve the handling of weight in FindFontForChar. r=jdaggett
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -738,35 +738,26 @@ gfxFontFamily::FindFontForChar(FontSearc
         if (rank == 0)
             continue;
             
         // 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
+
+            // matching italics takes precedence over weight
             bool wantItalic =
                 ((style->style & (FONT_STYLE_ITALIC | FONT_STYLE_OBLIQUE)) != 0);
             if (fe->IsItalic() == wantItalic) {
-                rank += 5;
+                rank += 10;
             }
-            
-            // 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;
-            }
+
+            // measure of closeness of weight to the desired value
+            rank += 9 - abs(fe->Weight() / 100 - style->ComputeWeight());
         } else {
             // if no font to match, prefer non-bold, non-italic fonts
             if (!fe->IsItalic()) {
                 rank += 3;
             }
             if (!fe->IsBold()) {
                 rank += 2;
             }