#ifndef UI_GFX_FONT_RENDER_PARAMS_H_
#define UI_GFX_FONT_RENDER_PARAMS_H_
#include <string>
#include <vector>
#include "build/build_config.h"
#include "device/vr/buildflags/buildflags.h"
#include "third_party/skia/include/core/SkSurfaceProps.h"
#include "ui/gfx/font.h"
#include "ui/gfx/gfx_export.h"
namespace gfx {
struct GFX_EXPORT FontRenderParams {
bool operator==(const FontRenderParams& other) const {
return antialiasing == other.antialiasing &&
subpixel_positioning == other.subpixel_positioning &&
autohinter == other.autohinter && use_bitmaps == other.use_bitmaps &&
hinting == other.hinting &&
subpixel_rendering == other.subpixel_rendering;
}
enum Hinting {
HINTING_NONE = 0,
HINTING_SLIGHT,
HINTING_MEDIUM,
HINTING_FULL,
HINTING_MAX = HINTING_FULL,
};
enum SubpixelRendering {
SUBPIXEL_RENDERING_NONE = 0,
SUBPIXEL_RENDERING_RGB,
SUBPIXEL_RENDERING_BGR,
SUBPIXEL_RENDERING_VRGB,
SUBPIXEL_RENDERING_VBGR,
SUBPIXEL_RENDERING_MAX = SUBPIXEL_RENDERING_VBGR,
};
bool antialiasing = true;
bool subpixel_positioning = true;
bool autohinter = false;
bool use_bitmaps = false;
Hinting hinting = HINTING_MEDIUM;
SubpixelRendering subpixel_rendering = SUBPIXEL_RENDERING_NONE;
static SkPixelGeometry SubpixelRenderingToSkiaPixelGeometry(
SubpixelRendering subpixel_rendering);
};
struct GFX_EXPORT FontRenderParamsQuery {
FontRenderParamsQuery();
FontRenderParamsQuery(const FontRenderParamsQuery& other);
~FontRenderParamsQuery();
bool is_empty() const {
return families.empty() && pixel_size <= 0 && point_size <= 0 && style < 0;
}
std::vector<std::string> families;
int pixel_size;
int point_size;
int style;
Font::Weight weight;
float device_scale_factor;
};
GFX_EXPORT FontRenderParams GetFontRenderParams(
const FontRenderParamsQuery& query,
std::string* family_out);
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
GFX_EXPORT void ClearFontRenderParamsCacheForTest();
#endif
GFX_EXPORT float GetFontRenderParamsDeviceScaleFactor();
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \
BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_FUCHSIA)
GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor(
float device_scale_factor);
#endif
}
#endif