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
This commit is contained in:
parent
656dbe4c71
commit
57c948251a
@ -291,6 +291,19 @@ protected:
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user