Implement SkFontMgr_Custom::onCreateFromFontData.
This fixes serialization issues. We could create a non-default gx
typeface, but not deserialize it correctly.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2057293002
Review-Url: https://codereview.chromium.org/2057293002
diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
index 200173d..0fc5180 100644
--- a/src/ports/SkFontMgr_custom.cpp
+++ b/src/ports/SkFontMgr_custom.cpp
@@ -291,6 +291,19 @@
return new SkTypeface_Stream(std::move(data), style, isFixedPitch, false, name);
}
+ SkTypeface* onCreateFromFontData(SkFontData* data) const override {
+ bool isFixedPitch;
+ SkFontStyle style;
+ SkString name;
+ if (!fScanner.scanFont(data->getStream(), data->getIndex(),
+ &name, &style, &isFixedPitch, nullptr))
+ {
+ return nullptr;
+ }
+ std::unique_ptr<SkFontData> unique_data(data);
+ return new SkTypeface_Stream(std::move(unique_data), style, isFixedPitch, false, name);
+ }
+
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path));
return stream.get() ? this->createFromStream(stream.release(), ttcIndex) : nullptr;