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

Unified Diff: Source/platform/fonts/win/FontCacheSkiaWin.cpp

Issue 790733005: Blink side of the change to pass the system font metrics from the browser to the renderer on Windo… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 11 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
Index: Source/platform/fonts/win/FontCacheSkiaWin.cpp
diff --git a/Source/platform/fonts/win/FontCacheSkiaWin.cpp b/Source/platform/fonts/win/FontCacheSkiaWin.cpp
index 47d376c1709a37c52d94fdb39a662eb639efb807..993fc7427c9b73bc252d4d02eb8076d7d3b6a82e 100644
--- a/Source/platform/fonts/win/FontCacheSkiaWin.cpp
+++ b/Source/platform/fonts/win/FontCacheSkiaWin.cpp
@@ -45,6 +45,25 @@ namespace blink {
HashMap<String, RefPtr<SkTypeface> >* FontCache::s_sideloadedFonts = 0;
+// Cached system font metrics.
+String FontCache::s_menuFontFamilyName;
+int32_t FontCache::s_menuFontHeight = 0;
+String FontCache::s_smallCaptionFontFamilyName;
+int32_t FontCache::s_smallCaptionFontHeight = 0;
+String FontCache::s_statusFontFamilyName;
+int32_t FontCache::s_statusFontHeight = 0;
+
+namespace {
+
+int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight)
+{
+ // Adjustment for codepage 936 to make the fonts more legible in Simplified Chinese.
+ // Please refer to RenderThemeChromiumFontProviderWin.cpp for more information.
+ return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight;
+}
+
+} // namespace
+
// static
void FontCache::addSideloadedFontForTesting(SkTypeface* typeface)
{
@@ -55,6 +74,27 @@ void FontCache::addSideloadedFontForTesting(SkTypeface* typeface)
s_sideloadedFonts->set(name.c_str(), adoptRef(typeface));
}
+// static
+void FontCache::setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight)
+{
+ s_menuFontFamilyName = familyName;
+ s_menuFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight);
+}
+
+// static
+void FontCache::setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fontHeight)
+{
+ s_smallCaptionFontFamilyName = familyName;
+ s_smallCaptionFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight);
+}
+
+// static
+void FontCache::setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeight)
+{
+ s_statusFontFamilyName = familyName;
+ s_statusFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight);
+}
+
FontCache::FontCache()
: m_purgePreventCount(0)
{

Powered by Google App Engine
This is Rietveld 408576698