Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: ui/gfx/render_text.h

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Alexei's issues Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/gfx/render_text.h
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index 5913f4dcb68cb40b63885d37f6b788aaef8f8069..9cc003d505679964cde751dec50230bc06a462d3 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -62,7 +62,7 @@ class GFX_EXPORT SkiaTextRenderer {
bool subpixel_rendering_suppressed);
void SetTypeface(SkTypeface* typeface);
void SetTextSize(SkScalar size);
- void SetFontWithStyle(const Font& font, int font_style);
+ void SetFont(const Font& font, bool italic, gfx::Font::Weight weight);
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
void SetForegroundColor(SkColor foreground);
void SetShader(sk_sp<SkShader> shader);
// Sets underline metrics to use if the text will be drawn with an underline.
@@ -123,6 +123,7 @@ class StyleIterator {
public:
StyleIterator(const BreakList<SkColor>& colors,
const BreakList<BaselineStyle>& baselines,
+ const BreakList<gfx::Font::Weight>& weights,
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
const std::vector<BreakList<bool>>& styles);
~StyleIterator();
@@ -130,6 +131,7 @@ class StyleIterator {
SkColor color() const { return color_->second; }
BaselineStyle baseline() const { return baseline_->second; }
bool style(TextStyle s) const { return style_[s]->second; }
+ gfx::Font::Weight weight() const { return weight_->second; }
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
// Get the intersecting range of the current iterator set.
Range GetRange() const;
@@ -140,10 +142,12 @@ class StyleIterator {
private:
BreakList<SkColor> colors_;
BreakList<BaselineStyle> baselines_;
+ BreakList<gfx::Font::Weight> weights_;
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
std::vector<BreakList<bool> > styles_;
BreakList<SkColor>::const_iterator color_;
BreakList<BaselineStyle>::const_iterator baseline_;
+ BreakList<gfx::Font::Weight>::const_iterator weight_;
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
std::vector<BreakList<bool>::const_iterator> style_;
DISALLOW_COPY_AND_ASSIGN(StyleIterator);
@@ -186,9 +190,10 @@ struct Line {
int baseline;
};
-// Creates an SkTypeface from a font and a |gfx::Font::FontStyle|.
-// May return NULL.
-skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font, int style);
+// Creates an SkTypeface from a font, italic flag and weight. May return NULL.
+skia::RefPtr<SkTypeface> CreateSkiaTypeface(const gfx::Font& font,
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
+ bool italic,
+ gfx::Font::Weight weight);
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
// Applies the given FontRenderParams to a Skia |paint|.
void ApplyRenderParams(const FontRenderParams& params,
@@ -363,6 +368,9 @@ class GFX_EXPORT RenderText {
void SetStyle(TextStyle style, bool value);
void ApplyStyle(TextStyle style, bool value, const Range& range);
+ void SetWeight(gfx::Font::Weight weight);
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
+ void ApplyWeight(gfx::Font::Weight weight, const Range& range);
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
+
// Returns whether this style is enabled consistently across the entire
// RenderText.
bool GetStyle(TextStyle style) const;
@@ -486,6 +494,7 @@ class GFX_EXPORT RenderText {
const BreakList<SkColor>& colors() const { return colors_; }
const BreakList<BaselineStyle>& baselines() const { return baselines_; }
+ const BreakList<gfx::Font::Weight>& weights() const { return weights_; }
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
const std::vector<BreakList<bool> >& styles() const { return styles_; }
const std::vector<internal::Line>& lines() const { return lines_; }
@@ -741,6 +750,7 @@ class GFX_EXPORT RenderText {
// TODO(msw): Expand to support cursor, selection, background, etc. colors.
BreakList<SkColor> colors_;
BreakList<BaselineStyle> baselines_;
+ BreakList<gfx::Font::Weight> weights_;
Alexei Svitkine (slow) 2016/04/05 16:38:53 Remove gfx::
std::vector<BreakList<bool> > styles_;
// Breaks saved without temporary composition and selection styling.

Powered by Google App Engine
This is Rietveld 408576698