修复hsp中使用rawfile字体文件不生效的问题

Signed-off-by: fan_pan <fanpan10@huawei.com>
Change-Id: I868742b639d5f8f528c424c15a5b4d826da9fbbd
This commit is contained in:
fan_pan 2023-12-23 18:11:26 +08:00
parent 400b1d8542
commit f13babf0c6
19 changed files with 104 additions and 195 deletions

View File

@ -2759,9 +2759,10 @@ RefPtr<JsAcePage> FrontendDelegateDeclarative::GetPage(int32_t pageId) const
return itPage->second;
}
void FrontendDelegateDeclarative::RegisterFont(const std::string& familyName, const std::string& familySrc)
void FrontendDelegateDeclarative::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc);
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc, bundleName, moduleName);
}
void FrontendDelegateDeclarative::GetSystemFontList(std::vector<std::string>& fontList)

View File

@ -251,7 +251,8 @@ public:
void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "") override;
void GetSystemFontList(std::vector<std::string>& fontList) override;

View File

@ -542,9 +542,10 @@ void FrontendDelegateDeclarativeNG::ChangeLocale(const std::string& language, co
TaskExecutor::TaskType::PLATFORM);
}
void FrontendDelegateDeclarativeNG::RegisterFont(const std::string& familyName, const std::string& familySrc)
void FrontendDelegateDeclarativeNG::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc);
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc, bundleName, moduleName);
}
void FrontendDelegateDeclarativeNG::GetSystemFontList(std::vector<std::string>& fontList)

View File

@ -193,7 +193,8 @@ public:
void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "") override;
void GetSystemFontList(std::vector<std::string>& fontList) override;

View File

@ -212,7 +212,8 @@ public:
virtual void OnMediaQueryUpdate(bool isSynchronous = false) = 0;
virtual void RegisterFont(const std::string& familyName, const std::string& familySrc) = 0;
virtual void RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName = "", const std::string& moduleName = "") = 0;
virtual void GetSystemFontList(std::vector<std::string>& fontList) = 0;

View File

@ -1802,9 +1802,10 @@ RefPtr<JsAcePage> FrontendDelegateImpl::GetPage(int32_t pageId) const
return itPage->second;
}
void FrontendDelegateImpl::RegisterFont(const std::string& familyName, const std::string& familySrc)
void FrontendDelegateImpl::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc);
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc, bundleName, moduleName);
}
void FrontendDelegateImpl::GetSystemFontList(std::vector<std::string>& fontList)

View File

@ -299,7 +299,8 @@ public:
void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "") override;
void GetSystemFontList(std::vector<std::string>& fontList) override;

View File

@ -1621,9 +1621,10 @@ RefPtr<JsAcePage> PluginFrontendDelegate::GetPage(int32_t pageId) const
return itPage->second;
}
void PluginFrontendDelegate::RegisterFont(const std::string& familyName, const std::string& familySrc)
void PluginFrontendDelegate::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc);
pipelineContextHolder_.Get()->RegisterFont(familyName, familySrc, bundleName, moduleName);
}
void PluginFrontendDelegate::GetSystemFontList(std::vector<std::string>& fontList)

View File

@ -194,7 +194,8 @@ public:
void ChangeLocale(const std::string& language, const std::string& countryOrRegion) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc) override;
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "") override;
void GetSystemFontList(std::vector<std::string>& fontList) override;

View File

@ -28,7 +28,8 @@ public:
FontLoader(const std::string& familyName, const std::string& familySrc);
~FontLoader() override = default;
virtual void AddFont(const RefPtr<PipelineBase>& context) = 0;
virtual void AddFont(const RefPtr<PipelineBase>& context, const std::string& bundleName = "",
const std::string& moduleName = "") = 0;
virtual void SetDefaultFontFamily(const char* fontFamily, const char* familySrc)
{

View File

@ -30,8 +30,8 @@ namespace OHOS::Ace {
float FontManager::fontWeightScale_ = 1.0f;
void FontManager::RegisterFont(
const std::string& familyName, const std::string& familySrc, const RefPtr<PipelineBase>& context)
void FontManager::RegisterFont(const std::string& familyName, const std::string& familySrc,
const RefPtr<PipelineBase>& context, const std::string& bundleName, const std::string& moduleName)
{
if (std::find(std::begin(fontNames_), std::end(fontNames_), familyName) == std::end(fontNames_)) {
fontNames_.emplace_back(familyName);
@ -46,7 +46,7 @@ void FontManager::RegisterFont(
}
RefPtr<FontLoader> fontLoader = FontLoader::Create(familyName, familySrc);
fontLoaders_.emplace_back(fontLoader);
fontLoader->AddFont(context);
fontLoader->AddFont(context, bundleName, moduleName);
fontLoader->SetVariationChanged([weak = WeakClaim(this), familyName]() {
auto fontManager = weak.Upgrade();

View File

@ -39,8 +39,8 @@ public:
static RefPtr<FontManager> Create();
void RegisterFont(
const std::string& familyName, const std::string& familySrc, const RefPtr<PipelineBase>& context);
void RegisterFont(const std::string& familyName, const std::string& familySrc, const RefPtr<PipelineBase>& context,
const std::string& bundleName = "", const std::string& moduleName = "");
void GetSystemFontList(std::vector<std::string>& fontList);
bool GetSystemFont(const std::string& fontName, FontInfo& fontInfo);
bool RegisterCallback(

View File

@ -16,16 +16,17 @@
#include "core/components/font/rosen_font_loader.h"
#include "base/network/download_manager.h"
#include "core/common/resource/resource_manager.h"
#include "core/common/resource/resource_object.h"
#include "core/common/resource/resource_wrapper.h"
#include "core/components/font/rosen_font_collection.h"
#include "core/pipeline/base/rosen_render_context.h"
namespace OHOS::Ace {
#ifdef USE_GRAPHIC_TEXT_GINE
constexpr size_t FILE_HEAD_LENGTH = 7; // 7 is the size of "file://"
constexpr size_t MEMORY_HEAD_LENGTH = 9; // 9 is the size of "memory://"
constexpr size_t INTERNAL_FILE_HEAD_LENGTH = 15; // 15 is the size of "internal://app/"
#endif
const std::regex RAWFILE_APP_RES_PATH_REGEX(R"(^resource://RAWFILE/(.*)$)");
constexpr uint32_t RAWFILE_RESOURCE_MATCH_SIZE = 2;
@ -34,9 +35,10 @@ RosenFontLoader::RosenFontLoader(const std::string& familyName, const std::strin
: FontLoader(familyName, familySrc)
{}
void RosenFontLoader::AddFont(const RefPtr<PipelineBase>& context)
void RosenFontLoader::AddFont(
const RefPtr<PipelineBase>& context, const std::string& bundleName, const std::string& moduleName)
{
if (familySrc_.empty()) {
if (context == nullptr || familySrc_.empty()) {
return;
}
@ -45,16 +47,12 @@ void RosenFontLoader::AddFont(const RefPtr<PipelineBase>& context)
LoadFromNetwork(context);
} else if (familySrc_.substr(0, strlen(FONT_SRC_RESOURCE)) == FONT_SRC_RESOURCE) {
// Get font from Resource.
LoadFromResource(context);
#ifndef USE_GRAPHIC_TEXT_GINE
} else {
#else
LoadFromResource(context, bundleName, moduleName);
} else if (familySrc_.find_first_of(':') != std::string::npos) {
// Get font from file
// Read file with absolute path to solve the problem that rawfile file registration fails during preview.
LoadFromFile(context);
} else {
#endif
// Get font from asset.
LoadFromAsset(context);
}
@ -65,7 +63,7 @@ void RosenFontLoader::SetDefaultFontFamily(const char* fontFamily, const char* f
RosenFontCollection::GetInstance().LoadFontFamily(fontFamily, familySrc);
}
void RosenFontLoader::LoadFromNetwork(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineBase>& context)
void RosenFontLoader::LoadFromNetwork(const RefPtr<PipelineBase>& context)
{
auto weakContext = AceType::WeakClaim(AceType::RawPtr(context));
context->GetTaskExecutor()->PostTask(
@ -80,27 +78,12 @@ void RosenFontLoader::LoadFromNetwork(const OHOS::Ace::RefPtr<OHOS::Ace::Pipelin
if (!DownloadManager::GetInstance().Download(fontLoader->familySrc_, fontData) || fontData.empty()) {
return;
}
context->GetTaskExecutor()->PostTask(
[fontData, weak] {
auto fontLoader = weak.Upgrade();
if (!fontLoader) {
return;
}
// Load font.
RosenFontCollection::GetInstance().LoadFontFromList(
fontData.data(), fontData.size(), fontLoader->familyName_);
fontLoader->isLoaded_ = true;
// When font is already loaded, notify all which used this font.
fontLoader->NotifyCallbacks();
},
TaskExecutor::TaskType::UI);
fontLoader->PostLoadFontTask(std::move(fontData), context);
},
TaskExecutor::TaskType::BACKGROUND);
}
#ifdef USE_GRAPHIC_TEXT_GINE
void RosenFontLoader::LoadFromFile(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineBase>& context)
void RosenFontLoader::LoadFromFile(const RefPtr<PipelineBase>& context)
{
auto weakContext = AceType::WeakClaim(AceType::RawPtr(context));
context->GetTaskExecutor()->PostTask(
@ -123,21 +106,8 @@ void RosenFontLoader::LoadFromFile(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineBa
TAG_LOGW(AceLogTag::ACE_FONT, "No asset data!");
return;
}
context->GetTaskExecutor()->PostTask(
[assetData, weak] {
auto fontLoader = weak.Upgrade();
if (!fontLoader) {
return;
}
// Load font.
RosenFontCollection::GetInstance().LoadFontFromList(
assetData->GetData(), assetData->GetSize(), fontLoader->familyName_);
fontLoader->isLoaded_ = true;
// When font is already loaded, notify all which used this font.
fontLoader->NotifyCallbacks();
},
TaskExecutor::TaskType::UI);
const std::vector<uint8_t> fontData(assetData->GetData(), assetData->GetData() + assetData->GetSize());
fontLoader->PostLoadFontTask(std::move(fontData), context);
},
TaskExecutor::TaskType::BACKGROUND);
}
@ -212,24 +182,31 @@ std::string RosenFontLoader::RemovePathHead(const std::string& uri)
TAG_LOGW(AceLogTag::ACE_FONT, "Wrong scheme, not a valid File!");
return std::string();
}
#endif
void RosenFontLoader::LoadFromResource(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineBase>& context)
void RosenFontLoader::LoadFromResource(
const RefPtr<PipelineBase>& context, const std::string& bundleName, const std::string& moduleName)
{
auto weakContext = AceType::WeakClaim(AceType::RawPtr(context));
context->GetTaskExecutor()->PostTask(
[weak = AceType::WeakClaim(this), weakContext] {
[weak = AceType::WeakClaim(this), weakContext, bundleName, moduleName] {
auto fontLoader = weak.Upgrade();
auto context = weakContext.Upgrade();
if (!fontLoader || !context) {
return;
}
auto themeManager = context->GetThemeManager();
if (!themeManager) {
return;
auto resourceObject = AceType::MakeRefPtr<ResourceObject>(bundleName, moduleName);
RefPtr<ResourceAdapter> resourceAdapter = nullptr;
RefPtr<ThemeConstants> themeConstants = nullptr;
if (SystemProperties::GetResourceDecoupling()) {
resourceAdapter = ResourceManager::GetInstance().GetOrCreateResourceAdapter(resourceObject);
CHECK_NULL_VOID(resourceAdapter);
} else {
auto themeManager = PipelineBase::CurrentThemeManager();
CHECK_NULL_VOID(themeManager);
themeConstants = themeManager->GetThemeConstants();
CHECK_NULL_VOID(themeConstants);
}
TAG_LOGI(AceLogTag::ACE_FONT, "begin to load font from resource.");
auto themeConstants = themeManager->GetThemeConstants();
auto resourceWrapper = AceType::MakeRefPtr<ResourceWrapper>(themeConstants, resourceAdapter);
std::string rawFile;
std::unique_ptr<uint8_t[]> data;
size_t dataLen = 0;
@ -241,36 +218,20 @@ void RosenFontLoader::LoadFromResource(const OHOS::Ace::RefPtr<OHOS::Ace::Pipeli
if (rawFile.empty()) {
return;
}
if (!themeConstants->GetRawFileData(rawFile, dataLen, data) || !data.get()) {
TAG_LOGW(AceLogTag::ACE_FONT, "Get raw file data failed!");
if (!resourceWrapper->GetRawFileData(rawFile, dataLen, data, bundleName, moduleName) || !data.get()) {
TAG_LOGW(AceLogTag::ACE_FONT, "Get font data by rawFile failed, src:%{private}s, rawFile:%{public}s",
fontLoader->familySrc_.c_str(), rawFile.c_str());
return;
}
auto fontDataPtr = data.get();
std::vector<uint8_t> fontData;
for (size_t i = 0; i < dataLen; i++) {
fontData.emplace_back(fontDataPtr[i]);
}
context->GetTaskExecutor()->PostTask(
[fontData, weak] {
auto fontLoader = weak.Upgrade();
if (!fontLoader) {
return;
}
// Load font.
RosenFontCollection::GetInstance().LoadFontFromList(
fontData.data(), fontData.size(), fontLoader->familyName_);
fontLoader->isLoaded_ = true;
// When font is already loaded, notify all which used this font.
fontLoader->NotifyCallbacks();
},
TaskExecutor::TaskType::UI);
const std::vector<uint8_t> fontData(data.get(), data.get() + dataLen);
fontLoader->PostLoadFontTask(std::move(fontData), context);
},
TaskExecutor::TaskType::BACKGROUND);
}
void RosenFontLoader::LoadFromAsset(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineBase>& context)
void RosenFontLoader::LoadFromAsset(const RefPtr<PipelineBase>& context)
{
auto weakContext = AceType::WeakClaim(AceType::RawPtr(context));
context->GetTaskExecutor()->PostTask(
@ -296,26 +257,30 @@ void RosenFontLoader::LoadFromAsset(const OHOS::Ace::RefPtr<OHOS::Ace::PipelineB
TAG_LOGW(AceLogTag::ACE_FONT, "No asset data!");
return;
}
context->GetTaskExecutor()->PostTask(
[assetData, weak] {
auto fontLoader = weak.Upgrade();
if (!fontLoader) {
return;
}
// Load font.
RosenFontCollection::GetInstance().LoadFontFromList(
assetData->GetData(), assetData->GetSize(), fontLoader->familyName_);
fontLoader->isLoaded_ = true;
// When font is already loaded, notify all which used this font.
fontLoader->NotifyCallbacks();
},
TaskExecutor::TaskType::UI);
const std::vector<uint8_t> fontData(assetData->GetData(), assetData->GetData() + assetData->GetSize());
fontLoader->PostLoadFontTask(std::move(fontData), context);
},
TaskExecutor::TaskType::BACKGROUND);
}
void RosenFontLoader::PostLoadFontTask(const std::vector<uint8_t>& fontData, const RefPtr<PipelineBase>& context)
{
CHECK_NULL_VOID(context);
context->GetTaskExecutor()->PostTask(
[fontData, weak = AceType::WeakClaim(this)] {
auto fontLoader = weak.Upgrade();
CHECK_NULL_VOID(fontLoader);
// Load font.
RosenFontCollection::GetInstance().LoadFontFromList(
fontData.data(), fontData.size(), fontLoader->familyName_);
fontLoader->isLoaded_ = true;
// When font is already loaded, notify all which used this font.
fontLoader->NotifyCallbacks();
},
TaskExecutor::TaskType::UI);
}
void RosenFontLoader::NotifyCallbacks()
{
for (const auto& [node, callback] : callbacksNG_) {

View File

@ -17,9 +17,7 @@
#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_FONT_ROSEN_FONT_LOADER_H
#include "core/common/font_loader.h"
#ifdef USE_GRAPHIC_TEXT_GINE
#include "core/common/rosen/rosen_asset_manager.h"
#endif
namespace OHOS::Ace {
@ -33,18 +31,19 @@ public:
RosenFontLoader(const std::string& familyName, const std::string& familySrc);
~RosenFontLoader() override = default;
void AddFont(const RefPtr<PipelineBase>& context) override;
void AddFont(const RefPtr<PipelineBase>& context, const std::string& bundleName = "",
const std::string& moduleName = "") override;
void SetDefaultFontFamily(const char* fontFamily, const char* familySrc) override;
private:
void LoadFromNetwork(const RefPtr<PipelineBase>& context);
void LoadFromResource(const RefPtr<PipelineBase>& context);
void LoadFromResource(
const RefPtr<PipelineBase>& context, const std::string& bundleName = "", const std::string& moduleName = "");
void LoadFromAsset(const RefPtr<PipelineBase>& context);
#ifdef USE_GRAPHIC_TEXT_GINE
void LoadFromFile(const RefPtr<PipelineBase>& context);
RefPtr<Asset> GetAssetFromFile(const std::string& fileName) const;
std::string RemovePathHead(const std::string& uri);
#endif
void PostLoadFontTask(const std::vector<uint8_t>& fontData, const RefPtr<PipelineBase>& context);
void NotifyCallbacks();
};

View File

@ -24,19 +24,9 @@
namespace OHOS::Ace::NG {
#ifdef USE_GRAPHIC_TEXT_GINE
RefPtr<TxtFontCollection> TxtFontCollection::instance;
#endif
RefPtr<FontCollection> TxtFontCollection::GetInstance()
{
#ifndef USE_GRAPHIC_TEXT_GINE
static RefPtr<TxtFontCollection> instance = AceType::MakeRefPtr<TxtFontCollection>();
#else
if (instance == nullptr) {
instance = AceType::MakeRefPtr<TxtFontCollection>();
}
#endif
return instance;
}

View File

@ -60,7 +60,6 @@ private:
std::shared_ptr<txt::FontCollection> collection_;
sk_sp<txt::DynamicFontManager> dynamicFontManager_;
#else
static RefPtr<TxtFontCollection> instance;
std::shared_ptr<RSFontCollection> collection_;
#endif
};

View File

@ -267,10 +267,11 @@ void PipelineBase::SetTextFieldManager(const RefPtr<ManagerInterface>& manager)
textFieldManager_ = manager;
}
void PipelineBase::RegisterFont(const std::string& familyName, const std::string& familySrc)
void PipelineBase::RegisterFont(const std::string& familyName, const std::string& familySrc,
const std::string& bundleName, const std::string& moduleName)
{
if (fontManager_) {
fontManager_->RegisterFont(familyName, familySrc, AceType::Claim(this));
fontManager_->RegisterFont(familyName, familySrc, AceType::Claim(this), bundleName, moduleName);
}
}

View File

@ -745,7 +745,8 @@ public:
void RequestFrame();
void RegisterFont(const std::string& familyName, const std::string& familySrc);
void RegisterFont(const std::string& familyName, const std::string& familySrc, const std::string& bundleName = "",
const std::string& moduleName = "");
void GetSystemFontList(std::vector<std::string>& fontList);

View File

@ -39,58 +39,8 @@ constexpr int32_t FONT_INFO_INDEX_SYMBOLIC = 9;
constexpr int32_t FONT_INFO_INDEX_MAX = 10;
}
#ifndef USE_GRAPHIC_TEXT_GINE
static bool ParseFamilyName(napi_env env, napi_value familyNameNApi, std::string& familyName, napi_valuetype valueType)
{
napi_typeof(env, familyNameNApi, &valueType);
if (valueType == napi_string) {
size_t nameLen = 0;
napi_get_value_string_utf8(env, familyNameNApi, nullptr, 0, &nameLen);
std::unique_ptr<char[]> name = std::make_unique<char[]>(nameLen + 1);
napi_get_value_string_utf8(env, familyNameNApi, name.get(), nameLen + 1, &nameLen);
familyName = name.get();
} else if (valueType == napi_object) {
ResourceInfo recv;
if (!ParseResourceParam(env, familyNameNApi, recv)) {
return false;
}
if (!ParseString(recv, familyName)) {
return false;
}
} else {
return false;
}
return true;
}
static bool ParseFamilySrc(napi_env env, napi_value familySrcNApi, std::string& familySrc, napi_valuetype& valueType)
{
napi_typeof(env, familySrcNApi, &valueType);
if (valueType == napi_string) {
size_t srcLen = 0;
napi_get_value_string_utf8(env, familySrcNApi, nullptr, 0, &srcLen);
std::unique_ptr<char[]> src = std::make_unique<char[]>(srcLen + 1);
napi_get_value_string_utf8(env, familySrcNApi, src.get(), srcLen + 1, &srcLen);
familySrc = src.get();
} else if (valueType == napi_object) {
ResourceInfo recv;
if (!ParseResourceParam(env, familySrcNApi, recv)) {
NapiThrow(env, "Can not parse resource info from input params.", Framework::ERROR_CODE_INTERNAL_ERROR);
return false;
}
if (!ParseString(recv, familySrc)) {
NapiThrow(env, "Can not get familySrc from resource manager.", Framework::ERROR_CODE_INTERNAL_ERROR);
return false;
}
} else {
return false;
}
return true;
}
#else
static bool ParseFamilyNameOrSrc(
napi_env env, napi_value familyNameOrSrcNApi, std::string& familyNameOrSrc, napi_valuetype valueType)
static bool ParseFamilyNameOrSrc(napi_env env, napi_value familyNameOrSrcNApi, std::string& familyNameOrSrc,
napi_valuetype valueType, ResourceInfo& info)
{
napi_typeof(env, familyNameOrSrcNApi, &valueType);
if (valueType == napi_string) {
@ -100,11 +50,10 @@ static bool ParseFamilyNameOrSrc(
napi_get_value_string_utf8(env, familyNameOrSrcNApi, name.get(), nameLen + 1, &nameLen);
familyNameOrSrc = name.get();
} else if (valueType == napi_object) {
ResourceInfo recv;
if (!ParseResourceParam(env, familyNameOrSrcNApi, recv)) {
if (!ParseResourceParam(env, familyNameOrSrcNApi, info)) {
return false;
}
if (!ParseString(recv, familyNameOrSrc)) {
if (!ParseString(info, familyNameOrSrc)) {
return false;
}
} else {
@ -112,7 +61,6 @@ static bool ParseFamilyNameOrSrc(
}
return true;
}
#endif
static napi_value JSRegisterFont(napi_env env, napi_callback_info info)
{
@ -135,28 +83,24 @@ static napi_value JSRegisterFont(napi_env env, napi_callback_info info)
} else {
return nullptr;
}
#ifndef USE_GRAPHIC_TEXT_GINE
if (!ParseFamilyName(env, familyNameNApi, familyName, valueType)) {
#else
if (!ParseFamilyNameOrSrc(env, familyNameNApi, familyName, valueType)) {
#endif
ResourceInfo resourceInfo;
if (!ParseFamilyNameOrSrc(env, familyNameNApi, familyName, valueType, resourceInfo)) {
return nullptr;
}
#ifndef USE_GRAPHIC_TEXT_GINE
if (!ParseFamilySrc(env, familySrcNApi, familySrc, valueType)) {
#else
if (!ParseFamilyNameOrSrc(env, familySrcNApi, familySrc, valueType)) {
#endif
if (!ParseFamilyNameOrSrc(env, familySrcNApi, familySrc, valueType, resourceInfo)) {
return nullptr;
}
std::string bundleName = resourceInfo.bundleName.has_value() ? resourceInfo.bundleName.value() : "";
std::string moduleName = resourceInfo.moduleName.has_value() ? resourceInfo.moduleName.value() : "";
auto delegate = EngineHelper::GetCurrentDelegate();
if (!delegate) {
TAG_LOGW(AceLogTag::ACE_FONT, "can not get delegate.");
return nullptr;
}
TAG_LOGI(AceLogTag::ACE_FONT, "begin to register font.");
delegate->RegisterFont(familyName, familySrc);
delegate->RegisterFont(familyName, familySrc, bundleName, moduleName);
return nullptr;
}