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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 int PlatformFontWin::GetHeight() const { | 136 int PlatformFontWin::GetHeight() const { |
137 return font_ref_->height(); | 137 return font_ref_->height(); |
138 } | 138 } |
139 | 139 |
140 int PlatformFontWin::GetBaseline() const { | 140 int PlatformFontWin::GetBaseline() const { |
141 return font_ref_->baseline(); | 141 return font_ref_->baseline(); |
142 } | 142 } |
143 | 143 |
144 int PlatformFontWin::GetAverageCharacterWidth() const { | 144 float PlatformFontWin::GetAverageCharacterWidth() const { |
145 return font_ref_->ave_char_width(); | 145 return font_ref_->ave_char_width(); |
146 } | 146 } |
147 | 147 |
148 int PlatformFontWin::GetStringWidth(const base::string16& text) const { | 148 float PlatformFontWin::GetStringWidth(const base::string16& text) const { |
149 return Canvas::GetStringWidth(text, | 149 return Canvas::GetStringWidth(text, |
150 Font(const_cast<PlatformFontWin*>(this))); | 150 Font(const_cast<PlatformFontWin*>(this))); |
151 } | 151 } |
152 | 152 |
153 int PlatformFontWin::GetExpectedTextWidth(int length) const { | 153 float PlatformFontWin::GetExpectedTextWidth(int length) const { |
154 return length * std::min(font_ref_->GetDluBaseX(), | 154 return length * std::min<float>(font_ref_->GetDluBaseX(), |
155 GetAverageCharacterWidth()); | 155 GetAverageCharacterWidth()); |
156 } | 156 } |
157 | 157 |
158 int PlatformFontWin::GetStyle() const { | 158 int PlatformFontWin::GetStyle() const { |
159 return font_ref_->style(); | 159 return font_ref_->style(); |
160 } | 160 } |
161 | 161 |
162 std::string PlatformFontWin::GetFontName() const { | 162 std::string PlatformFontWin::GetFontName() const { |
163 return font_ref_->font_name(); | 163 return font_ref_->font_name(); |
164 } | 164 } |
165 | 165 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return new PlatformFontWin(native_font); | 315 return new PlatformFontWin(native_font); |
316 } | 316 } |
317 | 317 |
318 // static | 318 // static |
319 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 319 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
320 int font_size) { | 320 int font_size) { |
321 return new PlatformFontWin(font_name, font_size); | 321 return new PlatformFontWin(font_name, font_size); |
322 } | 322 } |
323 | 323 |
324 } // namespace gfx | 324 } // namespace gfx |
OLD | NEW |