diff options
author | android-autoroll <android-autoroll@skia-corp.google.com.iam.gserviceaccount.com> | 2022-03-29 22:49:00 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-29 22:49:00 +0000 |
commit | 44bc8c64deed1cd5cae27479504175b90f47d1da (patch) | |
tree | 816d9bf1af0673eaba1aab4d141abe9970a460e5 | |
parent | d7d633a1a2887ae016366b64170f27bba43cf7a0 (diff) | |
parent | e4161ab97f7bd69a68ac06faf33ca360463994a6 (diff) | |
download | skia-44bc8c64deed1cd5cae27479504175b90f47d1da.tar.gz |
RESTRICT AUTOMERGE Roll Skia from e28fcd178277 to a357a11f7456 (1 revision) am: e4161ab97f
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/skia/+/17469132
Change-Id: I1c2988114579abf385935852cd6e7195e19fd073
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | gm/stroketext.cpp | 30 | ||||
-rw-r--r-- | resources/fonts/Variable.ttf | bin | 11548 -> 12812 bytes | |||
-rw-r--r-- | src/ports/SkFontHost_FreeType_common.cpp | 14 |
3 files changed, 41 insertions, 3 deletions
diff --git a/gm/stroketext.cpp b/gm/stroketext.cpp index 4c2baa11f4..98e670a9ff 100644 --- a/gm/stroketext.cpp +++ b/gm/stroketext.cpp @@ -10,6 +10,8 @@ #include "include/core/SkCanvas.h" #include "include/core/SkColor.h" #include "include/core/SkFont.h" +#include "include/core/SkFontArguments.h" +#include "include/core/SkFontMgr.h" #include "include/core/SkFontTypes.h" #include "include/core/SkImageInfo.h" #include "include/core/SkPaint.h" @@ -95,10 +97,24 @@ DEF_SIMPLE_GM(stroketext, canvas, 1200, 480) { draw_text_set(canvas, paint, font); } -DEF_SIMPLE_GM_CAN_FAIL(stroketext_native, canvas, msg, 650, 320) { +DEF_SIMPLE_GM_CAN_FAIL(stroketext_native, canvas, msg, 650, 420) { sk_sp<SkTypeface> ttf = MakeResourceAsTypeface("fonts/Stroking.ttf"); sk_sp<SkTypeface> otf = MakeResourceAsTypeface("fonts/Stroking.otf"); - if (!ttf && !otf) { + + sk_sp<SkTypeface> overlap = []() -> sk_sp<SkTypeface>{ + std::unique_ptr<SkStreamAsset> variableStream(GetResourceAsStream("fonts/Variable.ttf")); + if (!variableStream) { + return nullptr; + } + const SkFontArguments::VariationPosition::Coordinate position[] = { + { SkSetFourByteTag('w','g','h','t'), 721.0f }, + }; + SkFontArguments params; + params.setVariationDesignPosition({position, SK_ARRAY_COUNT(position)}); + return SkFontMgr::RefDefault()->makeFromStream(std::move(variableStream), params); + }(); + + if (!ttf && !otf && !overlap) { msg->append("No support for ttf or otf."); return skiagm::DrawResult::kSkip; } @@ -140,5 +156,15 @@ DEF_SIMPLE_GM_CAN_FAIL(stroketext_native, canvas, msg, 650, 320) { canvas->drawString("○◉ ⁰¹³ᶠ", 10, 300, font, p); } + if (overlap) { + /* Variable.ttf is structured like: + U+74 t (glyf outline has overlap flag) + U+167 ŧ (glyf outline does not have overlap flag) + */ + SkFont font(overlap, 100); + p.setStrokeWidth(1); + canvas->drawString("tŧ", 10, 400, font, p); + } + return skiagm::DrawResult::kOk; } diff --git a/resources/fonts/Variable.ttf b/resources/fonts/Variable.ttf Binary files differindex be5cf90130..f852390699 100644 --- a/resources/fonts/Variable.ttf +++ b/resources/fonts/Variable.ttf diff --git a/src/ports/SkFontHost_FreeType_common.cpp b/src/ports/SkFontHost_FreeType_common.cpp index c85fc77c13..da64ed8d2c 100644 --- a/src/ports/SkFontHost_FreeType_common.cpp +++ b/src/ports/SkFontHost_FreeType_common.cpp @@ -13,6 +13,7 @@ #include "include/core/SkPath.h" #include "include/core/SkPictureRecorder.h" #include "include/effects/SkGradientShader.h" +#include "include/pathops/SkPathOps.h" #include "include/private/SkColorData.h" #include "include/private/SkTo.h" #include "src/core/SkFDot6.h" @@ -49,6 +50,11 @@ #endif #endif +// FT_OUTLINE_OVERLAP was added in FreeType 2.10.3 +#ifndef FT_OUTLINE_OVERLAP +# define FT_OUTLINE_OVERLAP 0x40 +#endif + // FT_LOAD_COLOR and the corresponding FT_Pixel_Mode::FT_PIXEL_MODE_BGRA // were introduced in FreeType 2.5.0. // The following may be removed once FreeType 2.5.0 is required to build. @@ -1728,7 +1734,13 @@ bool generateFacePathCOLRv1(FT_Face face, SkGlyphID glyphID, SkPath* path) { } // namespace bool SkScalerContext_FreeType_Base::generateGlyphPath(FT_Face face, SkPath* path) { - return generateGlyphPathStatic(face, path); + if (!generateGlyphPathStatic(face, path)) { + return false; + } + if (face->glyph->outline.flags & FT_OUTLINE_OVERLAP) { + Simplify(*path, path); + } + return true; } bool SkScalerContext_FreeType_Base::generateFacePath(FT_Face face, |