|
7 | 7 | #include "base/basictypes.h"
|
8 | 8 | #include "base/command_line.h"
|
9 | 9 | #include "base/metrics/field_trial.h"
|
| 10 | +#include "base/win/registry.h" |
10 | 11 | #include "base/win/windows_version.h"
|
11 | 12 | #include "ui/gfx/switches.h"
|
12 | 13 | #include "ui/gfx/win/dpi.h"
|
@@ -38,6 +39,20 @@ bool ShouldUseDirectWrite() {
|
38 | 39 | if (gfx::GetDPIScale() > 1.0f)
|
39 | 40 | return true;
|
40 | 41 |
|
| 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 | + |
41 | 56 | // Otherwise, check the field trial.
|
42 | 57 | const std::string group_name =
|
43 | 58 | base::FieldTrialList::FindFullName("DirectWrite");
|
|
0 commit comments