Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit e2607d4

Browse files
shrikantCommit bot
shrikant
authored and
Commit bot
committed
Disable direct write if font count in registry is greater than or equal to threshold (currently 1750).
R=scottmg,ananta,cpu,asvitkine BUG=421305 Review URL: https://codereview.chromium.org/667013003 Cr-Commit-Position: refs/heads/master@{#300345}
1 parent c6d8e74 commit e2607d4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ui/gfx/win/direct_write.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "base/basictypes.h"
88
#include "base/command_line.h"
99
#include "base/metrics/field_trial.h"
10+
#include "base/win/registry.h"
1011
#include "base/win/windows_version.h"
1112
#include "ui/gfx/switches.h"
1213
#include "ui/gfx/win/dpi.h"
@@ -38,6 +39,20 @@ bool ShouldUseDirectWrite() {
3839
if (gfx::GetDPIScale() > 1.0f)
3940
return true;
4041

42+
// We have logic in renderer_font_platform_win.cc for falling back to safe
43+
// font list if machine has more than 1750 fonts installed. Users have
44+
// complained about this as safe font list is usually not sufficient.
45+
// We now disable direct write (gdi) if we encounter more number
46+
// of fonts than a threshold (currently 1750).
47+
// Refer: crbug.com/421305
48+
const wchar_t kWindowsFontsRegistryKey[] =
49+
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts";
50+
base::win::RegistryValueIterator reg_iterator(HKEY_LOCAL_MACHINE,
51+
kWindowsFontsRegistryKey);
52+
const DWORD kMaxAllowedFontsBeforeFallbackToGDI = 1750;
53+
if (reg_iterator.ValueCount() >= kMaxAllowedFontsBeforeFallbackToGDI)
54+
return false;
55+
4156
// Otherwise, check the field trial.
4257
const std::string group_name =
4358
base::FieldTrialList::FindFullName("DirectWrite");

0 commit comments

Comments
 (0)