Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_FONT_RENDER_PARAMS_H_ | 5 #ifndef UI_GFX_FONT_RENDER_PARAMS_H_ |
| 6 #define UI_GFX_FONT_RENDER_PARAMS_H_ | 6 #define UI_GFX_FONT_RENDER_PARAMS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 std::vector<std::string> families; | 77 std::vector<std::string> families; |
| 78 | 78 |
| 79 // Font size in pixels or points, or 0 if unset. | 79 // Font size in pixels or points, or 0 if unset. |
| 80 int pixel_size; | 80 int pixel_size; |
| 81 int point_size; | 81 int point_size; |
| 82 | 82 |
| 83 // gfx::Font::FontStyle bit field, or -1 if unset. | 83 // gfx::Font::FontStyle bit field, or -1 if unset. |
| 84 int style; | 84 int style; |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 // This class is used to modify the FontRenderParams based on the current | |
| 88 // status of the system. | |
| 89 class GFX_EXPORT FontRenderParamsRewriter { | |
|
Daniel Erat
2014/12/09 16:24:35
i don't think i like this being a general interfac
Jun Mukai
2014/12/12 00:04:49
Removed this class.
| |
| 90 public: | |
| 91 // Gets/sets/removes the singleton instance. These are safe if instance is not | |
| 92 // set yet. | |
| 93 static FontRenderParamsRewriter* GetInstance(); | |
| 94 static void SetInstance(FontRenderParamsRewriter* instance); | |
| 95 static void Shutdown(); | |
| 96 | |
| 97 virtual ~FontRenderParamsRewriter(); | |
| 98 | |
| 99 // Rewrite the FontRenderParams based on the current system configuration. | |
| 100 virtual void RewriteParams(FontRenderParams* params) = 0; | |
| 101 }; | |
| 102 | |
| 87 // Returns the appropriate parameters for rendering the font described by | 103 // Returns the appropriate parameters for rendering the font described by |
| 88 // |query|. If |family_out| is non-NULL, it will be updated to contain the | 104 // |query|. If |family_out| is non-NULL, it will be updated to contain the |
| 89 // recommended font family from |query.families|. | 105 // recommended font family from |query.families|. |
| 90 GFX_EXPORT FontRenderParams GetFontRenderParams( | 106 // The return value should not be cached, because the result is already |
| 91 const FontRenderParamsQuery& query, | 107 // rewritten by the current FontRenderParamsRewriter instance. To cache the |
| 92 std::string* family_out); | 108 // parameters, consider using GetSystemFontRenderParams() below and rewrite |
| 109 // the result by yourself. | |
| 110 GFX_EXPORT FontRenderParams | |
| 111 GetCurrentFontRenderParams(const FontRenderParamsQuery& query, | |
| 112 std::string* family_out); | |
| 113 | |
| 114 // Returns the appropriate parameters for rendering the font described by | |
| 115 // |query|. This is similar to GetCurrentFontRenderParams(), but the return | |
| 116 // value is not yet rewritten by FontRenderParamsRewirter, hence it can be | |
| 117 // cached. | |
| 118 GFX_EXPORT FontRenderParams | |
| 119 GetSystemFontRenderParams(const FontRenderParamsQuery& query, | |
| 120 std::string* family_out); | |
| 93 | 121 |
| 94 // Clears GetFontRenderParams()'s cache. Intended to be called by tests that are | 122 // Clears GetFontRenderParams()'s cache. Intended to be called by tests that are |
| 95 // changing Fontconfig's configuration. | 123 // changing Fontconfig's configuration. |
| 96 // TODO(derat): This is only defined for Linux, but OS_LINUX doesn't seem to be | 124 // TODO(derat): This is only defined for Linux, but OS_LINUX doesn't seem to be |
| 97 // set when font_render_params_linux_unittest.cc includes this header. Figure | 125 // set when font_render_params_linux_unittest.cc includes this header. Figure |
| 98 // out what's going on here. | 126 // out what's going on here. |
| 99 GFX_EXPORT void ClearFontRenderParamsCacheForTest(); | 127 GFX_EXPORT void ClearFontRenderParamsCacheForTest(); |
| 100 | 128 |
| 101 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 102 // Sets the device scale factor for FontRenderParams to decide | 130 // Sets the device scale factor for FontRenderParams to decide |
| 103 // if it should enable subpixel positioning. | 131 // if it should enable subpixel positioning. |
| 104 GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor( | 132 GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor( |
| 105 float device_scale_factor); | 133 float device_scale_factor); |
| 106 #endif | 134 #endif |
| 107 | 135 |
| 108 } // namespace gfx | 136 } // namespace gfx |
| 109 | 137 |
| 110 #endif // UI_GFX_FONT_RENDER_PARAMS_H_ | 138 #endif // UI_GFX_FONT_RENDER_PARAMS_H_ |
| OLD | NEW |