This commit is contained in:
halx99 2022-12-11 15:58:55 +08:00
parent 7d2ecae55c
commit b5713f2443
2 changed files with 23 additions and 7 deletions

View File

@ -42,7 +42,7 @@ void FUILabel::applyTextFormat()
if (_fontName.find("ui://") != -1) if (_fontName.find("ui://") != -1)
{ {
setBMFontFilePath(_fontName); this->setBMFontFilePath(_fontName);
} }
else else
{ {
@ -118,7 +118,14 @@ void FUILabel::applyTextFormat()
disableEffect(LabelEffect::SHADOW); disableEffect(LabelEffect::SHADOW);
} }
#if defined(AX_VERSION)
bool FUILabel::setBMFontFilePath(std::string_view bmfontFilePath,
const Rect& imageRect,
bool imageRotated,
float fontSize)
#else
bool FUILabel::setBMFontFilePath(std::string_view bmfontFilePath, const Vec2& imageOffset, float fontSize) bool FUILabel::setBMFontFilePath(std::string_view bmfontFilePath, const Vec2& imageOffset, float fontSize)
#endif
{ {
BitmapFont* bmFont = (BitmapFont*)UIPackage::getItemAssetByURL(bmfontFilePath, PackageItemType::FONT); BitmapFont* bmFont = (BitmapFont*)UIPackage::getItemAssetByURL(bmfontFilePath, PackageItemType::FONT);
if (bmFont == nullptr) if (bmFont == nullptr)

View File

@ -23,14 +23,23 @@ public:
void setUnderlineColor(const ax::Color3B& value); void setUnderlineColor(const ax::Color3B& value);
virtual bool setBMFontFilePath(std::string_view bmfontFilePath, const ax::Vec2& imageOffset = ax::Vec2::ZERO, float fontSize = 0) override; #if defined(AX_VERSION)
bool setBMFontFilePath(std::string_view bmfontFilePath,
const ax::Rect& imageRect = ax::Rect::ZERO,
bool imageRotated = false,
float fontSize = 0) override;
#else
bool setBMFontFilePath(std::string_view bmfontFilePath,
const ax::Vec2& imageOffset = ax::Vec2::ZERO,
float fontSize = 0) override;
#endif
void setGrayed(bool value); void setGrayed(bool value);
protected: protected:
/* /*
ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>cocos2d<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>ļ<EFBFBD>2d/CCLabel.h<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD>672<EFBFBD>У<EFBFBD>ΪupdateBMFontScale<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>virtual<EFBFBD><EFBFBD><EFBFBD>η<EFBFBD><EFBFBD><EFBFBD> cocos2d的源码2d/CCLabel.h672updateBMFontScale函数打上virtual修饰符
<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>ΪFontFnt<EFBFBD><EFBFBD><EFBFBD>͵Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD>ʹ<EFBFBD><EFBFBD>FontFnt<EFBFBD><EFBFBD>FontFntֻ֧<EFBFBD>ִ<EFBFBD><EFBFBD>ⲿ<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>BMFontConfiguration<EFBFBD>Ƕ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>cpp<EFBFBD><EFBFBD>ġ<EFBFBD><EFBFBD><EFBFBD> FontFnt类型的代码使FontFntFontFnt只支持从外部文件中载入配置BMFontConfiguration是定义在cpp里的
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/ */
virtual void updateBMFontScale() override; virtual void updateBMFontScale() override;