FontAtlasWrapper.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #include "FontAtlasWrapper.h"
  2. #include "WrapperConverter.h"
  3. #include "imguiWrappedHeader.h"
  4. IggGlyphRanges iggGetGlyphRangesAll() {
  5. static const ImWchar ranges[] = {
  6. 0x0001,
  7. 0xFFFF,
  8. 0,
  9. };
  10. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(&ranges[0]));
  11. }
  12. IggGlyphRanges iggGetGlyphRangesDefault(IggFontAtlas handle) {
  13. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  14. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesDefault()));
  15. }
  16. IggGlyphRanges iggGetGlyphRangesKorean(IggFontAtlas handle) {
  17. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  18. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesKorean()));
  19. }
  20. IggGlyphRanges iggGetGlyphRangesJapanese(IggFontAtlas handle) {
  21. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  22. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesJapanese()));
  23. }
  24. IggGlyphRanges iggGetGlyphRangesChineseFull(IggFontAtlas handle) {
  25. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  26. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesChineseFull()));
  27. }
  28. IggGlyphRanges iggGetGlyphRangesChineseSimplifiedCommon(IggFontAtlas handle) {
  29. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  30. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesChineseSimplifiedCommon()));
  31. }
  32. IggGlyphRanges iggGetGlyphRangesCyrillic(IggFontAtlas handle) {
  33. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  34. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesCyrillic()));
  35. }
  36. IggGlyphRanges iggGetGlyphRangesThai(IggFontAtlas handle) {
  37. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  38. return static_cast<IggGlyphRanges>(const_cast<ImWchar *>(fontAtlas->GetGlyphRangesThai()));
  39. }
  40. IggFont iggAddFontDefault(IggFontAtlas handle) {
  41. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  42. ImFont *font = fontAtlas->AddFontDefault();
  43. return static_cast<IggFont>(font);
  44. }
  45. IggFont iggAddFontDefaultV(IggFontAtlas handle, IggFontConfig config) {
  46. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  47. ImFontConfig *fontConfig = reinterpret_cast<ImFontConfig *>(config);
  48. ImFont *font = fontAtlas->AddFontDefault(fontConfig);
  49. return static_cast<IggFont>(font);
  50. }
  51. IggFont iggAddFontFromFileTTF(IggFontAtlas handle, char const *filename, float sizePixels, IggFontConfig config, IggGlyphRanges glyphRanges) {
  52. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  53. ImFontConfig *fontConfig = reinterpret_cast<ImFontConfig *>(config);
  54. ImWchar *glyphChars = reinterpret_cast<ImWchar *>(glyphRanges);
  55. ImFont *font = fontAtlas->AddFontFromFileTTF(filename, sizePixels, fontConfig, glyphChars);
  56. return static_cast<IggFont>(font);
  57. }
  58. IggFont iggAddFontFromMemoryTTF(IggFontAtlas handle, char *font_data, int font_size, float sizePixels, IggFontConfig config, IggGlyphRanges glyphRanges) {
  59. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  60. ImFontConfig *fontConfig = reinterpret_cast<ImFontConfig *>(config);
  61. ImWchar *glyphChars = reinterpret_cast<ImWchar *>(glyphRanges);
  62. ImFont *font = fontAtlas->AddFontFromMemoryTTF(font_data, font_size, sizePixels, fontConfig, glyphChars);
  63. return static_cast<IggFont>(font);
  64. }
  65. void iggFontAtlasSetTexDesiredWidth(IggFontAtlas handle, int value) {
  66. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  67. fontAtlas->TexDesiredWidth = value;
  68. }
  69. void iggFontAtlasGetTexDataAsAlpha8(IggFontAtlas handle, unsigned char **pixels, int *width, int *height, int *bytesPerPixel) {
  70. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  71. fontAtlas->GetTexDataAsAlpha8(pixels, width, height, bytesPerPixel);
  72. }
  73. void iggFontAtlasGetTexDataAsRGBA32(IggFontAtlas handle, unsigned char **pixels, int *width, int *height, int *bytesPerPixel) {
  74. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  75. fontAtlas->GetTexDataAsRGBA32(pixels, width, height, bytesPerPixel);
  76. }
  77. void iggFontAtlasSetTextureID(IggFontAtlas handle, IggTextureID id) {
  78. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  79. fontAtlas->SetTexID(reinterpret_cast<ImTextureID>(id));
  80. }
  81. void iggFontAtlasBuild(IggFontAtlas handle) {
  82. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  83. fontAtlas->Build();
  84. }
  85. void iggFontAtlasClear(IggFontAtlas handle) {
  86. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  87. fontAtlas->Clear();
  88. }
  89. unsigned int iggFontAtlasGetFontBuilderFlags(IggFontAtlas handle) {
  90. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  91. return fontAtlas->FontBuilderFlags;
  92. }
  93. void iggFontAtlasSetFontBuilderFlags(IggFontAtlas handle, unsigned int flags) {
  94. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  95. fontAtlas->FontBuilderFlags = flags;
  96. }
  97. int iggFontAtlasFontCount(IggFontAtlas handle) {
  98. ImFontAtlas *fontAtlas = reinterpret_cast<ImFontAtlas *>(handle);
  99. return fontAtlas->Fonts.size();
  100. }