blob: 08b7b34e36c9a533950cb71723a909cb5f7700ec [file] [log] [blame]
[email protected]c6ac8412010-08-13 16:43:031// Copyright (c) 2006-2008 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
[email protected]08397d52011-02-05 01:53:385#include "ui/gfx/font.h"
[email protected]c6ac8412010-08-13 16:43:036
[email protected]cb8788d2010-12-10 23:44:067#include "base/utf_string_conversions.h"
[email protected]08397d52011-02-05 01:53:388#include "ui/gfx/platform_font.h"
[email protected]c6ac8412010-08-13 16:43:039
10namespace gfx {
11
12////////////////////////////////////////////////////////////////////////////////
13// Font, public:
14
15Font::Font() : platform_font_(PlatformFont::CreateDefault()) {
16}
17
18Font::Font(const Font& other) : platform_font_(other.platform_font_) {
19}
20
21gfx::Font& Font::operator=(const Font& other) {
22 platform_font_ = other.platform_font_;
23 return *this;
24}
25
26Font::Font(NativeFont native_font)
27 : platform_font_(PlatformFont::CreateFromNativeFont(native_font)) {
28}
29
30Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) {
31}
32
[email protected]76fcc3e2011-01-12 16:24:4533Font::Font(const string16& font_name, int font_size)
[email protected]c6ac8412010-08-13 16:43:0334 : platform_font_(PlatformFont::CreateFromNameAndSize(font_name,
35 font_size)) {
36}
37
38Font::~Font() {
39}
40
41Font Font::DeriveFont(int size_delta) const {
42 return DeriveFont(size_delta, GetStyle());
43}
44
45Font Font::DeriveFont(int size_delta, int style) const {
46 return platform_font_->DeriveFont(size_delta, style);
47}
48
49int Font::GetHeight() const {
50 return platform_font_->GetHeight();
51}
52
53int Font::GetBaseline() const {
54 return platform_font_->GetBaseline();
55}
56
57int Font::GetAverageCharacterWidth() const {
58 return platform_font_->GetAverageCharacterWidth();
59}
60
[email protected]13658c42011-01-04 20:46:1461int Font::GetStringWidth(const string16& text) const {
62 return platform_font_->GetStringWidth(text);
[email protected]c6ac8412010-08-13 16:43:0363}
64
65int Font::GetExpectedTextWidth(int length) const {
66 return platform_font_->GetExpectedTextWidth(length);
67}
68
69int Font::GetStyle() const {
70 return platform_font_->GetStyle();
71}
72
[email protected]76fcc3e2011-01-12 16:24:4573string16 Font::GetFontName() const {
[email protected]c6ac8412010-08-13 16:43:0374 return platform_font_->GetFontName();
75}
76
77int Font::GetFontSize() const {
78 return platform_font_->GetFontSize();
79}
80
81NativeFont Font::GetNativeFont() const {
82 return platform_font_->GetNativeFont();
83}
84
85} // namespace gfx