diff --git a/gfx/src/mac/nsATSUIUtils.cpp b/gfx/src/mac/nsATSUIUtils.cpp index 11e20c3825c7..4ef16a3b5c43 100644 --- a/gfx/src/mac/nsATSUIUtils.cpp +++ b/gfx/src/mac/nsATSUIUtils.cpp @@ -419,8 +419,10 @@ ATSUTextLayout nsATSUIToolkit::GetTextLayout() mContext->GetDevUnitsToAppUnits(dev2app); Fixed size = FloatToFixed( roundf(float(fontsize) / dev2app)); +#if DONT_USE_FONTS_SMALLER_THAN_9 if( FixRound ( size ) < 9 ) size = X2Fix(9); +#endif theTag[1] = kATSUSizeTag; theValueSize[1] = (ByteCount) sizeof(Fixed); diff --git a/gfx/src/mac/nsDeviceContextMac.cpp b/gfx/src/mac/nsDeviceContextMac.cpp index ebb70fbdb1f3..f464f8cddc84 100644 --- a/gfx/src/mac/nsDeviceContextMac.cpp +++ b/gfx/src/mac/nsDeviceContextMac.cpp @@ -29,6 +29,10 @@ #include "il_util.h" #include + +const PRUint32 nsDeviceContextMac::kPixelsPerInch = 72; + + static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); //------------------------------------------------------------------------ @@ -69,7 +73,7 @@ double pix_inch; thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below! mDepth = (**thepix).pixelSize; pix_inch = Fix2X((**thepix).hRes); - mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72); + mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(kPixelsPerInch); mPixelsToTwips = 1.0f/mTwipsToPixels; return DeviceContextImpl::Init(aNativeWidget); @@ -341,7 +345,7 @@ THPrint thePrintRecord; // handle to print record ((nsDeviceContextMac*)aContext)->Init(curPort); ((nsDeviceContextMac*)aContext)->mPageRect = (**thePrintRecord).prInfo.rPage; - ((nsDeviceContextMac*)aContext)->mTwipsToPixels = pix_Inch/(float)NSIntPointsToTwips(72); + ((nsDeviceContextMac*)aContext)->mTwipsToPixels = pix_Inch/(float)NSIntPointsToTwips(kPixelsPerInch); ((nsDeviceContextMac*)aContext)->mPixelsToTwips = 1.0f/mTwipsToPixels; ((nsDeviceContextMac*)aContext)->mAppUnitsToDevUnits = mTwipsToPixels; ((nsDeviceContextMac*)aContext)->mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits; diff --git a/gfx/src/mac/nsDeviceContextMac.h b/gfx/src/mac/nsDeviceContextMac.h index 5dfbfbf1cfd3..4ba8fb82f7e3 100644 --- a/gfx/src/mac/nsDeviceContextMac.h +++ b/gfx/src/mac/nsDeviceContextMac.h @@ -78,6 +78,8 @@ protected: static nsHashtable* gFontInfoList; public: static bool GetMacFontNumber(const nsString& aFontName, short &fontNum); + + static const PRUint32 kPixelsPerInch; }; #endif /* nsDeviceContextMac_h___ */ diff --git a/gfx/src/mac/nsFontMetricsMac.cpp b/gfx/src/mac/nsFontMetricsMac.cpp index 1760b30d903c..89dc283d1feb 100644 --- a/gfx/src/mac/nsFontMetricsMac.cpp +++ b/gfx/src/mac/nsFontMetricsMac.cpp @@ -273,8 +273,10 @@ NS_EXPORT void nsFontMetricsMac::GetNativeTextStyle(nsIFontMetrics& inMetrics, inDevContext.GetDevUnitsToAppUnits(dev2app); short textSize = float(aFont->size) / dev2app; +#if DONT_USE_FONTS_SMALLER_THAN_9 if (textSize < 9) textSize = 9; +#endif Style textFace = normal; switch (aFont->style) diff --git a/gfx/src/mac/nsFontMetricsMac.h b/gfx/src/mac/nsFontMetricsMac.h index d954e7a0bed9..0f03cfb3e0fb 100644 --- a/gfx/src/mac/nsFontMetricsMac.h +++ b/gfx/src/mac/nsFontMetricsMac.h @@ -28,6 +28,8 @@ #include "nsIDeviceContext.h" #include "nsCRT.h" +#define DONT_USE_FONTS_SMALLER_THAN_9 1 // 1 = 9 pt minimum, 0 = use any font size + class nsFontMetricsMac : public nsIFontMetrics { public: diff --git a/gfx/src/mac/nsImageMac.cpp b/gfx/src/mac/nsImageMac.cpp index 6013291fb686..d05b22fd414e 100644 --- a/gfx/src/mac/nsImageMac.cpp +++ b/gfx/src/mac/nsImageMac.cpp @@ -113,8 +113,8 @@ PRInt32 bufferdepth; mThePixelmap.pixelSize = bufferdepth; mThePixelmap.packType = 0; mThePixelmap.packSize = 0; - mThePixelmap.hRes = 72<<16; - mThePixelmap.vRes = 72<<16; + mThePixelmap.hRes = nsDeviceContextMac::kPixelsPerInch<<16; + mThePixelmap.vRes = nsDeviceContextMac::kPixelsPerInch<<16; mThePixelmap.planeBytes = 0; mThePixelmap.pmReserved = 0; mThePixelmap.pmVersion = 0; diff --git a/widget/src/mac/nsDeviceContextMac.cpp b/widget/src/mac/nsDeviceContextMac.cpp index ebb70fbdb1f3..f464f8cddc84 100644 --- a/widget/src/mac/nsDeviceContextMac.cpp +++ b/widget/src/mac/nsDeviceContextMac.cpp @@ -29,6 +29,10 @@ #include "il_util.h" #include + +const PRUint32 nsDeviceContextMac::kPixelsPerInch = 72; + + static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID); //------------------------------------------------------------------------ @@ -69,7 +73,7 @@ double pix_inch; thepix = (**thegd).gdPMap; // dereferenced handle: don't move memory below! mDepth = (**thepix).pixelSize; pix_inch = Fix2X((**thepix).hRes); - mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(72); + mTwipsToPixels = pix_inch/(float)NSIntPointsToTwips(kPixelsPerInch); mPixelsToTwips = 1.0f/mTwipsToPixels; return DeviceContextImpl::Init(aNativeWidget); @@ -341,7 +345,7 @@ THPrint thePrintRecord; // handle to print record ((nsDeviceContextMac*)aContext)->Init(curPort); ((nsDeviceContextMac*)aContext)->mPageRect = (**thePrintRecord).prInfo.rPage; - ((nsDeviceContextMac*)aContext)->mTwipsToPixels = pix_Inch/(float)NSIntPointsToTwips(72); + ((nsDeviceContextMac*)aContext)->mTwipsToPixels = pix_Inch/(float)NSIntPointsToTwips(kPixelsPerInch); ((nsDeviceContextMac*)aContext)->mPixelsToTwips = 1.0f/mTwipsToPixels; ((nsDeviceContextMac*)aContext)->mAppUnitsToDevUnits = mTwipsToPixels; ((nsDeviceContextMac*)aContext)->mDevUnitsToAppUnits = 1.0f / mAppUnitsToDevUnits; diff --git a/widget/src/mac/nsDeviceContextMac.h b/widget/src/mac/nsDeviceContextMac.h index 5dfbfbf1cfd3..4ba8fb82f7e3 100644 --- a/widget/src/mac/nsDeviceContextMac.h +++ b/widget/src/mac/nsDeviceContextMac.h @@ -78,6 +78,8 @@ protected: static nsHashtable* gFontInfoList; public: static bool GetMacFontNumber(const nsString& aFontName, short &fontNum); + + static const PRUint32 kPixelsPerInch; }; #endif /* nsDeviceContextMac_h___ */ diff --git a/widget/src/mac/nsMacControl.cpp b/widget/src/mac/nsMacControl.cpp index ad1179a1b184..ab8bd4139f51 100644 --- a/widget/src/mac/nsMacControl.cpp +++ b/widget/src/mac/nsMacControl.cpp @@ -284,8 +284,6 @@ NS_METHOD nsMacControl::CreateOrReplaceMacControl(short inControlType) // // //------------------------------------------------------------------------- -#define kMinControlFontSize 9 - void nsMacControl::SetupMacControlFont() { NS_PRECONDITION(mFontMetrics != nsnull, "No font metrics in SetupMacControlFont"); @@ -294,9 +292,11 @@ void nsMacControl::SetupMacControlFont() TextStyle theStyle; nsFontMetricsMac::GetNativeTextStyle(*mFontMetrics, *mContext, theStyle); +#if DONT_USE_FONTS_SMALLER_THAN_9 // impose a min size of 9pt on the control font - if (theStyle.tsSize < kMinControlFontSize) - theStyle.tsSize = kMinControlFontSize; + if (theStyle.tsSize < 9) + theStyle.tsSize = 9; +#endif ControlFontStyleRec fontStyleRec; fontStyleRec.flags = (kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask);