| 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/platform_font_win.h" | 5 #include "ui/gfx/platform_font_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 int PlatformFontWin::GetStyle() const { | 162 int PlatformFontWin::GetStyle() const { |
| 163 return font_ref_->style(); | 163 return font_ref_->style(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 std::string PlatformFontWin::GetFontName() const { | 166 std::string PlatformFontWin::GetFontName() const { |
| 167 return font_ref_->font_name(); | 167 return font_ref_->font_name(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 std::string PlatformFontWin::GetActualFontNameForTesting() const { |
| 171 // With the current implementation on Windows, HFontRef::font_name() returns |
| 172 // the font name taken from the HFONT handle, but it's not the name that comes |
| 173 // from the font's metadata. See http://crbug.com/327287 |
| 174 return font_ref_->font_name(); |
| 175 } |
| 176 |
| 170 std::string PlatformFontWin::GetLocalizedFontName() const { | 177 std::string PlatformFontWin::GetLocalizedFontName() const { |
| 171 base::win::ScopedCreateDC memory_dc(CreateCompatibleDC(NULL)); | 178 base::win::ScopedCreateDC memory_dc(CreateCompatibleDC(NULL)); |
| 172 if (!memory_dc.Get()) | 179 if (!memory_dc.Get()) |
| 173 return GetFontName(); | 180 return GetFontName(); |
| 174 | 181 |
| 175 // When a font has a localized name for a language matching the system | 182 // When a font has a localized name for a language matching the system |
| 176 // locale, GetTextFace() returns the localized name. | 183 // locale, GetTextFace() returns the localized name. |
| 177 base::win::ScopedSelectObject font(memory_dc, font_ref_->hfont()); | 184 base::win::ScopedSelectObject font(memory_dc, font_ref_->hfont()); |
| 178 wchar_t localized_font_name[LF_FACESIZE]; | 185 wchar_t localized_font_name[LF_FACESIZE]; |
| 179 int length = GetTextFace(memory_dc, arraysize(localized_font_name), | 186 int length = GetTextFace(memory_dc, arraysize(localized_font_name), |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 return new PlatformFontWin(native_font); | 331 return new PlatformFontWin(native_font); |
| 325 } | 332 } |
| 326 | 333 |
| 327 // static | 334 // static |
| 328 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 335 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 329 int font_size) { | 336 int font_size) { |
| 330 return new PlatformFontWin(font_name, font_size); | 337 return new PlatformFontWin(font_name, font_size); |
| 331 } | 338 } |
| 332 | 339 |
| 333 } // namespace gfx | 340 } // namespace gfx |
| OLD | NEW |