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 3 // found in the LICENSE file. 4 5 #include "ui/gfx/font.h" 6 7 #include "base/strings/utf_string_conversions.h" 8 #include "ui/gfx/platform_font.h" 9 10 namespace gfx { 11 12 //////////////////////////////////////////////////////////////////////////////// 13 // Font, public: 14 Font()15Font::Font() : platform_font_(PlatformFont::CreateDefault()) { 16 } 17 Font(const Font & other)18Font::Font(const Font& other) : platform_font_(other.platform_font_) { 19 } 20 operator =(const Font & other)21Font& Font::operator=(const Font& other) { 22 platform_font_ = other.platform_font_; 23 return *this; 24 } 25 Font(NativeFont native_font)26Font::Font(NativeFont native_font) 27 : platform_font_(PlatformFont::CreateFromNativeFont(native_font)) { 28 } 29 Font(PlatformFont * platform_font)30Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) { 31 } 32 Font(const std::string & font_name,int font_size)33Font::Font(const std::string& font_name, int font_size) 34 : platform_font_(PlatformFont::CreateFromNameAndSize(font_name, 35 font_size)) { 36 } 37 ~Font()38Font::~Font() { 39 } 40 Derive(int size_delta,int style) const41Font Font::Derive(int size_delta, int style) const { 42 return platform_font_->DeriveFont(size_delta, style); 43 } 44 GetHeight() const45int Font::GetHeight() const { 46 return platform_font_->GetHeight(); 47 } 48 GetBaseline() const49int Font::GetBaseline() const { 50 return platform_font_->GetBaseline(); 51 } 52 GetCapHeight() const53int Font::GetCapHeight() const { 54 return platform_font_->GetCapHeight(); 55 } 56 GetExpectedTextWidth(int length) const57int Font::GetExpectedTextWidth(int length) const { 58 return platform_font_->GetExpectedTextWidth(length); 59 } 60 GetStyle() const61int Font::GetStyle() const { 62 return platform_font_->GetStyle(); 63 } 64 GetFontName() const65std::string Font::GetFontName() const { 66 return platform_font_->GetFontName(); 67 } 68 GetActualFontNameForTesting() const69std::string Font::GetActualFontNameForTesting() const { 70 return platform_font_->GetActualFontNameForTesting(); 71 } 72 GetFontSize() const73int Font::GetFontSize() const { 74 return platform_font_->GetFontSize(); 75 } 76 GetFontRenderParams() const77const FontRenderParams& Font::GetFontRenderParams() const { 78 return platform_font_->GetFontRenderParams(); 79 } 80 GetNativeFont() const81NativeFont Font::GetNativeFont() const { 82 return platform_font_->GetNativeFont(); 83 } 84 85 } // namespace gfx 86