[Cronet] Delay StartNetLog and StopNetLog until native request context is initialized
[chromium-blink-merge.git] / ui / gfx / font.cc
blob915db076cc59c66f303ec790cd8cfcde5ae5f6a2
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"
10 namespace gfx {
12 ////////////////////////////////////////////////////////////////////////////////
13 // Font, public:
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_;
23 return *this;
26 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS)
27 Font::Font(NativeFont native_font)
28 : platform_font_(PlatformFont::CreateFromNativeFont(native_font)) {
30 #endif
32 Font::Font(PlatformFont* platform_font) : platform_font_(platform_font) {
35 Font::Font(const std::string& font_name, int font_size)
36 : platform_font_(PlatformFont::CreateFromNameAndSize(font_name,
37 font_size)) {
40 Font::~Font() {
43 Font Font::Derive(int size_delta, int style) const {
44 return platform_font_->DeriveFont(size_delta, style);
47 int Font::GetHeight() const {
48 return platform_font_->GetHeight();
51 int Font::GetBaseline() const {
52 return platform_font_->GetBaseline();
55 int Font::GetCapHeight() const {
56 return platform_font_->GetCapHeight();
59 int Font::GetExpectedTextWidth(int length) const {
60 return platform_font_->GetExpectedTextWidth(length);
63 int Font::GetStyle() const {
64 return platform_font_->GetStyle();
67 std::string Font::GetFontName() const {
68 return platform_font_->GetFontName();
71 std::string Font::GetActualFontNameForTesting() const {
72 return platform_font_->GetActualFontNameForTesting();
75 int Font::GetFontSize() const {
76 return platform_font_->GetFontSize();
79 const FontRenderParams& Font::GetFontRenderParams() const {
80 return platform_font_->GetFontRenderParams();
83 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_IOS)
84 NativeFont Font::GetNativeFont() const {
85 return platform_font_->GetNativeFont();
87 #endif
89 } // namespace gfx