[Cronet] Delay StartNetLog and StopNetLog until native request context is initialized
[chromium-blink-merge.git] / ui / gfx / font_render_params.h
blob0bf10d468382232709bb5442894d217e57484b44
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,
29 // Different subpixel orders to be used for subpixel rendering.
30 enum SubpixelRendering {
31 SUBPIXEL_RENDERING_NONE = 0,
32 SUBPIXEL_RENDERING_RGB,
33 SUBPIXEL_RENDERING_BGR,
34 SUBPIXEL_RENDERING_VRGB,
35 SUBPIXEL_RENDERING_VBGR,
38 // Antialiasing (grayscale if |subpixel_rendering| is SUBPIXEL_RENDERING_NONE
39 // and RGBA otherwise).
40 bool antialiasing;
42 // Should subpixel positioning (i.e. fractional X positions for glyphs) be
43 // used?
44 // TODO(derat): Remove this; we don't set it in the browser and mostly ignore
45 // it in Blink: http://crbug.com/396659
46 bool subpixel_positioning;
48 // Should FreeType's autohinter be used (as opposed to Freetype's bytecode
49 // interpreter, which uses fonts' own hinting instructions)?
50 bool autohinter;
52 // Should embedded bitmaps in fonts should be used?
53 bool use_bitmaps;
55 // Hinting level.
56 Hinting hinting;
58 // Whether subpixel rendering should be used or not, and if so, the display's
59 // subpixel order.
60 SubpixelRendering subpixel_rendering;
62 static SkFontHost::LCDOrder SubpixelRenderingToSkiaLCDOrder(
63 SubpixelRendering subpixel_rendering);
64 static SkFontHost::LCDOrientation SubpixelRenderingToSkiaLCDOrientation(
65 SubpixelRendering subpixel_rendering);
68 // A query used to determine the appropriate FontRenderParams.
69 struct GFX_EXPORT FontRenderParamsQuery {
70 explicit FontRenderParamsQuery(bool for_web_contents);
71 ~FontRenderParamsQuery();
73 bool is_empty() const {
74 return families.empty() && pixel_size <= 0 && point_size <= 0 && style < 0;
77 // True if rendering text for the web.
78 // TODO(derat): Remove this once FontRenderParams::subpixel_positioning is
79 // gone: http://crbug.com/396659
80 bool for_web_contents;
82 // Requested font families, or empty if unset.
83 std::vector<std::string> families;
85 // Font size in pixels or points, or 0 if unset.
86 int pixel_size;
87 int point_size;
89 // gfx::Font::FontStyle bit field, or -1 if unset.
90 int style;
92 // The device scale factor of the display, or 0 if unset.
93 float device_scale_factor;
96 // Returns the appropriate parameters for rendering the font described by
97 // |query|. If |family_out| is non-NULL, it will be updated to contain the
98 // recommended font family from |query.families|.
99 GFX_EXPORT FontRenderParams GetFontRenderParams(
100 const FontRenderParamsQuery& query,
101 std::string* family_out);
103 // Clears GetFontRenderParams()'s cache. Intended to be called by tests that are
104 // changing Fontconfig's configuration.
105 // TODO(derat): This is only defined for Linux, but OS_LINUX doesn't seem to be
106 // set when font_render_params_linux_unittest.cc includes this header. Figure
107 // out what's going on here.
108 GFX_EXPORT void ClearFontRenderParamsCacheForTest();
110 #if defined(OS_CHROMEOS)
111 // Gets the device scale factor to query the FontRenderParams.
112 float GetFontRenderParamsDeviceScaleFactor();
114 // Sets the device scale factor for FontRenderParams to decide
115 // if it should enable subpixel positioning.
116 GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor(
117 float device_scale_factor);
118 #endif
120 } // namespace gfx
122 #endif // UI_GFX_FONT_RENDER_PARAMS_H_