aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-autoroll <android-autoroll@skia-corp.google.com.iam.gserviceaccount.com>2022-03-29 11:01:54 +0000
committerDerek Sollenberger <djsollen@google.com>2022-03-29 13:02:59 +0000
commite4161ab97f7bd69a68ac06faf33ca360463994a6 (patch)
tree816d9bf1af0673eaba1aab4d141abe9970a460e5
parent75106ff1e1f62d091c70444f3743cacf8864784e (diff)
parenta357a11f7456651320f57599f44cee8e49a57104 (diff)
downloadskia-e4161ab97f7bd69a68ac06faf33ca360463994a6.tar.gz
RESTRICT AUTOMERGE Roll Skia from e28fcd178277 to a357a11f7456 (1 revision)
https://skia.googlesource.com/skia.git/+log/e28fcd178277..a357a11f7456 If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://skia-autoroll.corp.goog/r/android-next-autoroll Please CC djsollen@google.com on the revert to ensure that a human is aware of the problem. To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md Test: Presubmit checks will test this change. Exempt-From-Owner-Approval: The autoroll bot does not require owner approval. Bug: b/225044541 Change-Id: I98b921403b0c556806437ee3d0071d7b26d43309
-rw-r--r--gm/stroketext.cpp30
-rw-r--r--resources/fonts/Variable.ttfbin11548 -> 12812 bytes
-rw-r--r--src/ports/SkFontHost_FreeType_common.cpp14
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
index be5cf90130..f852390699 100644
--- a/resources/fonts/Variable.ttf
+++ b/resources/fonts/Variable.ttf
Binary files differ
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,