2013-07-26 08:58:13 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga Inc.
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-07-26 08:58:13 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _CCFontFNT_h_
|
|
|
|
#define _CCFontFNT_h_
|
|
|
|
|
|
|
|
#include "CCFont.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2014-02-21 09:59:43 +08:00
|
|
|
class BMFontConfiguration;
|
2014-01-17 13:35:58 +08:00
|
|
|
|
2013-07-26 08:58:13 +08:00
|
|
|
class FontFNT : public Font
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
static FontFNT * create(const std::string& fntFilePath, const Vec2& imageOffset = Vec2::ZERO);
|
2014-02-20 22:33:52 +08:00
|
|
|
/** Purges the cached data.
|
|
|
|
Removes from memory the cached configurations and the atlas name dictionary.
|
|
|
|
*/
|
|
|
|
static void purgeCachedData();
|
2014-05-08 11:12:59 +08:00
|
|
|
virtual int* getHorizontalKerningForTextUTF16(const std::u16string& text, int &outNumLetters) const override;
|
2013-08-15 21:00:06 +08:00
|
|
|
virtual FontAtlas *createFontAtlas() override;
|
2013-08-02 05:36:34 +08:00
|
|
|
|
2013-08-06 06:56:18 +08:00
|
|
|
protected:
|
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
FontFNT(BMFontConfiguration *theContfig, const Vec2& imageOffset = Vec2::ZERO);
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-08-06 06:56:18 +08:00
|
|
|
virtual ~FontFNT();
|
|
|
|
|
2013-07-26 08:58:13 +08:00
|
|
|
private:
|
|
|
|
|
2013-09-13 11:46:46 +08:00
|
|
|
int getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const;
|
2013-07-26 08:58:13 +08:00
|
|
|
|
2014-02-21 09:59:43 +08:00
|
|
|
BMFontConfiguration * _configuration;
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _imageOffset;
|
2013-07-26 08:58:13 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /* defined(__cocos2d_libs__CCFontFNT__) */
|