Bug 1123654 - Replace use of [deprecated] GetStockObject(DEFAULT_GUI_FONT) with newer API; results in use of Tahoma in place of Microsoft Sans Serif in various contexts. r=jimm

This commit is contained in:
Jonathan Kew 2015-01-22 22:52:26 +00:00
parent 881c62848d
commit e3d0ba6183
4 changed files with 39 additions and 47 deletions

View File

@ -860,22 +860,22 @@ gfxGDIFontList::GetDefaultFont(const gfxFontStyle* aStyle)
gfxFontFamily *ff = nullptr;
// this really shouldn't fail to find a font....
HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
LOGFONTW logFont;
if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) {
ff = FindFamily(nsDependentString(logFont.lfFaceName));
if (ff) {
return ff;
}
}
// ...but just in case, try another approach as well
NONCLIENTMETRICSW ncm;
ncm.cbSize = sizeof(ncm);
BOOL status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), &ncm, 0);
if (status) {
ff = FindFamily(nsDependentString(ncm.lfMessageFont.lfFaceName));
if (ff) {
return ff;
}
}
// ...but just in case, try another (long-deprecated) approach as well
HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
LOGFONTW logFont;
if (hGDI && ::GetObjectW(hGDI, sizeof(logFont), &logFont)) {
ff = FindFamily(nsDependentString(logFont.lfFaceName));
}
return ff;

View File

@ -557,9 +557,9 @@ skip-if(B2G) == 363858-1.html 363858-1-ref.html
skip-if(B2G) == 363858-2.html 363858-2-ref.html
skip-if(B2G) == 363858-3.html 363858-3-ref.html
skip-if(B2G) == 363858-4.html 363858-4-ref.html
fuzzy-if(OSX>=1008,45,2) == 363858-5a.html 363858-5-ref.html
fuzzy-if(OSX>=1008,45,2) fuzzy-if(winWidget,37,1) == 363858-5a.html 363858-5-ref.html
== 363858-5b.html 363858-5-ref.html
fuzzy-if(OSX>=1008,45,2) == 363858-6a.html 363858-6-ref.html
fuzzy-if(OSX>=1008,45,2) fuzzy-if(winWidget,37,1) == 363858-6a.html 363858-6-ref.html
== 363858-6b.html 363858-6-ref.html
== 363874.html 363874-ref.html
== 363874-max-width.html 363874-max-width-ref.html

View File

@ -16,7 +16,7 @@
== placeholder-3.html placeholder-overridden-ref.html
== placeholder-4.html placeholder-overridden-ref.html
== placeholder-5.html placeholder-visible-ref.html
fuzzy-if(winWidget,160,6) == placeholder-6.html placeholder-overflow-ref.html
fuzzy-if(winWidget,160,7) == placeholder-6.html placeholder-overflow-ref.html
skip-if(B2G) == placeholder-6-textarea.html placeholder-overflow-textarea-ref.html
# needs-focus == placeholder-7.html placeholder-focus-ref.html
# needs-focus == placeholder-8.html placeholder-focus-ref.html

View File

@ -535,10 +535,10 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
LOGFONTW* ptrLogFont = nullptr;
LOGFONTW logFont;
NONCLIENTMETRICSW ncm;
HGDIOBJ hGDI;
char16_t name[LF_FACESIZE];
bool useShellDlg = false;
// Depending on which stock font we want, there are three different
// Depending on which stock font we want, there are a couple of
// places we might have to look it up.
switch (anID) {
case LookAndFeel::eFont_Icon:
@ -549,11 +549,7 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
ptrLogFont = &logFont;
break;
case LookAndFeel::eFont_Menu:
case LookAndFeel::eFont_MessageBox:
case LookAndFeel::eFont_SmallCaption:
case LookAndFeel::eFont_StatusBar:
case LookAndFeel::eFont_Tooltips:
default:
ncm.cbSize = sizeof(NONCLIENTMETRICSW);
if (!::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
sizeof(ncm), (PVOID)&ncm, 0))
@ -561,10 +557,11 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
switch (anID) {
case LookAndFeel::eFont_Menu:
case LookAndFeel::eFont_PullDownMenu:
ptrLogFont = &ncm.lfMenuFont;
break;
case LookAndFeel::eFont_MessageBox:
ptrLogFont = &ncm.lfMessageFont;
case LookAndFeel::eFont_Caption:
ptrLogFont = &ncm.lfCaptionFont;
break;
case LookAndFeel::eFont_SmallCaption:
ptrLogFont = &ncm.lfSmCaptionFont;
@ -573,29 +570,21 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
case LookAndFeel::eFont_Tooltips:
ptrLogFont = &ncm.lfStatusFont;
break;
}
break;
case LookAndFeel::eFont_Widget:
case LookAndFeel::eFont_Window: // css3
case LookAndFeel::eFont_Document:
case LookAndFeel::eFont_Workspace:
case LookAndFeel::eFont_Desktop:
case LookAndFeel::eFont_Info:
case LookAndFeel::eFont_Dialog:
case LookAndFeel::eFont_Button:
case LookAndFeel::eFont_PullDownMenu:
case LookAndFeel::eFont_List:
case LookAndFeel::eFont_Field:
case LookAndFeel::eFont_Caption:
hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
if (!hGDI)
return false;
if (::GetObjectW(hGDI, sizeof(logFont), &logFont) <= 0)
return false;
ptrLogFont = &logFont;
// XXX It's not clear to me whether this is exactly the right
// set of LookAndFeel values to map to the dialog font; we may
// want to add or remove cases here after reviewing the visual
// results under various Windows versions.
useShellDlg = true;
// Fall through so that we can get size from lfMessageFont;
// but later we'll use the (virtual) "MS Shell Dlg 2" font name
// instead of the LOGFONT's.
default:
ptrLogFont = &ncm.lfMessageFont;
break;
}
break;
}
@ -649,9 +638,12 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
aFontStyle.systemFont = true;
name[0] = 0;
if (useShellDlg) {
aFontName = NS_LITERAL_STRING("MS Shell Dlg 2");
} else {
memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*sizeof(char16_t));
aFontName = name;
}
return true;
}