bug 852522 - (win-hidpi) scale system font sizes in response to dpi/devPixelsPerPx setting. r=jimm

This commit is contained in:
Jonathan Kew 2013-03-19 17:24:27 +00:00
Родитель 3c12543a8e
Коммит 1beddbc13f
1 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -555,18 +555,19 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
break;
}
// FIXME?: mPixelScale is currently hardcoded to 1.
float mPixelScale = 1.0f;
// Get scaling factor from logical to physical pixels
float pixelScale = 96.0 / GetDeviceCaps(aHDC, LOGPIXELSY);
// The lfHeight is in pixels, and it needs to be adjusted for the
// device it will be displayed on.
// Screens and Printers will differ in DPI
//
// So this accounts for the difference in the DeviceContexts
// The mPixelScale will be a "1" for the screen and could be
// any value when going to a printer, for example mPixleScale is
// The pixelScale will typically be 1.0 for the screen
// (though larger for hi-dpi screens where the Windows resolution
// scale factor is 125% or 150% or even more), and could be
// any value when going to a printer, for example pixelScale is
// 6.25 when going to a 600dpi printer.
// round, but take into account whether it is negative
float pixelHeight = -ptrLogFont->lfHeight;
if (pixelHeight < 0) {
HFONT hFont = ::CreateFontIndirectW(ptrLogFont);
@ -579,7 +580,7 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
::DeleteObject(hFont);
pixelHeight = tm.tmAscent;
}
pixelHeight *= mPixelScale;
pixelHeight *= pixelScale;
// we have problem on Simplified Chinese system because the system
// report the default font size is 8 points. but if we use 8, the text
@ -619,6 +620,8 @@ nsLookAndFeel::GetFontImpl(FontID anID, nsString &aFontName,
HDC tdc = GetDC(NULL);
bool status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
ReleaseDC(NULL, tdc);
// now convert the logical font size from GetSysFontInfo into device pixels for layout
aFontStyle.size *= aDevPixPerCSSPixel;
return status;
}