mirror of https://github.com/axmolengine/axmol.git
Label:Fixed the top of character's texture may be tailored if enable outline effect.
This commit is contained in:
parent
d65900ea3d
commit
322bd30d7b
|
@ -97,6 +97,8 @@ FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /
|
|||
, _stroker(nullptr)
|
||||
, _distanceFieldEnabled(distanceFieldEnabled)
|
||||
, _outlineSize(0.0f)
|
||||
, _lineHeight(0)
|
||||
, _fontAtlas(nullptr)
|
||||
{
|
||||
if (outline > 0)
|
||||
{
|
||||
|
@ -147,6 +149,7 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
|||
|
||||
// store the face globally
|
||||
_fontRef = face;
|
||||
_lineHeight = static_cast<int>(_fontRef->size->metrics.height >> 6);
|
||||
|
||||
// done and good
|
||||
return true;
|
||||
|
@ -172,17 +175,21 @@ FontFreeType::~FontFreeType()
|
|||
|
||||
FontAtlas * FontFreeType::createFontAtlas()
|
||||
{
|
||||
FontAtlas *atlas = new (std::nothrow) FontAtlas(*this);
|
||||
if (_usedGlyphs != GlyphCollection::DYNAMIC)
|
||||
if (_fontAtlas == nullptr)
|
||||
{
|
||||
std::u16string utf16;
|
||||
if (StringUtils::UTF8ToUTF16(getCurrentGlyphCollection(), utf16))
|
||||
_fontAtlas = new (std::nothrow) FontAtlas(*this);
|
||||
if (_fontAtlas && _usedGlyphs != GlyphCollection::DYNAMIC)
|
||||
{
|
||||
atlas->prepareLetterDefinitions(utf16);
|
||||
std::u16string utf16;
|
||||
if (StringUtils::UTF8ToUTF16(getCurrentGlyphCollection(), utf16))
|
||||
{
|
||||
_fontAtlas->prepareLetterDefinitions(utf16);
|
||||
}
|
||||
}
|
||||
this->release();
|
||||
}
|
||||
this->release();
|
||||
return atlas;
|
||||
|
||||
return _fontAtlas;
|
||||
}
|
||||
|
||||
int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const
|
||||
|
@ -234,11 +241,6 @@ int FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsign
|
|||
return (static_cast<int>(kerning.x >> 6));
|
||||
}
|
||||
|
||||
int FontFreeType::getFontMaxHeight() const
|
||||
{
|
||||
return (static_cast<int>(_fontRef->size->metrics.height >> 6));
|
||||
}
|
||||
|
||||
int FontFreeType::getFontAscender() const
|
||||
{
|
||||
return (static_cast<int>(_fontRef->size->metrics.ascender >> 6));
|
||||
|
@ -313,7 +315,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
|
|||
auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY);
|
||||
|
||||
outRect.origin.x = blendImageMinX;
|
||||
outRect.origin.y = -blendImageMaxY;
|
||||
outRect.origin.y = -blendImageMaxY + _outlineSize;
|
||||
|
||||
long index, index2;
|
||||
auto blendImage = new unsigned char[blendWidth * blendHeight * 2];
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
|
||||
unsigned char * getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance);
|
||||
|
||||
virtual int getFontMaxHeight() const override;
|
||||
virtual int getFontMaxHeight() const override { return _lineHeight; }
|
||||
virtual int getFontAscender() const;
|
||||
|
||||
protected:
|
||||
|
@ -90,6 +90,8 @@ private:
|
|||
std::string _fontName;
|
||||
bool _distanceFieldEnabled;
|
||||
float _outlineSize;
|
||||
int _lineHeight;
|
||||
FontAtlas* _fontAtlas;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
|
|
Loading…
Reference in New Issue