mirror of https://github.com/axmolengine/axmol.git
Fix #972
This commit is contained in:
parent
7d2ecae55c
commit
b5713f2443
|
@ -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)
|
||||||
|
|
|
@ -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.h,大约在672行,为updateBMFontScale函数打上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类型的代码,但我们不使用FontFnt(FontFnt只支持从外部文件中载入配置,更糟糕的是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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue