Fix/enable proper font weight selection.

Change-Id: I3cd1eb7758708d90a6c99384cb336c65c1e5c5c3
This commit is contained in:
Gary Qian 2017-07-12 17:06:59 -07:00
parent 97e0ba1bdf
commit 8c0962d728
5 changed files with 5 additions and 9 deletions

View File

@ -169,7 +169,7 @@ FontCollection::GetMinikinFontCollectionForFamily(const std::string& family) {
// Create the minikin font from the skia typeface.
minikin::Font minikin_font(
std::make_shared<FontSkia>(skia_typeface),
minikin::FontStyle{skia_typeface->fontStyle().weight(),
minikin::FontStyle{skia_typeface->fontStyle().weight() / 100,
skia_typeface->isItalic()});
minikin_fonts.emplace_back(std::move(minikin_font));

View File

@ -104,7 +104,6 @@ void GetFontAndMinikinPaint(const TextStyle& style,
void GetPaint(const TextStyle& style, SkPaint* paint) {
paint->setTextSize(style.font_size);
paint->setFakeBoldText(style.fake_bold);
}
} // namespace

View File

@ -36,8 +36,6 @@ bool TextStyle::equals(const TextStyle& other) const {
return false;
if (font_style != other.font_style)
return false;
if (fake_bold != other.fake_bold)
return false;
if (font_family != other.font_family)
return false;
if (letter_spacing != other.letter_spacing)

View File

@ -36,7 +36,6 @@ class TextStyle {
double decoration_thickness = 1.0;
FontWeight font_weight = FontWeight::w400;
FontStyle font_style = FontStyle::normal;
bool fake_bold = false;
TextBaseline text_baseline = TextBaseline::kAlphabetic;
std::string font_family = "";
double font_size = 14.0;

View File

@ -136,7 +136,6 @@ TEST_F(RenderTest, RainbowParagraph) {
text_style2.letter_spacing = 10;
text_style2.word_spacing = 30;
text_style2.font_weight = txt::FontWeight::w600;
text_style2.fake_bold = true;
text_style2.color = SK_ColorGREEN;
text_style2.decoration = txt::TextDecoration(0x1 | 0x2 | 0x4);
text_style2.decoration_color = SK_ColorBLACK;
@ -229,10 +228,10 @@ TEST_F(RenderTest, BoldParagraph) {
txt::ParagraphBuilder builder(paragraph_style, &font_collection);
txt::TextStyle text_style;
text_style.font_family = "Roboto";
text_style.font_size = 60;
text_style.letter_spacing = 10;
text_style.font_weight = txt::FontWeight::w700;
text_style.fake_bold = true;
text_style.letter_spacing = 0;
text_style.font_weight = txt::FontWeight::w900;
text_style.color = SK_ColorRED;
builder.PushStyle(text_style);
@ -927,6 +926,7 @@ TEST_F(RenderTest, GetRectsForRangeParagraph) {
txt::TextStyle text_style;
text_style.font_size = 50;
text_style.letter_spacing = 0;
text_style.font_weight = FontWeight::w500;
text_style.word_spacing = 0;
text_style.color = SK_ColorBLACK;
text_style.height = 1;