| Index: ui/gfx/render_text.cc
|
| diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc
|
| index 7019918df3959526af5504e2f57a75ee02ec8cd5..29b2e8e3bf1d795b4d60b92b3a2dba1370814ac9 100644
|
| --- a/ui/gfx/render_text.cc
|
| +++ b/ui/gfx/render_text.cc
|
| @@ -90,6 +90,16 @@
|
| return baseline + std::max(min_shift, std::min(max_shift, baseline_shift));
|
| }
|
|
|
| +#if !defined(OS_MACOSX)
|
| +// Converts |Font::FontStyle| flags to |SkTypeface::Style| flags.
|
| +SkTypeface::Style ConvertFontStyleToSkiaTypefaceStyle(int font_style) {
|
| + int skia_style = SkTypeface::kNormal;
|
| + skia_style |= (font_style & Font::BOLD) ? SkTypeface::kBold : 0;
|
| + skia_style |= (font_style & Font::ITALIC) ? SkTypeface::kItalic : 0;
|
| + return static_cast<SkTypeface::Style>(skia_style);
|
| +}
|
| +#endif
|
| +
|
| int round(float value) {
|
| return static_cast<int>(floor(value + 0.5f));
|
| }
|
| @@ -247,6 +257,18 @@
|
| paint_.setTextSize(size);
|
| }
|
|
|
| +void SkiaTextRenderer::SetFontWithStyle(const Font& font, int style) {
|
| + skia::RefPtr<SkTypeface> typeface = CreateSkiaTypeface(font, style);
|
| + if (typeface) {
|
| + // |paint_| adds its own ref. So don't |release()| it from the ref ptr here.
|
| + SetTypeface(typeface.get());
|
| +
|
| + // Enable fake bold text if bold style is needed but new typeface does not
|
| + // have it.
|
| + paint_.setFakeBoldText((style & Font::BOLD) && !typeface->isBold());
|
| + }
|
| +}
|
| +
|
| void SkiaTextRenderer::SetForegroundColor(SkColor foreground) {
|
| paint_.setColor(foreground);
|
| }
|
| @@ -400,6 +422,14 @@
|
| Line::Line(const Line& other) = default;
|
|
|
| Line::~Line() {}
|
| +
|
| +#if !defined(OS_MACOSX)
|
| +skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style) {
|
| + SkTypeface::Style skia_style = ConvertFontStyleToSkiaTypefaceStyle(style);
|
| + return skia::AdoptRef(
|
| + SkTypeface::CreateFromName(font.GetFontName().c_str(), skia_style));
|
| +}
|
| +#endif
|
|
|
| void ApplyRenderParams(const FontRenderParams& params,
|
| bool subpixel_rendering_suppressed,
|
|
|