tweaks to rounding problems with twips to pixels and font point sizes

added hack to support desdemona font for test cases
This commit is contained in:
peterl%netscape.com 1998-07-23 17:52:40 +00:00
parent 3538d9e5ed
commit e63a09dbd3
2 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,7 @@ nsDeviceContextWin :: nsDeviceContextWin()
HDC hdc = ::GetDC(NULL);
mTwipsToPixels = ::GetDeviceCaps(hdc, LOGPIXELSX) / NS_POINTS_TO_TWIPS_FLOAT(72.0f);
mTwipsToPixels = ((float)::GetDeviceCaps(hdc, LOGPIXELSX)) / NS_POINTS_TO_TWIPS_FLOAT(72.0f);
mPixelsToTwips = 1.0f / mTwipsToPixels;
::ReleaseDC(NULL, hdc);

View File

@ -90,6 +90,9 @@ const char* nsFontMetricsWin::MapFamilyToFont(const nsString& aLogicalFontName)
if (aLogicalFontName.EqualsIgnoreCase("monospace")) {
return "Courier New";
}
if (aLogicalFontName.EqualsIgnoreCase("desdemona")) {
return "Desdemona";
}
return "Arial";/* XXX for now */
}
@ -116,7 +119,8 @@ void nsFontMetricsWin::RealizeFont(nsIDeviceContext *aContext)
logFont.lfItalic = (mFont->style & NS_FONT_STYLE_ITALIC)
? TRUE : FALSE;
float t2p = aContext->GetAppUnitsToDevUnits();
logFont.lfHeight = (LONG)(-mFont->size * t2p);
float rounded = (float)NS_POINTS_TO_TWIPS_INT(NS_TWIPS_TO_POINTS_INT(mFont->size));
logFont.lfHeight = (LONG)(-rounded * t2p); // this ugly rounding is to make ours compatible with Nav 4.0
strncpy(logFont.lfFaceName,
MapFamilyToFont(mFont->name),
LF_FACESIZE);