| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 base::win::RegistryValueIterator it(HKEY_LOCAL_MACHINE, kFonts); |
| 29 for (; it.Valid(); ++it) { | 29 for (; it.Valid(); ++it) { |
| 30 const std::string filename = | 30 const std::string filename = |
| 31 StringToLowerASCII(base::WideToUTF8(it.Value())); | 31 base::StringToLowerASCII(base::WideToUTF8(it.Value())); |
| 32 (*map)[filename] = base::WideToUTF8(it.Name()); | 32 (*map)[filename] = base::WideToUTF8(it.Name()); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Fills |font_names| with a list of font families found in the font file at | 36 // 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 | 37 // |filename|. Takes in a |font_map| from font filename to font families, which |
| 38 // is filled-in by querying the registry, if empty. | 38 // is filled-in by querying the registry, if empty. |
| 39 void GetFontNamesFromFilename(const std::string& filename, | 39 void GetFontNamesFromFilename(const std::string& filename, |
| 40 std::map<std::string, std::string>* font_map, | 40 std::map<std::string, std::string>* font_map, |
| 41 std::vector<std::string>* font_names) { | 41 std::vector<std::string>* font_names) { |
| 42 if (font_map->empty()) | 42 if (font_map->empty()) |
| 43 QueryFontsFromRegistry(font_map); | 43 QueryFontsFromRegistry(font_map); |
| 44 | 44 |
| 45 std::map<std::string, std::string>::const_iterator it = | 45 std::map<std::string, std::string>::const_iterator it = |
| 46 font_map->find(StringToLowerASCII(filename)); | 46 font_map->find(base::StringToLowerASCII(filename)); |
| 47 if (it == font_map->end()) | 47 if (it == font_map->end()) |
| 48 return; | 48 return; |
| 49 | 49 |
| 50 internal::ParseFontFamilyString(it->second, font_names); | 50 internal::ParseFontFamilyString(it->second, font_names); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Returns true if |text| contains only ASCII digits. | 53 // Returns true if |text| contains only ASCII digits. |
| 54 bool ContainsOnlyDigits(const std::string& text) { | 54 bool ContainsOnlyDigits(const std::string& text) { |
| 55 return text.find_first_not_of("0123456789") == base::string16::npos; | 55 return text.find_first_not_of("0123456789") == base::string16::npos; |
| 56 } | 56 } |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 font.GetFontSize()); | 314 font.GetFontSize()); |
| 315 found_fallback = true; | 315 found_fallback = true; |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 DeleteEnhMetaFile(meta_file); | 318 DeleteEnhMetaFile(meta_file); |
| 319 | 319 |
| 320 return found_fallback; | 320 return found_fallback; |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace gfx | 323 } // namespace gfx |
| OLD | NEW |