Fix fairygui compilation

This commit is contained in:
halx99 2021-11-11 18:04:38 +08:00
parent 6c3d2d13f0
commit 31ed6d97a9
3 changed files with 23 additions and 6 deletions

View File

@ -768,9 +768,12 @@ void UIPackage::loadMovieClip(PackageItem* item)
void UIPackage::loadFont(PackageItem* item) void UIPackage::loadFont(PackageItem* item)
{ {
item->bitmapFont = BitmapFont::create(); item->bitmapFont = BitmapFont::create();
FontAtlas* fontAtlas = new FontAtlas(*item->bitmapFont); auto bitmapFont = item->bitmapFont;
item->bitmapFont->_fontAtlas = fontAtlas; #if defined(ADXE_VERSION)
auto fontAtlas = bitmapFont->resetFontAtlas(bitmapFont->newFontAtlas());
#else
auto fontAtlas = bitmapFont->resetFontAtlas(bitmapFont->createFontAtlas());
#endif
ByteBuffer* buffer = item->rawData; ByteBuffer* buffer = item->rawData;
buffer->seek(0, 0); buffer->seek(0, 0);

View File

@ -16,8 +16,22 @@ public:
static BitmapFont* create(); static BitmapFont* create();
virtual int* getHorizontalKerningForTextUTF32(const std::u32string& text, int &outNumLetters) const override; virtual int* getHorizontalKerningForTextUTF32(const std::u32string& text, int &outNumLetters) const override;
virtual cocos2d::FontAtlas *createFontAtlas() override { return _fontAtlas; } # if defined(ADXE_VERSION)
void releaseAtlas() { _fontAtlas->release(); } virtual cocos2d::FontAtlas* newFontAtlas() override { return new cocos2d::FontAtlas(this); }
#else
virtual cocos2d::FontAtlas* createFontAtlas() override { return new cocos2d::FontAtlas(*this); }
#endif
cocos2d::FontAtlas* resetFontAtlas(cocos2d::FontAtlas* fontAtlas)
{
if (_fontAtlas != fontAtlas)
{
CC_SAFE_RELEASE(_fontAtlas);
_fontAtlas = fontAtlas;
}
return _fontAtlas;
}
cocos2d::FontAtlas* getFontAtlas() const { return _fontAtlas; }
void releaseAtlas() { resetFontAtlas(nullptr); }
void setFontSize(float fontSize) {} void setFontSize(float fontSize) {}
int getOriginalFontSize()const { return _originalFontSize; } int getOriginalFontSize()const { return _originalFontSize; }
bool isResizable() { return _resizable; } bool isResizable() { return _resizable; }

View File

@ -143,7 +143,7 @@ bool FUILabel::setBMFontFilePath(const std::string& bmfontFilePath, const Vec2&
_bmFontCanTint = bmFont->canTint(); _bmFontCanTint = bmFont->canTint();
_currentLabelType = LabelType::BMFONT; _currentLabelType = LabelType::BMFONT;
setFontAtlas(bmFont->createFontAtlas()); setFontAtlas(bmFont->getFontAtlas());
return true; return true;
} }