Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1998)

Unified Diff: content/common/dwrite_font_platform_win.cc

Issue 898403002: win: Hack around Gill Sans Ultra Bold DirectWrite problem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/dwrite_font_platform_win.cc
diff --git a/content/common/dwrite_font_platform_win.cc b/content/common/dwrite_font_platform_win.cc
index c2547b5ea323842894728211f92e750a84788c13..aa9d98fb058ebb8b3dedd57e33ece6a802dfa99f 100644
--- a/content/common/dwrite_font_platform_win.cc
+++ b/content/common/dwrite_font_platform_win.cc
@@ -746,6 +746,24 @@ base::string16 FontCollectionLoader::GetFontNameFromKey(UINT32 idx) {
return reg_fonts_[idx];
}
+const wchar_t* kFontsToIgnore[] = {
+ // "Gill Sans Ultra Bold" turns into an Ultra Bold weight "Gill Sans" in
+ // DirectWrite, but most users don't have any other weights. The regular
+ // weight font is named "Gill Sans MT", but that ends up in a different
+ // family with that name. On Mac, there's a "Gill Sans" with various weights,
+ // so CSS authors use { 'font-family': 'Gill Sans', 'Gill Sans MT', ... } and
+ // because of the DirectWrite family futzing, they end up with an Ultra Bold
+ // font, when they just wanted "Gill Sans". Mozilla implemented a more
+ // complicated hack where they effectively rename the Ultra Bold font to
+ // "Gill Sans MT Ultra Bold", but because the Ultra Bold font is so ugly
+ // anyway, we simply ignore it. See
+ // http://www.microsoft.com/typography/fonts/font.aspx?FMID=978 for a picture
+ // of the font, and the file name. We also ignore "Gill Sans Ultra Bold
+ // Condensed".
+ L"gilsanub.ttf",
+ L"gillubcd.ttf",
+};
+
bool FontCollectionLoader::LoadFontListFromRegistry() {
const wchar_t kFontsRegistry[] =
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
@@ -773,7 +791,15 @@ bool FontCollectionLoader::LoadFontListFromRegistry() {
value.size() < kMaxFontFileNameLength - 1) ||
base::FilePath::CompareEqualIgnoreCase(system_font_path.value(),
path.DirName().value())) {
- reg_fonts_.push_back(value.c_str());
+ bool should_ignore = false;
+ for (const auto& ignore : kFontsToIgnore) {
+ if (base::FilePath::CompareEqualIgnoreCase(path.value(), ignore)) {
+ should_ignore = true;
+ break;
+ }
+ }
+ if (!should_ignore)
+ reg_fonts_.push_back(value.c_str());
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698