Make UsbEventRouter depend explicitly on EventRouter.
[chromium-blink-merge.git] / ui / gfx / font_render_params.h
blob8febd661fd233edb3c8f2c11f80971511b460984
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 "third_party/skia/include/core/SkFontHost.h"
12 #include "ui/gfx/gfx_export.h"
14 namespace gfx {
16 // A collection of parameters describing how text should be rendered on Linux.
17 struct GFX_EXPORT FontRenderParams {
18 FontRenderParams();
19 ~FontRenderParams();
21 // Level of hinting to be applied.
22 enum Hinting {
23 HINTING_NONE = 0,
24 HINTING_SLIGHT,
25 HINTING_MEDIUM,
26 HINTING_FULL,
28 HINTING_MAX = HINTING_FULL,
31 // Different subpixel orders to be used for subpixel rendering.
32 enum SubpixelRendering {
33 SUBPIXEL_RENDERING_NONE = 0,
34 SUBPIXEL_RENDERING_RGB,
35 SUBPIXEL_RENDERING_BGR,
36 SUBPIXEL_RENDERING_VRGB,
37 SUBPIXEL_RENDERING_VBGR,
39 SUBPIXEL_RENDERING_MAX = SUBPIXEL_RENDERING_VBGR,
42 // Antialiasing (grayscale if |subpixel_rendering| is SUBPIXEL_RENDERING_NONE
43 // and RGBA otherwise).
44 bool antialiasing;
46 // Should subpixel positioning (i.e. fractional X positions for glyphs) be
47 // used?
48 // TODO(derat): Remove this; we don't set it in the browser and mostly ignore
49 // it in Blink: http://crbug.com/396659
50 bool subpixel_positioning;
52 // Should FreeType's autohinter be used (as opposed to Freetype's bytecode
53 // interpreter, which uses fonts' own hinting instructions)?
54 bool autohinter;
56 // Should embedded bitmaps in fonts should be used?
57 bool use_bitmaps;
59 // Hinting level.
60 Hinting hinting;
62 // Whether subpixel rendering should be used or not, and if so, the display's
63 // subpixel order.
64 SubpixelRendering subpixel_rendering;
66 static SkFontHost::LCDOrder SubpixelRenderingToSkiaLCDOrder(
67 SubpixelRendering subpixel_rendering);
68 static SkFontHost::LCDOrientation SubpixelRenderingToSkiaLCDOrientation(
69 SubpixelRendering subpixel_rendering);
72 // A query used to determine the appropriate FontRenderParams.
73 struct GFX_EXPORT FontRenderParamsQuery {
74 FontRenderParamsQuery();
75 ~FontRenderParamsQuery();
77 bool is_empty() const {
78 return families.empty() && pixel_size <= 0 && point_size <= 0 && style < 0;
81 // Requested font families, or empty if unset.
82 std::vector<std::string> families;
84 // Font size in pixels or points, or 0 if unset.
85 int pixel_size;
86 int point_size;
88 // gfx::Font::FontStyle bit field, or -1 if unset.
89 int style;
91 // The device scale factor of the display, or 0 if unset.
92 float device_scale_factor;
95 // Returns the appropriate parameters for rendering the font described by
96 // |query|. If |family_out| is non-NULL, it will be updated to contain the
97 // recommended font family from |query.families|.
98 GFX_EXPORT FontRenderParams GetFontRenderParams(
99 const FontRenderParamsQuery& query,
100 std::string* family_out);
102 // Clears GetFontRenderParams()'s cache. Intended to be called by tests that are
103 // changing Fontconfig's configuration.
104 // TODO(derat): This is only defined for Linux, but OS_LINUX doesn't seem to be
105 // set when font_render_params_linux_unittest.cc includes this header. Figure
106 // out what's going on here.
107 GFX_EXPORT void ClearFontRenderParamsCacheForTest();
109 #if defined(OS_CHROMEOS)
110 // Gets the device scale factor to query the FontRenderParams.
111 float GetFontRenderParamsDeviceScaleFactor();
113 // Sets the device scale factor for FontRenderParams to decide
114 // if it should enable subpixel positioning.
115 GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor(
116 float device_scale_factor);
117 #endif
119 } // namespace gfx
121 #endif // UI_GFX_FONT_RENDER_PARAMS_H_