OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/font_fallback_win.h" | 5 #include "ui/gfx/font_fallback_win.h" |
6 | 6 |
7 #include <usp10.h> | 7 #include <usp10.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
16 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
17 #include "ui/gfx/font_fallback.h" | 17 #include "ui/gfx/font_fallback.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Queries the registry to get a mapping from font filenames to font names. | 23 // Queries the registry to get a mapping from font filenames to font names. |
24 void QueryFontsFromRegistry(std::map<std::string, std::string>* map) { | 24 void QueryFontsFromRegistry(std::map<std::string, std::string>* map) { |
25 const wchar_t* kFonts = | 25 const wchar_t* kFonts = |
26 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; | 26 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; |
27 | 27 |
28 base::win::RegistryValueIterator it(HKEY_LOCAL_MACHINE, kFonts); | 28 // This registry key is "shared" between 32-bit and 64-bit hive so safe to |
| 29 // access without any WOW64 access flag. See |
| 30 // http://msdn.microsoft.com/en-us/library/windows/desktop/aa384253.aspx. |
| 31 base::win::RegistryValueIterator it(HKEY_LOCAL_MACHINE, kFonts, 0); |
29 for (; it.Valid(); ++it) { | 32 for (; it.Valid(); ++it) { |
30 const std::string filename = | 33 const std::string filename = |
31 base::StringToLowerASCII(base::WideToUTF8(it.Value())); | 34 base::StringToLowerASCII(base::WideToUTF8(it.Value())); |
32 (*map)[filename] = base::WideToUTF8(it.Name()); | 35 (*map)[filename] = base::WideToUTF8(it.Name()); |
33 } | 36 } |
34 } | 37 } |
35 | 38 |
36 // Fills |font_names| with a list of font families found in the font file at | 39 // Fills |font_names| with a list of font families found in the font file at |
37 // |filename|. Takes in a |font_map| from font filename to font families, which | 40 // |filename|. Takes in a |font_map| from font filename to font families, which |
38 // is filled-in by querying the registry, if empty. | 41 // is filled-in by querying the registry, if empty. |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 font.GetFontSize()); | 317 font.GetFontSize()); |
315 found_fallback = true; | 318 found_fallback = true; |
316 } | 319 } |
317 } | 320 } |
318 DeleteEnhMetaFile(meta_file); | 321 DeleteEnhMetaFile(meta_file); |
319 | 322 |
320 return found_fallback; | 323 return found_fallback; |
321 } | 324 } |
322 | 325 |
323 } // namespace gfx | 326 } // namespace gfx |
OLD | NEW |