2013-07-11 02:59:05 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga Inc.
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-07-11 02:59:05 +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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-07-19 04:13:41 +08:00
|
|
|
#ifndef _FontDefinition_h_
|
|
|
|
#define _FontDefinition_h_
|
2013-07-11 02:59:05 +08:00
|
|
|
|
2013-11-07 09:05:13 +08:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2013-07-11 02:59:05 +08:00
|
|
|
#include "CCTextImage.h"
|
|
|
|
#include "CCFont.h"
|
2013-07-20 01:33:26 +08:00
|
|
|
#include "CCFontAtlas.h"
|
2013-07-11 02:59:05 +08:00
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-07-16 05:35:25 +08:00
|
|
|
/**
|
|
|
|
*/
|
2013-07-25 01:22:46 +08:00
|
|
|
class CC_DLL FontDefinitionTTF : public Object
|
2013-07-11 02:59:05 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-08-06 06:11:07 +08:00
|
|
|
|
2013-08-06 09:03:52 +08:00
|
|
|
static FontDefinitionTTF* create(Font *font, int textureSize = 0);
|
2013-07-20 01:33:26 +08:00
|
|
|
FontAtlas * createFontAtlas();
|
|
|
|
|
2013-07-19 04:13:41 +08:00
|
|
|
private:
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js ctor
|
|
|
|
*/
|
2013-07-20 03:24:25 +08:00
|
|
|
FontDefinitionTTF();
|
2013-09-13 16:46:31 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-20 03:24:25 +08:00
|
|
|
~FontDefinitionTTF();
|
|
|
|
|
2013-08-06 06:11:07 +08:00
|
|
|
bool initDefinition(Font *font, const char *letters, int textureSize);
|
2013-07-18 08:31:28 +08:00
|
|
|
bool prepareLetterDefinitions(TextFontPagesDef *pageDefs);
|
2013-09-13 11:46:46 +08:00
|
|
|
void addLetterDefinition(const FontLetterDefinition &defToAdd);
|
2013-07-18 08:31:28 +08:00
|
|
|
|
2013-11-07 09:05:13 +08:00
|
|
|
TextImage * _textImages;
|
|
|
|
std::unordered_map<unsigned short, FontLetterDefinition> _fontLettersDefinitionUTF16;
|
|
|
|
float _commonLineHeight;
|
|
|
|
|
|
|
|
static const int DEFAUL_ATLAS_TEXTURE_SIZE;
|
2013-07-11 02:59:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif
|