forked from firka/flutter
Change to new SkFontMgr API (flutter/engine#4173)
* Change to new SkFontMgr API These changes clarify ownership rules and work today. They will be necessary once SK_SUPPORT_LEGACY_FONTMGR_API goes away. * Fix spacing * Formatting
This commit is contained in:
@@ -228,10 +228,11 @@ sk_sp<SkTypeface> AssetFontSelector::getTypefaceAsset(
|
||||
}
|
||||
|
||||
sk_sp<SkFontMgr> font_mgr(SkFontMgr::RefDefault());
|
||||
SkMemoryStream* typeface_stream = new SkMemoryStream(
|
||||
typeface_asset->data.data(), typeface_asset->data.size());
|
||||
std::unique_ptr<SkStreamAsset> typeface_stream =
|
||||
std::make_unique<SkMemoryStream>(typeface_asset->data.data(),
|
||||
typeface_asset->data.size());
|
||||
typeface_asset->typeface =
|
||||
sk_sp<SkTypeface>(font_mgr->createFromStream(typeface_stream));
|
||||
font_mgr->makeFromStream(std::move(typeface_stream));
|
||||
if (typeface_asset->typeface == nullptr) {
|
||||
typeface_cache_.insert(std::make_pair(asset_path, nullptr));
|
||||
return nullptr;
|
||||
|
||||
@@ -67,31 +67,35 @@ SkTypeface* AssetFontManager::onMatchFaceStyle(const SkTypeface*,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTypeface* AssetFontManager::onCreateFromData(SkData*, int ttcIndex) const {
|
||||
sk_sp<SkTypeface> AssetFontManager::onMakeFromData(sk_sp<SkData>,
|
||||
int ttcIndex) const {
|
||||
FXL_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTypeface* AssetFontManager::onCreateFromStream(SkStreamAsset*,
|
||||
int ttcIndex) const {
|
||||
sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamIndex(
|
||||
std::unique_ptr<SkStreamAsset>,
|
||||
int ttcIndex) const {
|
||||
FXL_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTypeface* AssetFontManager::onCreateFromStream(SkStreamAsset*,
|
||||
const SkFontArguments&) const {
|
||||
sk_sp<SkTypeface> AssetFontManager::onMakeFromStreamArgs(
|
||||
std::unique_ptr<SkStreamAsset>,
|
||||
const SkFontArguments&) const {
|
||||
FXL_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTypeface* AssetFontManager::onCreateFromFile(const char path[],
|
||||
int ttcIndex) const {
|
||||
sk_sp<SkTypeface> AssetFontManager::onMakeFromFile(const char path[],
|
||||
int ttcIndex) const {
|
||||
FXL_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkTypeface* AssetFontManager::onLegacyCreateTypeface(const char familyName[],
|
||||
SkFontStyle) const {
|
||||
sk_sp<SkTypeface> AssetFontManager::onLegacyMakeTypeface(
|
||||
const char familyName[],
|
||||
SkFontStyle) const {
|
||||
FXL_DCHECK(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -61,21 +61,23 @@ class AssetFontManager : public SkFontMgr {
|
||||
const SkFontStyle&) const override;
|
||||
|
||||
// |SkFontMgr|
|
||||
SkTypeface* onCreateFromData(SkData*, int ttcIndex) const override;
|
||||
sk_sp<SkTypeface> onMakeFromData(sk_sp<SkData>, int ttcIndex) const override;
|
||||
|
||||
// |SkFontMgr|
|
||||
SkTypeface* onCreateFromStream(SkStreamAsset*, int ttcIndex) const override;
|
||||
sk_sp<SkTypeface> onMakeFromStreamIndex(std::unique_ptr<SkStreamAsset>,
|
||||
int ttcIndex) const override;
|
||||
|
||||
// |SkFontMgr|
|
||||
SkTypeface* onCreateFromStream(SkStreamAsset*,
|
||||
const SkFontArguments&) const override;
|
||||
sk_sp<SkTypeface> onMakeFromStreamArgs(std::unique_ptr<SkStreamAsset>,
|
||||
const SkFontArguments&) const override;
|
||||
|
||||
// |SkFontMgr|
|
||||
SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override;
|
||||
sk_sp<SkTypeface> onMakeFromFile(const char path[],
|
||||
int ttcIndex) const override;
|
||||
|
||||
// |SkFontMgr|
|
||||
SkTypeface* onLegacyCreateTypeface(const char familyName[],
|
||||
SkFontStyle) const override;
|
||||
sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[],
|
||||
SkFontStyle) const override;
|
||||
|
||||
FXL_DISALLOW_COPY_AND_ASSIGN(AssetFontManager);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user