| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::GetCapHeight() const { | 144 int PlatformFontWin::GetCapHeight() const { |
| 145 return font_ref_->cap_height(); | 145 return font_ref_->cap_height(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 int PlatformFontWin::GetAverageCharacterWidth() const { | 148 float PlatformFontWin::GetAverageCharacterWidth() const { |
| 149 return font_ref_->ave_char_width(); | 149 return font_ref_->ave_char_width(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 int PlatformFontWin::GetStringWidth(const base::string16& text) const { | 152 float PlatformFontWin::GetStringWidth(const base::string16& text) const { |
| 153 return Canvas::GetStringWidth(text, | 153 return Canvas::GetStringWidth(text, |
| 154 Font(const_cast<PlatformFontWin*>(this))); | 154 Font(const_cast<PlatformFontWin*>(this))); |
| 155 } | 155 } |
| 156 | 156 |
| 157 int PlatformFontWin::GetExpectedTextWidth(int length) const { | 157 float PlatformFontWin::GetExpectedTextWidth(int length) const { |
| 158 return length * std::min(font_ref_->GetDluBaseX(), | 158 return length * std::min<float>(font_ref_->GetDluBaseX(), |
| 159 GetAverageCharacterWidth()); | 159 GetAverageCharacterWidth()); |
| 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 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 return new PlatformFontWin(native_font); | 324 return new PlatformFontWin(native_font); |
| 325 } | 325 } |
| 326 | 326 |
| 327 // static | 327 // static |
| 328 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, | 328 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, |
| 329 int font_size) { | 329 int font_size) { |
| 330 return new PlatformFontWin(font_name, font_size); | 330 return new PlatformFontWin(font_name, font_size); |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace gfx | 333 } // namespace gfx |
| OLD | NEW |