Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion modules/skparagraph/include/ParagraphStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ struct ParagraphStyle {
this->fEllipsisUtf16 == rhs.fEllipsisUtf16 &&
this->fTextDirection == rhs.fTextDirection && this->fTextAlign == rhs.fTextAlign &&
this->fDefaultTextStyle == rhs.fDefaultTextStyle &&
this->fReplaceTabCharacters == rhs.fReplaceTabCharacters;
this->fReplaceTabCharacters == rhs.fReplaceTabCharacters &&
this->fFakeMissingFontStyles == rhs.fFakeMissingFontStyles;

}

const StrutStyle& getStrutStyle() const { return fStrutStyle; }
Expand Down Expand Up @@ -121,6 +123,9 @@ struct ParagraphStyle {
bool hintingIsOn() const { return fHintingIsOn; }
void turnHintingOff() { fHintingIsOn = false; }

bool fakeMissingFontStyles() const { return fFakeMissingFontStyles; }
void setFakeMissingFontStyles(bool value) { fFakeMissingFontStyles = value; }

bool getReplaceTabCharacters() const { return fReplaceTabCharacters; }
void setReplaceTabCharacters(bool value) { fReplaceTabCharacters = value; }

Expand All @@ -139,6 +144,7 @@ struct ParagraphStyle {
TextHeightBehavior fTextHeightBehavior;
bool fHintingIsOn;
bool fReplaceTabCharacters;
bool fFakeMissingFontStyles;
bool fApplyRoundingHack = true;
};
} // namespace textlayout
Expand Down
24 changes: 13 additions & 11 deletions modules/skparagraph/src/OneLineShaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,17 +657,19 @@ bool OneLineShaper::shape() {
font.setHinting(block.fStyle.getFontHinting());
font.setSubpixel(block.fStyle.getSubpixel());

// Apply fake bold and/or italic settings to the font if the
// typeface's attributes do not match the intended font style.
int wantedWeight = block.fStyle.getFontStyle().weight();
bool fakeBold =
wantedWeight >= SkFontStyle::kSemiBold_Weight &&
wantedWeight - font.getTypeface()->fontStyle().weight() >= 200;
bool fakeItalic =
block.fStyle.getFontStyle().slant() == SkFontStyle::kItalic_Slant &&
font.getTypeface()->fontStyle().slant() != SkFontStyle::kItalic_Slant;
font.setEmbolden(fakeBold);
font.setSkewX(fakeItalic ? -SK_Scalar1 / 4 : 0);
if (fParagraph->paragraphStyle().fakeMissingFontStyles()) {
// Apply fake bold and/or italic settings to the font if the
// typeface's attributes do not match the intended font style.
int wantedWeight = block.fStyle.getFontStyle().weight();
bool fakeBold =
wantedWeight >= SkFontStyle::kSemiBold_Weight &&
wantedWeight - font.getTypeface()->fontStyle().weight() >= 200;
bool fakeItalic =
block.fStyle.getFontStyle().slant() == SkFontStyle::kItalic_Slant &&
font.getTypeface()->fontStyle().slant() != SkFontStyle::kItalic_Slant;
font.setEmbolden(fakeBold);
font.setSkewX(fakeItalic ? -SK_Scalar1 / 4 : 0);
}

// Walk through all the currently unresolved blocks
// (ignoring those that appear later)
Expand Down
1 change: 1 addition & 0 deletions modules/skparagraph/src/ParagraphStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ParagraphStyle::ParagraphStyle() {
fTextHeightBehavior = TextHeightBehavior::kAll;
fHintingIsOn = true;
fReplaceTabCharacters = false;
fFakeMissingFontStyles = true;
}

TextAlign ParagraphStyle::effective_align() const {
Expand Down