Implement onMakeClone function on all subclasses of SkTypeface except

on mac.

Change-Id: I2b8777a5b54e190c37623ab798a89b4f1833ceac
Reviewed-on: https://skia-review.googlesource.com/137382
Commit-Queue: Bruce Wang <brucewang@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
Bruce Wang 2018-06-25 11:37:25 -04:00 committed by Skia Commit-Bot
parent ff168d9258
commit 536ad2c146
9 changed files with 35 additions and 0 deletions

View File

@ -45,6 +45,9 @@ protected:
SkEmptyTypeface() : SkTypeface(SkFontStyle(), true) { }
SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override {
return nullptr;

View File

@ -73,6 +73,10 @@ protected:
SK_ABORT("Should never be called.");
return nullptr;
}
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
SK_ABORT("Should never be called.");
return nullptr;
}
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
int coordinateCount) const override {
SK_ABORT("Should never be called.");

View File

@ -259,6 +259,7 @@ public:
protected:
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
@ -1966,6 +1967,10 @@ SkStreamAsset* LogFontTypeface::onOpenStream(int* ttcIndex) const {
return stream;
}
sk_sp<SkTypeface> LogFontTypeface::onMakeClone(const SkFontArguments& args) const {
return sk_ref_sp(this);
}
static void bmpCharsToGlyphs(HDC hdc, const WCHAR* bmpChars, int count, uint16_t* glyphs,
bool Ox1FHack)
{

View File

@ -128,6 +128,9 @@ static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
TestTypeface(const SkFontStyle& fontStyle) : SkTypeface(fontStyle, false){}
protected:
SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override {
return nullptr;

View File

@ -235,6 +235,9 @@ protected:
EmptyTypeface() : SkTypeface(SkFontStyle(), true) { }
SkStreamAsset* onOpenStream(int* ttcIndex) const override { return nullptr; }
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override {
return nullptr;

View File

@ -176,6 +176,14 @@ SkStreamAsset* SkRandomTypeface::onOpenStream(int* ttcIndex) const {
return fProxy->openStream(ttcIndex);
}
sk_sp<SkTypeface> SkRandomTypeface::onMakeClone(const SkFontArguments& args) const {
sk_sp<SkTypeface> proxy = fProxy->makeClone(args);
if (!proxy) {
return nullptr;
}
return sk_make_sp<SkRandomTypeface>(proxy, fPaint, fFakeIt);
}
void SkRandomTypeface::onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const {
// TODO: anything that uses this typeface isn't correctly serializable, since this typeface
// cannot be deserialized.

View File

@ -30,6 +30,7 @@ protected:
void getGlyphToUnicodeMap(SkUnichar*) const override;
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override;
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
int onCharsToGlyphs(const void* chars, Encoding encoding,

View File

@ -84,6 +84,10 @@ protected:
return nullptr;
}
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const override;
int onCharsToGlyphs(const void* chars, Encoding encoding,

View File

@ -78,6 +78,10 @@ protected:
return nullptr;
}
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override {
return sk_ref_sp(this);
}
void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const override;
int onCharsToGlyphs(const void* chars, Encoding encoding,