Spaces should not be lost if label created with Fingerpop.ttf

This commit is contained in:
WenhaiLin 2015-08-05 23:46:41 +08:00
parent 2c220092e6
commit e81d5af12d
5 changed files with 38 additions and 13 deletions

View File

@ -164,7 +164,7 @@ bool FontAtlas::getLetterDefinitionForChar(char16_t utf16Char, FontLetterDefinit
if (outIterator != _letterDefinitions.end())
{
letterDefinition = (*outIterator).second;
return true;
return letterDefinition.validDefinition;
}
else
{

View File

@ -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)
{

View File

@ -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";
}

View File

@ -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.