From b16ecea3e699bcffa8a95a1d45ae5ee7dfcff5fa Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Wed, 11 Mar 2009 15:00:43 +1300 Subject: [PATCH] b=480098 correct weight units in gfxFcFontEntry::AdjustPatternToCSS r=roc --HG-- extra : rebase_source : 79604f227fc80720e4df479f1d8929f5c21623f2 --- gfx/thebes/src/gfxFontconfigUtils.cpp | 3 +++ gfx/thebes/src/gfxFontconfigUtils.h | 3 ++- gfx/thebes/src/gfxPangoFonts.cpp | 2 +- layout/reftests/font-face/reftest.list | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gfx/thebes/src/gfxFontconfigUtils.cpp b/gfx/thebes/src/gfxFontconfigUtils.cpp index d912dee4f40..32815c6de95 100644 --- a/gfx/thebes/src/gfxFontconfigUtils.cpp +++ b/gfx/thebes/src/gfxFontconfigUtils.cpp @@ -149,6 +149,9 @@ gfxFontconfigUtils::GetThebesWeight(FcPattern *aPattern) /* 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; diff --git a/gfx/thebes/src/gfxFontconfigUtils.h b/gfx/thebes/src/gfxFontconfigUtils.h index 639e5ded8c5..f53cfcdf018 100644 --- a/gfx/thebes/src/gfxFontconfigUtils.h +++ b/gfx/thebes/src/gfxFontconfigUtils.h @@ -150,7 +150,8 @@ public: 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, diff --git a/gfx/thebes/src/gfxPangoFonts.cpp b/gfx/thebes/src/gfxPangoFonts.cpp index 1574fcaf794..a3e73c9cf0a 100644 --- a/gfx/thebes/src/gfxPangoFonts.cpp +++ b/gfx/thebes/src/gfxPangoFonts.cpp @@ -209,7 +209,7 @@ 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); diff --git a/layout/reftests/font-face/reftest.list b/layout/reftests/font-face/reftest.list index c79a41d6969..116ea02ba0a 100644 --- a/layout/reftests/font-face/reftest.list +++ b/layout/reftests/font-face/reftest.list @@ -77,4 +77,4 @@ 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