b=480098 correct weight units in gfxFcFontEntry::AdjustPatternToCSS r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 11 Mar 2009 15:00:43 +1300
changeset 26030 b34586dde1b5f9ee3ee92c138f684bf15448c4b3
parent 26029 ed4bd19dca3e2d42fb2b656d6cfecfc2d52508c6
child 26031 cf256da7436b79b444076cbfec4213a31f53dbfc
push id5857
push userktomlinson@mozilla.com
push dateWed, 11 Mar 2009 02:03:30 +0000
treeherdermozilla-central@b34586dde1b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs480098
milestone1.9.2a1pre
b=480098 correct weight units in gfxFcFontEntry::AdjustPatternToCSS r=roc
gfx/thebes/src/gfxFontconfigUtils.cpp
gfx/thebes/src/gfxFontconfigUtils.h
gfx/thebes/src/gfxPangoFonts.cpp
layout/reftests/font-face/reftest.list
--- a/gfx/thebes/src/gfxFontconfigUtils.cpp
+++ b/gfx/thebes/src/gfxFontconfigUtils.cpp
@@ -144,16 +144,19 @@ gfxFontconfigUtils::GetThebesWeight(FcPa
 
     // including FC_WEIGHT_EXTRABLACK
     return 901;
 }
 
 /* static */ int
 gfxFontconfigUtils::FcWeightForBaseWeight(PRInt8 aBaseWeight)
 {
+    NS_PRECONDITION(aBaseWeight >= 0 && aBaseWeight <= 10,
+                    "base weight out of range");
+
     switch (aBaseWeight) {
         case 2:
             return FC_WEIGHT_EXTRALIGHT;
         case 3:
             return FC_WEIGHT_LIGHT;
         case 4:
             return FC_WEIGHT_REGULAR;
         case 5:
--- a/gfx/thebes/src/gfxFontconfigUtils.h
+++ b/gfx/thebes/src/gfxFontconfigUtils.h
@@ -145,17 +145,18 @@ public:
         return reinterpret_cast<const char*>(aChar8Ptr);
     }
 
     static PRUint8 FcSlantToThebesStyle(int aFcSlant);
     static PRUint8 GetThebesStyle(FcPattern *aPattern); // slant
     static PRUint16 GetThebesWeight(FcPattern *aPattern);
 
     static int GetFcSlant(const gfxFontStyle& aFontStyle);
-    // Returns a precise FC_WEIGHT from CSS weight |aBaseWeight|.
+    // Returns a precise FC_WEIGHT from |aBaseWeight|,
+    // which is a CSS absolute weight / 100.
     static int FcWeightForBaseWeight(PRInt8 aBaseWeight);
 
     static PRBool GetFullnameFromFamilyAndStyle(FcPattern *aFont,
                                                 nsACString *aFullname);
 
     // This doesn't consider which faces exist, and so initializes the pattern
     // using a guessed weight, and doesn't consider sizeAdjust.
     static nsReturnRef<FcPattern>
--- a/gfx/thebes/src/gfxPangoFonts.cpp
+++ b/gfx/thebes/src/gfxPangoFonts.cpp
@@ -204,17 +204,17 @@ protected:
     nsAutoTArray<nsCountedRef<FcPattern>,1> mPatterns;
 };
 
 void
 gfxFcFontEntry::AdjustPatternToCSS(FcPattern *aPattern)
 {
     int fontWeight = -1;
     FcPatternGetInteger(aPattern, FC_WEIGHT, 0, &fontWeight);
-    int cssWeight = gfxFontconfigUtils::FcWeightForBaseWeight(mWeight);
+    int cssWeight = gfxFontconfigUtils::FcWeightForBaseWeight(mWeight / 100);
     if (cssWeight != fontWeight) {
         FcPatternDel(aPattern, FC_WEIGHT);
         FcPatternAddInteger(aPattern, FC_WEIGHT, cssWeight);
     }
 
     int fontSlant;
     FcResult res = FcPatternGetInteger(aPattern, FC_SLANT, 0, &fontSlant);
     // gfxFontEntry doesn't understand the difference between oblique
--- a/layout/reftests/font-face/reftest.list
+++ b/layout/reftests/font-face/reftest.list
@@ -72,9 +72,9 @@ HTTP(..) == media-query-add-1.html media
 HTTP(..) == media-query-remove-1.html media-query-remove-1-ref.html
 HTTP(..) != media-query-add-1-ref.html media-query-remove-1-ref.html
 
 HTTP(..) == ahem-metrics-1.html ahem-metrics-1-ref.html
 HTTP(..) == ex-unit-1.html ex-unit-1-ref.html
 HTTP(..) == ex-unit-1-dynamic.html ex-unit-1-ref.html
 
 fails-if(MOZ_WIDGET_TOOLKIT=="windows") == local-1.html local-1-ref.html # bug 468387
-fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html # bug 468387, 480098
+fails-if(MOZ_WIDGET_TOOLKIT=="windows") HTTP(..) == synthetic-weight-style.html synthetic-weight-style-ref.html # bug 468387