Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ui/gfx/platform_font_pango.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win bots Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_pango.h" 5 #include "ui/gfx/platform_font_pango.h"
6 6
7 #include <fontconfig/fontconfig.h> 7 #include <fontconfig/fontconfig.h>
8 #include <pango/pango.h> 8 #include <pango/pango.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 175 }
176 176
177 int PlatformFontPango::GetHeight() const { 177 int PlatformFontPango::GetHeight() const {
178 return height_pixels_; 178 return height_pixels_;
179 } 179 }
180 180
181 int PlatformFontPango::GetBaseline() const { 181 int PlatformFontPango::GetBaseline() const {
182 return ascent_pixels_; 182 return ascent_pixels_;
183 } 183 }
184 184
185 int PlatformFontPango::GetAverageCharacterWidth() const { 185 float PlatformFontPango::GetAverageCharacterWidth() const {
186 const_cast<PlatformFontPango*>(this)->InitPangoMetrics(); 186 const_cast<PlatformFontPango*>(this)->InitPangoMetrics();
187 return SkScalarRound(average_width_pixels_); 187 return SkScalarRound(average_width_pixels_);
188 } 188 }
189 189
190 int PlatformFontPango::GetStringWidth(const base::string16& text) const { 190 float PlatformFontPango::GetStringWidth(const base::string16& text) const {
191 return Canvas::GetStringWidth(text, 191 return Canvas::GetStringWidth(text,
192 Font(const_cast<PlatformFontPango*>(this))); 192 Font(const_cast<PlatformFontPango*>(this)));
193 } 193 }
194 194
195 int PlatformFontPango::GetExpectedTextWidth(int length) const { 195 float PlatformFontPango::GetExpectedTextWidth(int length) const {
196 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth(); 196 double char_width = const_cast<PlatformFontPango*>(this)->GetAverageWidth();
197 return round(static_cast<float>(length) * char_width); 197 return round(static_cast<float>(length) * char_width);
198 } 198 }
199 199
200 int PlatformFontPango::GetStyle() const { 200 int PlatformFontPango::GetStyle() const {
201 return style_; 201 return style_;
202 } 202 }
203 203
204 std::string PlatformFontPango::GetFontName() const { 204 std::string PlatformFontPango::GetFontName() const {
205 return font_family_; 205 return font_family_;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 return new PlatformFontPango(native_font); 400 return new PlatformFontPango(native_font);
401 } 401 }
402 402
403 // static 403 // static
404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name, 404 PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string& font_name,
405 int font_size) { 405 int font_size) {
406 return new PlatformFontPango(font_name, font_size); 406 return new PlatformFontPango(font_name, font_size);
407 } 407 }
408 408
409 } // namespace gfx 409 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698