Added test case for binary fnt file

Also, fixed nul-termination issue in file parsing
This commit is contained in:
Roman "SBKarr 2013-12-28 23:00:07 +04:00
parent b0e6b5a43f
commit 93f6d9c4f5
3 changed files with 36 additions and 1 deletions

View File

@ -192,7 +192,7 @@ std::set<unsigned int>* CCBMFontConfiguration::parseConfigFile(const std::string
return ret;
}
std::string contents((const char*)data.getBytes());
std::string contents((const char*)data.getBytes(), data.getSize());
std::set<unsigned int> *validCharsString = new std::set<unsigned int>();

View File

@ -74,6 +74,7 @@ static std::function<Layer*()> createFunctions[] =
// should be moved to another test
CL(Atlas1),
CL(LabelBMFontCrashTest),
CL(LabelBMFontBinaryFormat),
};
#define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0]))
@ -1669,3 +1670,26 @@ std::string LabelBMFontCrashTest::subtitle() const
{
return "Should not crash.";
}
// LabelBMFontBinaryFormat
LabelBMFontBinaryFormat::LabelBMFontBinaryFormat()
{
auto s = Director::getInstance()->getWinSize();
auto bmFont = LabelBMFont::create();
bmFont->setFntFile("fonts/Roboto.bmf.fnt");
bmFont->setString("It is working!");
this->addChild(bmFont);
bmFont->setPosition(Point(s.width/2,s.height/4*2));
}
std::string LabelBMFontBinaryFormat::title() const
{
return "LabelBMFont Binary FNT File";
}
std::string LabelBMFontBinaryFormat::subtitle() const
{
return "This label uses font file in AngelCode binary format";
}

View File

@ -429,6 +429,17 @@ public:
virtual std::string subtitle() const override;
};
class LabelBMFontBinaryFormat : public AtlasDemo
{
public:
CREATE_FUNC(LabelBMFontBinaryFormat);
LabelBMFontBinaryFormat();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
// we don't support linebreak mode