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.
5 #include "ui/gfx/font.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/gfx/platform_font.h"
12 ////////////////////////////////////////////////////////////////////////////////
15 Font::Font() : platform_font_(PlatformFont::CreateDefault()) {
18 Font::Font(const Font
& other
) : platform_font_(other
.platform_font_
) {
21 Font
& Font::operator=(const Font
& other
) {
22 platform_font_
= other
.platform_font_
;
26 Font::Font(NativeFont native_font
)
27 : platform_font_(PlatformFont::CreateFromNativeFont(native_font
)) {
30 Font::Font(PlatformFont
* platform_font
) : platform_font_(platform_font
) {
33 Font::Font(const std::string
& font_name
, int font_size
)
34 : platform_font_(PlatformFont::CreateFromNameAndSize(font_name
,
41 Font
Font::Derive(int size_delta
, int style
) const {
42 return platform_font_
->DeriveFont(size_delta
, style
);
45 int Font::GetHeight() const {
46 return platform_font_
->GetHeight();
49 int Font::GetBaseline() const {
50 return platform_font_
->GetBaseline();
53 int Font::GetCapHeight() const {
54 return platform_font_
->GetCapHeight();
57 int Font::GetExpectedTextWidth(int length
) const {
58 return platform_font_
->GetExpectedTextWidth(length
);
61 int Font::GetStyle() const {
62 return platform_font_
->GetStyle();
65 std::string
Font::GetFontName() const {
66 return platform_font_
->GetFontName();
69 std::string
Font::GetActualFontNameForTesting() const {
70 return platform_font_
->GetActualFontNameForTesting();
73 int Font::GetFontSize() const {
74 return platform_font_
->GetFontSize();
77 NativeFont
Font::GetNativeFont() const {
78 return platform_font_
->GetNativeFont();