| 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 11 matching lines...) Expand all Loading... |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // Queries the registry to get a mapping from font filenames to font names. | 24 // Queries the registry to get a mapping from font filenames to font names. |
| 25 void QueryFontsFromRegistry(std::map<std::string, std::string>* map) { | 25 void QueryFontsFromRegistry(std::map<std::string, std::string>* map) { |
| 26 const wchar_t* kFonts = | 26 const wchar_t* kFonts = |
| 27 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; | 27 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; |
| 28 | 28 |
| 29 base::win::RegistryValueIterator it(HKEY_LOCAL_MACHINE, kFonts); | 29 base::win::RegistryValueIterator it(HKEY_LOCAL_MACHINE, kFonts); |
| 30 for (; it.Valid(); ++it) { | 30 for (; it.Valid(); ++it) { |
| 31 const std::string filename = | 31 const std::string filename = |
| 32 base::StringToLowerASCII(base::WideToUTF8(it.Value())); | 32 base::ToLowerASCII(base::WideToUTF8(it.Value())); |
| 33 (*map)[filename] = base::WideToUTF8(it.Name()); | 33 (*map)[filename] = base::WideToUTF8(it.Name()); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Fills |font_names| with a list of font families found in the font file at | 37 // Fills |font_names| with a list of font families found in the font file at |
| 38 // |filename|. Takes in a |font_map| from font filename to font families, which | 38 // |filename|. Takes in a |font_map| from font filename to font families, which |
| 39 // is filled-in by querying the registry, if empty. | 39 // is filled-in by querying the registry, if empty. |
| 40 void GetFontNamesFromFilename(const std::string& filename, | 40 void GetFontNamesFromFilename(const std::string& filename, |
| 41 std::map<std::string, std::string>* font_map, | 41 std::map<std::string, std::string>* font_map, |
| 42 std::vector<std::string>* font_names) { | 42 std::vector<std::string>* font_names) { |
| 43 if (font_map->empty()) | 43 if (font_map->empty()) |
| 44 QueryFontsFromRegistry(font_map); | 44 QueryFontsFromRegistry(font_map); |
| 45 | 45 |
| 46 std::map<std::string, std::string>::const_iterator it = | 46 std::map<std::string, std::string>::const_iterator it = |
| 47 font_map->find(base::StringToLowerASCII(filename)); | 47 font_map->find(base::ToLowerASCII(filename)); |
| 48 if (it == font_map->end()) | 48 if (it == font_map->end()) |
| 49 return; | 49 return; |
| 50 | 50 |
| 51 internal::ParseFontFamilyString(it->second, font_names); | 51 internal::ParseFontFamilyString(it->second, font_names); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Returns true if |text| contains only ASCII digits. | 54 // Returns true if |text| contains only ASCII digits. |
| 55 bool ContainsOnlyDigits(const std::string& text) { | 55 bool ContainsOnlyDigits(const std::string& text) { |
| 56 return text.find_first_not_of("0123456789") == base::string16::npos; | 56 return text.find_first_not_of("0123456789") == base::string16::npos; |
| 57 } | 57 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 font.GetFontSize()); | 322 font.GetFontSize()); |
| 323 found_fallback = true; | 323 found_fallback = true; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 DeleteEnhMetaFile(meta_file); | 326 DeleteEnhMetaFile(meta_file); |
| 327 | 327 |
| 328 return found_fallback; | 328 return found_fallback; |
| 329 } | 329 } |
| 330 | 330 |
| 331 } // namespace gfx | 331 } // namespace gfx |
| OLD | NEW |