Implement MoveFileLocal (with creating a snapshot).
[chromium-blink-merge.git] / ui / gfx / font_render_params.h
blob977a4955c021fac22f9aa834964a9f3a851d208a
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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_FONT_RENDER_PARAMS_H_
6 #define UI_GFX_FONT_RENDER_PARAMS_H_
8 #include <string>
9 #include <vector>
11 #include "ui/gfx/gfx_export.h"
13 namespace gfx {
15 // A collection of parameters describing how text should be rendered on Linux.
16 struct GFX_EXPORT FontRenderParams {
17 FontRenderParams();
18 ~FontRenderParams();
20 // Level of hinting to be applied.
21 enum Hinting {
22 HINTING_NONE = 0,
23 HINTING_SLIGHT,
24 HINTING_MEDIUM,
25 HINTING_FULL,
28 // Different subpixel orders to be used for subpixel rendering.
29 enum SubpixelRendering {
30 SUBPIXEL_RENDERING_NONE = 0,
31 SUBPIXEL_RENDERING_RGB,
32 SUBPIXEL_RENDERING_BGR,
33 SUBPIXEL_RENDERING_VRGB,
34 SUBPIXEL_RENDERING_VBGR,
37 // Antialiasing (grayscale if |subpixel_rendering| is SUBPIXEL_RENDERING_NONE
38 // and RGBA otherwise).
39 bool antialiasing;
41 // Should subpixel positioning (i.e. fractional X positions for glyphs) be
42 // used?
43 // TODO(derat): Remove this; we don't set it in the browser and mostly ignore
44 // it in Blink: http://crbug.com/396659
45 bool subpixel_positioning;
47 // Should FreeType's autohinter be used (as opposed to Freetype's bytecode
48 // interpreter, which uses fonts' own hinting instructions)?
49 bool autohinter;
51 // Should embedded bitmaps in fonts should be used?
52 bool use_bitmaps;
54 // Hinting level.
55 Hinting hinting;
57 // Whether subpixel rendering should be used or not, and if so, the display's
58 // subpixel order.
59 SubpixelRendering subpixel_rendering;
62 // A query used to determine the appropriate FontRenderParams.
63 struct GFX_EXPORT FontRenderParamsQuery {
64 explicit FontRenderParamsQuery(bool for_web_contents);
65 ~FontRenderParamsQuery();
67 bool is_empty() const {
68 return families.empty() && pixel_size <= 0 && point_size <= 0 && style < 0;
71 // True if rendering text for the web.
72 // TODO(derat): Remove this once FontRenderParams::subpixel_positioning is
73 // gone: http://crbug.com/396659
74 bool for_web_contents;
76 // Requested font families, or empty if unset.
77 std::vector<std::string> families;
79 // Font size in pixels or points, or 0 if unset.
80 int pixel_size;
81 int point_size;
83 // gfx::Font::FontStyle bit field, or -1 if unset.
84 int style;
86 // The device scale factor of the display, or 0 if unset.
87 float device_scale_factor;
90 // Returns the appropriate parameters for rendering the font described by
91 // |query|. If |family_out| is non-NULL, it will be updated to contain the
92 // recommended font family from |query.families|.
93 GFX_EXPORT FontRenderParams GetFontRenderParams(
94 const FontRenderParamsQuery& query,
95 std::string* family_out);
97 // Clears GetFontRenderParams()'s cache. Intended to be called by tests that are
98 // changing Fontconfig's configuration.
99 // TODO(derat): This is only defined for Linux, but OS_LINUX doesn't seem to be
100 // set when font_render_params_linux_unittest.cc includes this header. Figure
101 // out what's going on here.
102 GFX_EXPORT void ClearFontRenderParamsCacheForTest();
104 #if defined(OS_CHROMEOS)
105 // Gets the device scale factor to query the FontRenderParams.
106 float GetFontRenderParamsDeviceScaleFactor();
108 // Sets the device scale factor for FontRenderParams to decide
109 // if it should enable subpixel positioning.
110 GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor(
111 float device_scale_factor);
112 #endif
114 } // namespace gfx
116 #endif // UI_GFX_FONT_RENDER_PARAMS_H_