aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTypeface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkTypeface.cpp')
-rw-r--r--src/core/SkTypeface.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 0c960d5915..3c4f5cb7e7 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -9,6 +9,7 @@
#include "SkEndian.h"
#include "SkFontDescriptor.h"
#include "SkFontMgr.h"
+#include "SkMakeUnique.h"
#include "SkMutex.h"
#include "SkOTTable_OS_2.h"
#include "SkOnce.h"
@@ -150,9 +151,9 @@ sk_sp<SkTypeface> SkTypeface::MakeFromStream(SkStreamAsset* stream, int index) {
return sk_sp<SkTypeface>(fm->createFromStream(stream, index));
}
-sk_sp<SkTypeface> SkTypeface::MakeFromFontData(SkFontData* data) {
+sk_sp<SkTypeface> SkTypeface::MakeFromFontData(std::unique_ptr<SkFontData> data) {
SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
- return sk_sp<SkTypeface>(fm->createFromFontData(data));
+ return sk_sp<SkTypeface>(fm->createFromFontData(std::move(data)));
}
sk_sp<SkTypeface> SkTypeface::MakeFromFile(const char path[], int index) {
@@ -173,7 +174,7 @@ void SkTypeface::serialize(SkWStream* wstream) const {
// Embed font data if it's a local font.
if (isLocal && !desc.hasFontData()) {
- desc.setFontData(this->onCreateFontData());
+ desc.setFontData(this->onMakeFontData());
}
desc.serialize(wstream);
}
@@ -188,9 +189,9 @@ sk_sp<SkTypeface> SkTypeface::MakeDeserialize(SkStream* stream) {
return nullptr;
}
- SkFontData* data = desc.detachFontData();
+ std::unique_ptr<SkFontData> data = desc.detachFontData();
if (data) {
- sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(data));
+ sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData(std::move(data)));
if (typeface) {
return typeface;
}
@@ -227,15 +228,15 @@ SkStreamAsset* SkTypeface::openStream(int* ttcIndex) const {
return this->onOpenStream(ttcIndex);
}
-SkFontData* SkTypeface::createFontData() const {
- return this->onCreateFontData();
+std::unique_ptr<SkFontData> SkTypeface::makeFontData() const {
+ return this->onMakeFontData();
}
// This implementation is temporary until this method can be made pure virtual.
-SkFontData* SkTypeface::onCreateFontData() const {
+std::unique_ptr<SkFontData> SkTypeface::onMakeFontData() const {
int index;
- SkAutoTDelete<SkStreamAsset> stream(this->onOpenStream(&index));
- return new SkFontData(stream.release(), index, nullptr, 0);
+ std::unique_ptr<SkStreamAsset> stream(this->onOpenStream(&index));
+ return skstd::make_unique<SkFontData>(std::move(stream), index, nullptr, 0);
};
int SkTypeface::charsToGlyphs(const void* chars, Encoding encoding,