Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_GFX_PLATFORM_FONT_LINUX_H_ | 5 #ifndef UI_GFX_PLATFORM_FONT_LINUX_H_ |
| 6 #define UI_GFX_PLATFORM_FONT_LINUX_H_ | 6 #define UI_GFX_PLATFORM_FONT_LINUX_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 // the locale has changed. | 34 // the locale has changed. |
| 35 static void ReloadDefaultFont(); | 35 static void ReloadDefaultFont(); |
| 36 | 36 |
| 37 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
| 38 // Sets the default font. |font_description| is a gfx::FontList font | 38 // Sets the default font. |font_description| is a gfx::FontList font |
| 39 // description; only the first family will be used. | 39 // description; only the first family will be used. |
| 40 static void SetDefaultFontDescription(const std::string& font_description); | 40 static void SetDefaultFontDescription(const std::string& font_description); |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 // Overridden from PlatformFont: | 43 // Overridden from PlatformFont: |
| 44 Font DeriveFont(int size_delta, int style) const override; | 44 Font DeriveFont(int size_delta, |
| 45 int style, | |
| 46 gfx::Font::Weight weight) const override; | |
| 45 int GetHeight() override; | 47 int GetHeight() override; |
| 48 gfx::Font::Weight GetWeight() const override; | |
|
Alexei Svitkine (slow)
2016/04/04 16:34:51
Remove gfx:: since this in gfx:: namespace. Please
Mikus
2016/04/05 16:18:34
Done.
| |
| 46 int GetBaseline() override; | 49 int GetBaseline() override; |
| 47 int GetCapHeight() override; | 50 int GetCapHeight() override; |
| 48 int GetExpectedTextWidth(int length) override; | 51 int GetExpectedTextWidth(int length) override; |
| 49 int GetStyle() const override; | 52 int GetStyle() const override; |
| 50 const std::string& GetFontName() const override; | 53 const std::string& GetFontName() const override; |
| 51 std::string GetActualFontNameForTesting() const override; | 54 std::string GetActualFontNameForTesting() const override; |
| 52 int GetFontSize() const override; | 55 int GetFontSize() const override; |
| 53 const FontRenderParams& GetFontRenderParams() override; | 56 const FontRenderParams& GetFontRenderParams() override; |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // Create a new instance of this object with the specified properties. Called | 59 // Create a new instance of this object with the specified properties. Called |
| 57 // from DeriveFont. | 60 // from DeriveFont. |
| 58 PlatformFontLinux(const skia::RefPtr<SkTypeface>& typeface, | 61 PlatformFontLinux(const skia::RefPtr<SkTypeface>& typeface, |
| 59 const std::string& family, | 62 const std::string& family, |
| 60 int size_pixels, | 63 int size_pixels, |
| 61 int style, | 64 bool italic, |
| 65 gfx::Font::Weight weight, | |
|
Alexei Svitkine (slow)
2016/04/04 16:34:51
Remove gfx::
Mikus
2016/04/05 16:18:34
Done.
| |
| 62 const FontRenderParams& params); | 66 const FontRenderParams& params); |
| 63 ~PlatformFontLinux() override; | 67 ~PlatformFontLinux() override; |
| 64 | 68 |
| 65 // Initializes this object based on the passed-in details. If |typeface| is | 69 // Initializes this object based on the passed-in details. If |typeface| is |
| 66 // empty, a new typeface will be loaded. | 70 // empty, a new typeface will be loaded. |
| 67 void InitFromDetails( | 71 void InitFromDetails(const skia::RefPtr<SkTypeface>& typeface, |
| 68 const skia::RefPtr<SkTypeface>& typeface, | 72 const std::string& font_family, |
| 69 const std::string& font_family, | 73 int font_size_pixels, |
| 70 int font_size_pixels, | 74 bool italic, |
| 71 int style, | 75 gfx::Font::Weight weight, |
|
Alexei Svitkine (slow)
2016/04/04 16:34:51
Remove gfx::
Mikus
2016/04/05 16:18:34
Done.
| |
| 72 const FontRenderParams& params); | 76 const FontRenderParams& params); |
| 73 | 77 |
| 74 // Initializes this object as a copy of another PlatformFontLinux. | 78 // Initializes this object as a copy of another PlatformFontLinux. |
| 75 void InitFromPlatformFont(const PlatformFontLinux* other); | 79 void InitFromPlatformFont(const PlatformFontLinux* other); |
| 76 | 80 |
| 77 // Computes the metrics if they have not yet been computed. | 81 // Computes the metrics if they have not yet been computed. |
| 78 void ComputeMetricsIfNecessary(); | 82 void ComputeMetricsIfNecessary(); |
| 79 | 83 |
| 80 skia::RefPtr<SkTypeface> typeface_; | 84 skia::RefPtr<SkTypeface> typeface_; |
| 81 | 85 |
| 82 // Additional information about the face. | 86 // Additional information about the face. |
| 83 // Skia actually expects a family name and not a font name. | 87 // Skia actually expects a family name and not a font name. |
| 84 std::string font_family_; | 88 std::string font_family_; |
| 85 int font_size_pixels_; | 89 int font_size_pixels_; |
| 86 int style_; | 90 bool italic_; |
| 87 #if defined(OS_CHROMEOS) | 91 #if defined(OS_CHROMEOS) |
| 88 float device_scale_factor_; | 92 float device_scale_factor_; |
| 89 #endif | 93 #endif |
| 90 | 94 |
| 91 // Information describing how the font should be rendered. | 95 // Information describing how the font should be rendered. |
| 92 FontRenderParams font_render_params_; | 96 FontRenderParams font_render_params_; |
| 93 | 97 |
| 94 // Cached metrics, generated on demand. | 98 // Cached metrics, generated on demand. |
| 95 bool metrics_need_computation_ = true; | 99 bool metrics_need_computation_ = true; |
| 96 int ascent_pixels_; | 100 int ascent_pixels_; |
| 97 int height_pixels_; | 101 int height_pixels_; |
| 98 int cap_height_pixels_; | 102 int cap_height_pixels_; |
| 99 double average_width_pixels_; | 103 double average_width_pixels_; |
| 104 gfx::Font::Weight weight_; | |
| 100 | 105 |
| 101 #if defined(OS_CHROMEOS) | 106 #if defined(OS_CHROMEOS) |
| 102 // A font description string of the format used by gfx::FontList. | 107 // A font description string of the format used by gfx::FontList. |
| 103 static std::string* default_font_description_; | 108 static std::string* default_font_description_; |
| 104 #endif | 109 #endif |
| 105 | 110 |
| 106 DISALLOW_COPY_AND_ASSIGN(PlatformFontLinux); | 111 DISALLOW_COPY_AND_ASSIGN(PlatformFontLinux); |
| 107 }; | 112 }; |
| 108 | 113 |
| 109 } // namespace gfx | 114 } // namespace gfx |
| 110 | 115 |
| 111 #endif // UI_GFX_PLATFORM_FONT_LINUX_H_ | 116 #endif // UI_GFX_PLATFORM_FONT_LINUX_H_ |
| OLD | NEW |