Implement onMakeClone(const SkFontArguments& args) in classes: SkTypeface_Empty, SkTypeface_Stream, SkTypeface_File
Change-Id: I534cfc3439601f682d6b5a2fa023aef6b04d1653 Reviewed-on: https://skia-review.googlesource.com/137192 Commit-Queue: Ben Wagner <bungeman@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
6d36370c06
commit
0ea256c4db
@ -50,6 +50,9 @@ SkTypeface_Empty::SkTypeface_Empty() : INHERITED(SkFontStyle(), false, true, SkS
|
||||
|
||||
SkStreamAsset* SkTypeface_Empty::onOpenStream(int*) const { return nullptr; }
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface_Empty::onMakeClone(const SkFontArguments& args) const {
|
||||
return sk_ref_sp(this);
|
||||
}
|
||||
|
||||
SkTypeface_Stream::SkTypeface_Stream(std::unique_ptr<SkFontData> fontData,
|
||||
const SkFontStyle& style, bool isFixedPitch, bool sysFont,
|
||||
@ -67,6 +70,21 @@ std::unique_ptr<SkFontData> SkTypeface_Stream::onMakeFontData() const {
|
||||
return skstd::make_unique<SkFontData>(*fData);
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface_Stream::onMakeClone(const SkFontArguments& args) const {
|
||||
std::unique_ptr<SkFontData> data = this->cloneFontData(args);
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkString familyName;
|
||||
this->getFamilyName(&familyName);
|
||||
|
||||
return sk_make_sp<SkTypeface_Stream>(std::move(data),
|
||||
this->fontStyle(),
|
||||
this->isFixedPitch(),
|
||||
this->isSysFont(),
|
||||
familyName);
|
||||
}
|
||||
|
||||
SkTypeface_File::SkTypeface_File(const SkFontStyle& style, bool isFixedPitch, bool sysFont,
|
||||
const SkString familyName, const char path[], int index)
|
||||
@ -79,6 +97,22 @@ SkStreamAsset* SkTypeface_File::onOpenStream(int* ttcIndex) const {
|
||||
return SkStream::MakeFromFile(fPath.c_str()).release();
|
||||
}
|
||||
|
||||
sk_sp<SkTypeface> SkTypeface_File::onMakeClone(const SkFontArguments& args) const {
|
||||
std::unique_ptr<SkFontData> data = this->cloneFontData(args);
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkString familyName;
|
||||
this->getFamilyName(&familyName);
|
||||
|
||||
return sk_make_sp<SkTypeface_Stream>(std::move(data),
|
||||
this->fontStyle(),
|
||||
this->isFixedPitch(),
|
||||
this->isSysFont(),
|
||||
familyName);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SkFontStyleSet_Custom::SkFontStyleSet_Custom(const SkString familyName) : fFamilyName(familyName) {}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
protected:
|
||||
SkStreamAsset* onOpenStream(int*) const override;
|
||||
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
|
||||
|
||||
private:
|
||||
typedef SkTypeface_Custom INHERITED;
|
||||
@ -65,6 +66,7 @@ public:
|
||||
protected:
|
||||
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
|
||||
std::unique_ptr<SkFontData> onMakeFontData() const override;
|
||||
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
|
||||
|
||||
private:
|
||||
const std::unique_ptr<const SkFontData> fData;
|
||||
@ -80,6 +82,7 @@ public:
|
||||
|
||||
protected:
|
||||
SkStreamAsset* onOpenStream(int* ttcIndex) const override;
|
||||
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
|
||||
|
||||
private:
|
||||
SkString fPath;
|
||||
|
@ -531,11 +531,11 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkString fFamilyName;
|
||||
this->getFamilyName(&fFamilyName);
|
||||
SkString familyName;
|
||||
this->getFamilyName(&familyName);
|
||||
|
||||
return sk_make_sp<SkTypeface_stream>(std::move(data),
|
||||
fFamilyName,
|
||||
familyName,
|
||||
this->fontStyle(),
|
||||
this->isFixedPitch());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user