#5000 "GFX changes required to assume 96 dpi default scaling"

This commit is contained in:
pierre%netscape.com 1999-04-27 06:45:09 +00:00
parent 2bd75e97dc
commit 78e941dc79
9 changed files with 28 additions and 10 deletions

View File

@ -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);

View File

@ -29,6 +29,10 @@
#include "il_util.h"
#include <FixMath.h>
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;

View File

@ -78,6 +78,8 @@ protected:
static nsHashtable* gFontInfoList;
public:
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
static const PRUint32 kPixelsPerInch;
};
#endif /* nsDeviceContextMac_h___ */

View File

@ -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)

View File

@ -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:

View File

@ -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;

View File

@ -29,6 +29,10 @@
#include "il_util.h"
#include <FixMath.h>
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;

View File

@ -78,6 +78,8 @@ protected:
static nsHashtable* gFontInfoList;
public:
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
static const PRUint32 kPixelsPerInch;
};
#endif /* nsDeviceContextMac_h___ */

View File

@ -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);