Apply fake bold and italic settings to the SkFont if the typeface needs them

The rules for setting fake bold and italic are based on the implementation
used in Minikin.

Change-Id: I9bbecdbd0198363db0296fa9c68046b4724fbded
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/269429
Commit-Queue: Jason Simmons <jsimmons@google.com>
Reviewed-by: Julia Lavrova <jlavrova@google.com>
diff --git a/modules/skparagraph/src/OneLineShaper.cpp b/modules/skparagraph/src/OneLineShaper.cpp
index 00257ee..e52e6d1 100644
--- a/modules/skparagraph/src/OneLineShaper.cpp
+++ b/modules/skparagraph/src/OneLineShaper.cpp
@@ -524,6 +524,18 @@
                 font.setHinting(SkFontHinting::kSlight);
                 font.setSubpixel(true);
 
+                // 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)
                 auto count = fUnresolvedBlocks.size();