summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/font.cc
blob: 9eea73b608aa0ed091f8f5af1c6e508417fe7e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/gfx/font.h"

#include "base/strings/utf_string_conversions.h"
#include "ui/gfx/platform_font.h"

namespace gfx {

////////////////////////////////////////////////////////////////////////////////
// Font, public:

Font::Font() : platform_font_(PlatformFont::CreateDefault()) {
}

Font::Font(const Font& other) : platform_font_(other.platform_font_) {
}

gfx::Font& Font::operator=(const Font& other) {
  platform_font_ = other.platform_font_;
  return *this;
}

Font::Font(NativeFont native_font)
    : platform_font_(PlatformFont::CreateFromNativeFont(native_font)) {
}

Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) {
}

Font::Font(const std::string& font_name, int font_size)
    : platform_font_(PlatformFont::CreateFromNameAndSize(font_name,
                                                         font_size)) {
}

Font::~Font() {
}

Font Font::DeriveFont(int size_delta) const {
  return DeriveFont(size_delta, GetStyle());
}

Font Font::DeriveFont(int size_delta, int style) const {
  return platform_font_->DeriveFont(size_delta, style);
}

int Font::GetHeight() const {
  return platform_font_->GetHeight();
}

int Font::GetBaseline() const {
  return platform_font_->GetBaseline();
}

int Font::GetCapHeight() const {
  return platform_font_->GetCapHeight();
}

int Font::GetAverageCharacterWidth() const {
  return platform_font_->GetAverageCharacterWidth();
}

int Font::GetStringWidth(const base::string16& text) const {
  return platform_font_->GetStringWidth(text);
}

int Font::GetExpectedTextWidth(int length) const {
  return platform_font_->GetExpectedTextWidth(length);
}

int Font::GetStyle() const {
  return platform_font_->GetStyle();
}

std::string Font::GetFontName() const {
  return platform_font_->GetFontName();
}

std::string Font::GetActualFontNameForTesting() const {
  return platform_font_->GetActualFontNameForTesting();
}

int Font::GetFontSize() const {
  return platform_font_->GetFontSize();
}

NativeFont Font::GetNativeFont() const {
  return platform_font_->GetNativeFont();
}

}  // namespace gfx