CCFontCharMap.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /****************************************************************************
  2. Copyright (c) 2013 Zynga Inc.
  3. Copyright (c) 2013-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef _CCFontCharMap_h_
  23. #define _CCFontCharMap_h_
  24. /// @cond DO_NOT_SHOW
  25. #include "2d/CCFont.h"
  26. NS_CC_BEGIN
  27. class Texture2D;
  28. class FontCharMap : public Font
  29. {
  30. public:
  31. static FontCharMap * create(const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap);
  32. static FontCharMap * create(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
  33. static FontCharMap * create(const std::string& plistFile);
  34. virtual int* getHorizontalKerningForTextUTF32(const std::u32string& text, int &outNumLetters) const override;
  35. virtual FontAtlas *createFontAtlas() override;
  36. protected:
  37. FontCharMap(Texture2D* texture,int itemWidth, int itemHeight, int startCharMap)
  38. :_texture(texture)
  39. ,_mapStartChar(startCharMap)
  40. ,_itemWidth(itemWidth)
  41. ,_itemHeight(itemHeight)
  42. {}
  43. /**
  44. * @js NA
  45. * @lua NA
  46. */
  47. virtual ~FontCharMap();
  48. private:
  49. Texture2D* _texture;
  50. int _mapStartChar;
  51. int _itemWidth;
  52. int _itemHeight;
  53. };
  54. /// @endcond
  55. NS_CC_END
  56. #endif /* defined(_CCFontCharMap_h_) */