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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 return font_ref_->font_name(); | 173 return font_ref_->font_name(); |
174 } | 174 } |
175 | 175 |
176 std::string PlatformFontWin::GetLocalizedFontName() const { | 176 std::string PlatformFontWin::GetLocalizedFontName() const { |
177 base::win::ScopedCreateDC memory_dc(CreateCompatibleDC(NULL)); | 177 base::win::ScopedCreateDC memory_dc(CreateCompatibleDC(NULL)); |
178 if (!memory_dc.Get()) | 178 if (!memory_dc.Get()) |
179 return GetFontName(); | 179 return GetFontName(); |
180 | 180 |
181 // When a font has a localized name for a language matching the system | 181 // When a font has a localized name for a language matching the system |
182 // locale, GetTextFace() returns the localized name. | 182 // locale, GetTextFace() returns the localized name. |
183 base::win::ScopedSelectObject font(memory_dc, font_ref_->hfont()); | 183 base::win::ScopedSelectObject font(memory_dc.Get(), font_ref_->hfont()); |
184 wchar_t localized_font_name[LF_FACESIZE]; | 184 wchar_t localized_font_name[LF_FACESIZE]; |
185 int length = GetTextFace(memory_dc, arraysize(localized_font_name), | 185 int length = GetTextFace(memory_dc.Get(), arraysize(localized_font_name), |
186 &localized_font_name[0]); | 186 &localized_font_name[0]); |
187 if (length <= 0) | 187 if (length <= 0) |
188 return GetFontName(); | 188 return GetFontName(); |
189 return base::SysWideToUTF8(localized_font_name); | 189 return base::SysWideToUTF8(localized_font_name); |
190 } | 190 } |
191 | 191 |
192 int PlatformFontWin::GetFontSize() const { | 192 int PlatformFontWin::GetFontSize() const { |
193 return font_ref_->font_size(); | 193 return font_ref_->font_size(); |
194 } | 194 } |
195 | 195 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 return new PlatformFontWin(native_font); | 377 return new PlatformFontWin(native_font); |
378 } | 378 } |
379 | 379 |
380 // static | 380 // static |
381 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 381 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
382 int font_size) { | 382 int font_size) { |
383 return new PlatformFontWin(font_name, font_size); | 383 return new PlatformFontWin(font_name, font_size); |
384 } | 384 } |
385 | 385 |
386 } // namespace gfx | 386 } // namespace gfx |
OLD | NEW |