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)
|
, _stroker(nullptr)
|
||||||
, _distanceFieldEnabled(distanceFieldEnabled)
|
, _distanceFieldEnabled(distanceFieldEnabled)
|
||||||
, _outlineSize(0.0f)
|
, _outlineSize(0.0f)
|
||||||
|
, _lineHeight(0)
|
||||||
|
, _fontAtlas(nullptr)
|
||||||
{
|
{
|
||||||
if (outline > 0)
|
if (outline > 0)
|
||||||
{
|
{
|
||||||
|
@ -147,6 +149,7 @@ bool FontFreeType::createFontObject(const std::string &fontName, int fontSize)
|
||||||
|
|
||||||
// store the face globally
|
// store the face globally
|
||||||
_fontRef = face;
|
_fontRef = face;
|
||||||
|
_lineHeight = static_cast<int>(_fontRef->size->metrics.height >> 6);
|
||||||
|
|
||||||
// done and good
|
// done and good
|
||||||
return true;
|
return true;
|
||||||
|
@ -172,17 +175,21 @@ FontFreeType::~FontFreeType()
|
||||||
|
|
||||||
FontAtlas * FontFreeType::createFontAtlas()
|
FontAtlas * FontFreeType::createFontAtlas()
|
||||||
{
|
{
|
||||||
FontAtlas *atlas = new (std::nothrow) FontAtlas(*this);
|
if (_fontAtlas == nullptr)
|
||||||
if (_usedGlyphs != GlyphCollection::DYNAMIC)
|
{
|
||||||
|
_fontAtlas = new (std::nothrow) FontAtlas(*this);
|
||||||
|
if (_fontAtlas && _usedGlyphs != GlyphCollection::DYNAMIC)
|
||||||
{
|
{
|
||||||
std::u16string utf16;
|
std::u16string utf16;
|
||||||
if (StringUtils::UTF8ToUTF16(getCurrentGlyphCollection(), utf16))
|
if (StringUtils::UTF8ToUTF16(getCurrentGlyphCollection(), utf16))
|
||||||
{
|
{
|
||||||
atlas->prepareLetterDefinitions(utf16);
|
_fontAtlas->prepareLetterDefinitions(utf16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->release();
|
this->release();
|
||||||
return atlas;
|
}
|
||||||
|
|
||||||
|
return _fontAtlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
int * FontFreeType::getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const
|
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));
|
return (static_cast<int>(kerning.x >> 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
int FontFreeType::getFontMaxHeight() const
|
|
||||||
{
|
|
||||||
return (static_cast<int>(_fontRef->size->metrics.height >> 6));
|
|
||||||
}
|
|
||||||
|
|
||||||
int FontFreeType::getFontAscender() const
|
int FontFreeType::getFontAscender() const
|
||||||
{
|
{
|
||||||
return (static_cast<int>(_fontRef->size->metrics.ascender >> 6));
|
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);
|
auto blendHeight = blendImageMaxY - MIN(outlineMinY, glyphMinY);
|
||||||
|
|
||||||
outRect.origin.x = blendImageMinX;
|
outRect.origin.x = blendImageMinX;
|
||||||
outRect.origin.y = -blendImageMaxY;
|
outRect.origin.y = -blendImageMaxY + _outlineSize;
|
||||||
|
|
||||||
long index, index2;
|
long index, index2;
|
||||||
auto blendImage = new unsigned char[blendWidth * blendHeight * 2];
|
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);
|
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;
|
virtual int getFontAscender() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -90,6 +90,8 @@ private:
|
||||||
std::string _fontName;
|
std::string _fontName;
|
||||||
bool _distanceFieldEnabled;
|
bool _distanceFieldEnabled;
|
||||||
float _outlineSize;
|
float _outlineSize;
|
||||||
|
int _lineHeight;
|
||||||
|
FontAtlas* _fontAtlas;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @endcond
|
/// @endcond
|
||||||
|
|
Loading…
Reference in New Issue