From 5cbc5577bdc759a0e15155626d0abd6c69b14598 Mon Sep 17 00:00:00 2001 From: Shrikant Kelkar Date: Tue, 21 Oct 2014 13:06:47 -0700 Subject: [PATCH] Disable direct write if font count in registry is greater than or equal to threshold (currently 1750). R=cpu@chromium.org, ananta, asvitkine, cpu, scottmg BUG=421305 Review URL: https://codereview.chromium.org/667013003 Cr-Commit-Position: refs/heads/master@{#300345} (cherry picked from commit e2607d44b9384080b7a98e0b7ed9773265969d87) Conflicts: ui/gfx/win/direct_write.cc Review URL: https://codereview.chromium.org/671743002 Cr-Commit-Position: refs/branch-heads/2125@{#583} Cr-Branched-From: b68026d94bda36dd106a3d91a098719f952a9477-refs/heads/master@{#290040} --- content/common/sandbox_win.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/content/common/sandbox_win.cc b/content/common/sandbox_win.cc index 1f13fb8f7afd0..ed61bfa555958 100644 --- a/content/common/sandbox_win.cc +++ b/content/common/sandbox_win.cc @@ -18,6 +18,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/win/iat_patch_function.h" +#include "base/win/registry.h" #include "base/win/scoped_handle.h" #include "base/win/scoped_process_information.h" #include "base/win/windows_version.h" @@ -603,6 +604,20 @@ bool ShouldUseDirectWrite() { return true; #endif + // We have logic in renderer_font_platform_win.cc for falling back to safe + // font list if machine has more than 1750 fonts installed. Users have + // complained about this as safe font list is usually not sufficient. + // We now disable direct write (gdi) if we encounter more number + // of fonts than a threshold (currently 1750). + // Refer: crbug.com/421305 + const wchar_t kWindowsFontsRegistryKey[] = + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; + base::win::RegistryValueIterator reg_iterator(HKEY_LOCAL_MACHINE, + kWindowsFontsRegistryKey); + const DWORD kMaxAllowedFontsBeforeFallbackToGDI = 1750; + if (reg_iterator.ValueCount() >= kMaxAllowedFontsBeforeFallbackToGDI) + return false; + // Otherwise, check the field trial. const std::string group_name = base::FieldTrialList::FindFullName("DirectWrite");