mirror of https://github.com/axmolengine/axmol.git
Spaces should not be lost if label created with Fingerpop.ttf
This commit is contained in:
parent
2c220092e6
commit
e81d5af12d
|
@ -164,7 +164,7 @@ bool FontAtlas::getLetterDefinitionForChar(char16_t utf16Char, FontLetterDefinit
|
|||
if (outIterator != _letterDefinitions.end())
|
||||
{
|
||||
letterDefinition = (*outIterator).second;
|
||||
return true;
|
||||
return letterDefinition.validDefinition;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -274,25 +274,21 @@ int FontFreeType::getFontAscender() const
|
|||
unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWidth, long &outHeight, Rect &outRect,int &xAdvance)
|
||||
{
|
||||
bool invalidChar = true;
|
||||
unsigned char * ret = nullptr;
|
||||
unsigned char* ret = nullptr;
|
||||
|
||||
do
|
||||
do
|
||||
{
|
||||
if (!_fontRef)
|
||||
break;
|
||||
|
||||
auto glyphIndex = FT_Get_Char_Index(_fontRef, theChar);
|
||||
if(!glyphIndex)
|
||||
if (_fontRef == nullptr)
|
||||
break;
|
||||
|
||||
if (_distanceFieldEnabled)
|
||||
{
|
||||
if (FT_Load_Glyph(_fontRef,glyphIndex,FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT))
|
||||
if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT))
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FT_Load_Glyph(_fontRef,glyphIndex,FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT))
|
||||
if (FT_Load_Char(_fontRef, theChar, FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -400,9 +396,7 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
|
|||
unsigned char * FontFreeType::getGlyphBitmapWithOutline(unsigned short theChar, FT_BBox &bbox)
|
||||
{
|
||||
unsigned char* ret = nullptr;
|
||||
|
||||
FT_UInt gindex = FT_Get_Char_Index(_fontRef, theChar);
|
||||
if (FT_Load_Glyph(_fontRef, gindex, FT_LOAD_NO_BITMAP) == 0)
|
||||
if (FT_Load_Char(_fontRef, theChar, FT_LOAD_NO_BITMAP) == 0)
|
||||
{
|
||||
if (_fontRef->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
|
||||
{
|
||||
|
|
|
@ -87,6 +87,7 @@ NewLabelTests::NewLabelTests()
|
|||
ADD_TEST_CASE(LabelFullTypeFontTest);
|
||||
ADD_TEST_CASE(LabelIssue10688Test);
|
||||
ADD_TEST_CASE(LabelIssue13202Test);
|
||||
ADD_TEST_CASE(LabelIssue9500Test);
|
||||
};
|
||||
|
||||
LabelTTFAlignmentNew::LabelTTFAlignmentNew()
|
||||
|
@ -2085,3 +2086,22 @@ std::string LabelIssue13202Test::subtitle() const
|
|||
{
|
||||
return "FontAtlasCache::purgeCachedData should not cause crash.";
|
||||
}
|
||||
|
||||
LabelIssue9500Test::LabelIssue9500Test()
|
||||
{
|
||||
auto center = VisibleRect::center();
|
||||
|
||||
auto label = Label::createWithTTF("Spaces should not be lost", "fonts/Fingerpop.ttf", 20);
|
||||
label->setPosition(center);
|
||||
addChild(label);
|
||||
}
|
||||
|
||||
std::string LabelIssue9500Test::title() const
|
||||
{
|
||||
return "Test for Issue #9500";
|
||||
}
|
||||
|
||||
std::string LabelIssue9500Test::subtitle() const
|
||||
{
|
||||
return "Spaces should not be lost if label created with Fingerpop.ttf";
|
||||
}
|
||||
|
|
|
@ -669,4 +669,15 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class LabelIssue9500Test : public AtlasDemoNew
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LabelIssue9500Test);
|
||||
|
||||
LabelIssue9500Test();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue