text_server_extension.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /**************************************************************************/
  2. /* text_server_extension.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef TEXT_SERVER_EXTENSION_H
  31. #define TEXT_SERVER_EXTENSION_H
  32. #include "core/object/gdvirtual.gen.inc"
  33. #include "core/object/script_language.h"
  34. #include "core/os/thread_safe.h"
  35. #include "core/variant/native_ptr.h"
  36. #include "core/variant/typed_array.h"
  37. #include "servers/text_server.h"
  38. class TextServerExtension : public TextServer {
  39. GDCLASS(TextServerExtension, TextServer);
  40. protected:
  41. _THREAD_SAFE_CLASS_
  42. static void _bind_methods();
  43. public:
  44. virtual bool has_feature(Feature p_feature) const override;
  45. virtual String get_name() const override;
  46. virtual int64_t get_features() const override;
  47. GDVIRTUAL1RC(bool, _has_feature, Feature);
  48. GDVIRTUAL0RC(String, _get_name);
  49. GDVIRTUAL0RC(int64_t, _get_features);
  50. virtual void free_rid(const RID &p_rid) override;
  51. virtual bool has(const RID &p_rid) override;
  52. virtual bool load_support_data(const String &p_filename) override;
  53. GDVIRTUAL1(_free_rid, RID);
  54. GDVIRTUAL1R(bool, _has, RID);
  55. GDVIRTUAL1R(bool, _load_support_data, const String &);
  56. virtual String get_support_data_filename() const override;
  57. virtual String get_support_data_info() const override;
  58. virtual bool save_support_data(const String &p_filename) const override;
  59. GDVIRTUAL0RC(String, _get_support_data_filename);
  60. GDVIRTUAL0RC(String, _get_support_data_info);
  61. GDVIRTUAL1RC(bool, _save_support_data, const String &);
  62. virtual bool is_locale_right_to_left(const String &p_locale) const override;
  63. GDVIRTUAL1RC(bool, _is_locale_right_to_left, const String &);
  64. virtual int64_t name_to_tag(const String &p_name) const override;
  65. virtual String tag_to_name(int64_t p_tag) const override;
  66. GDVIRTUAL1RC(int64_t, _name_to_tag, const String &);
  67. GDVIRTUAL1RC(String, _tag_to_name, int64_t);
  68. /* Font interface */
  69. virtual RID create_font() override;
  70. GDVIRTUAL0R(RID, _create_font);
  71. virtual void font_set_data(const RID &p_font_rid, const PackedByteArray &p_data) override;
  72. virtual void font_set_data_ptr(const RID &p_font_rid, const uint8_t *p_data_ptr, int64_t p_data_size) override;
  73. GDVIRTUAL2(_font_set_data, RID, const PackedByteArray &);
  74. GDVIRTUAL3(_font_set_data_ptr, RID, GDExtensionConstPtr<const uint8_t>, int64_t);
  75. virtual void font_set_face_index(const RID &p_font_rid, int64_t p_index) override;
  76. virtual int64_t font_get_face_index(const RID &p_font_rid) const override;
  77. GDVIRTUAL2(_font_set_face_index, RID, int64_t);
  78. GDVIRTUAL1RC(int64_t, _font_get_face_index, RID);
  79. virtual int64_t font_get_face_count(const RID &p_font_rid) const override;
  80. GDVIRTUAL1RC(int64_t, _font_get_face_count, RID);
  81. virtual void font_set_style(const RID &p_font_rid, BitField<FontStyle> p_style) override;
  82. virtual BitField<FontStyle> font_get_style(const RID &p_font_rid) const override;
  83. GDVIRTUAL2(_font_set_style, RID, BitField<FontStyle>);
  84. GDVIRTUAL1RC(BitField<FontStyle>, _font_get_style, RID);
  85. virtual void font_set_name(const RID &p_font_rid, const String &p_name) override;
  86. virtual String font_get_name(const RID &p_font_rid) const override;
  87. GDVIRTUAL2(_font_set_name, RID, const String &);
  88. GDVIRTUAL1RC(String, _font_get_name, RID);
  89. virtual void font_set_style_name(const RID &p_font_rid, const String &p_name) override;
  90. virtual String font_get_style_name(const RID &p_font_rid) const override;
  91. GDVIRTUAL2(_font_set_style_name, RID, const String &);
  92. GDVIRTUAL1RC(String, _font_get_style_name, RID);
  93. virtual void font_set_weight(const RID &p_font_rid, int64_t p_weight) override;
  94. virtual int64_t font_get_weight(const RID &p_font_rid) const override;
  95. GDVIRTUAL2(_font_set_weight, RID, int64_t);
  96. GDVIRTUAL1RC(int64_t, _font_get_weight, RID);
  97. virtual void font_set_stretch(const RID &p_font_rid, int64_t p_stretch) override;
  98. virtual int64_t font_get_stretch(const RID &p_font_rid) const override;
  99. GDVIRTUAL2(_font_set_stretch, RID, int64_t);
  100. GDVIRTUAL1RC(int64_t, _font_get_stretch, RID);
  101. virtual void font_set_antialiasing(const RID &p_font_rid, TextServer::FontAntialiasing p_antialiasing) override;
  102. virtual TextServer::FontAntialiasing font_get_antialiasing(const RID &p_font_rid) const override;
  103. GDVIRTUAL2(_font_set_antialiasing, RID, TextServer::FontAntialiasing);
  104. GDVIRTUAL1RC(TextServer::FontAntialiasing, _font_get_antialiasing, RID);
  105. virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) override;
  106. virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const override;
  107. GDVIRTUAL2(_font_set_generate_mipmaps, RID, bool);
  108. GDVIRTUAL1RC(bool, _font_get_generate_mipmaps, RID);
  109. virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override;
  110. virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override;
  111. GDVIRTUAL2(_font_set_multichannel_signed_distance_field, RID, bool);
  112. GDVIRTUAL1RC(bool, _font_is_multichannel_signed_distance_field, RID);
  113. virtual void font_set_msdf_pixel_range(const RID &p_font_rid, int64_t p_msdf_pixel_range) override;
  114. virtual int64_t font_get_msdf_pixel_range(const RID &p_font_rid) const override;
  115. GDVIRTUAL2(_font_set_msdf_pixel_range, RID, int64_t);
  116. GDVIRTUAL1RC(int64_t, _font_get_msdf_pixel_range, RID);
  117. virtual void font_set_msdf_size(const RID &p_font_rid, int64_t p_msdf_size) override;
  118. virtual int64_t font_get_msdf_size(const RID &p_font_rid) const override;
  119. GDVIRTUAL2(_font_set_msdf_size, RID, int64_t);
  120. GDVIRTUAL1RC(int64_t, _font_get_msdf_size, RID);
  121. virtual void font_set_fixed_size(const RID &p_font_rid, int64_t p_fixed_size) override;
  122. virtual int64_t font_get_fixed_size(const RID &p_font_rid) const override;
  123. GDVIRTUAL2(_font_set_fixed_size, RID, int64_t);
  124. GDVIRTUAL1RC(int64_t, _font_get_fixed_size, RID);
  125. virtual void font_set_subpixel_positioning(const RID &p_font_rid, SubpixelPositioning p_subpixel) override;
  126. virtual SubpixelPositioning font_get_subpixel_positioning(const RID &p_font_rid) const override;
  127. GDVIRTUAL2(_font_set_subpixel_positioning, RID, SubpixelPositioning);
  128. GDVIRTUAL1RC(SubpixelPositioning, _font_get_subpixel_positioning, RID);
  129. virtual void font_set_embolden(const RID &p_font_rid, double p_strength) override;
  130. virtual double font_get_embolden(const RID &p_font_rid) const override;
  131. GDVIRTUAL2(_font_set_embolden, RID, double);
  132. GDVIRTUAL1RC(double, _font_get_embolden, RID);
  133. virtual void font_set_transform(const RID &p_font_rid, const Transform2D &p_transform) override;
  134. virtual Transform2D font_get_transform(const RID &p_font_rid) const override;
  135. GDVIRTUAL2(_font_set_transform, RID, Transform2D);
  136. GDVIRTUAL1RC(Transform2D, _font_get_transform, RID);
  137. virtual void font_set_allow_system_fallback(const RID &p_font_rid, bool p_allow_system_fallback) override;
  138. virtual bool font_is_allow_system_fallback(const RID &p_font_rid) const override;
  139. GDVIRTUAL2(_font_set_allow_system_fallback, RID, bool);
  140. GDVIRTUAL1RC(bool, _font_is_allow_system_fallback, RID);
  141. virtual void font_set_force_autohinter(const RID &p_font_rid, bool p_force_autohinter) override;
  142. virtual bool font_is_force_autohinter(const RID &p_font_rid) const override;
  143. GDVIRTUAL2(_font_set_force_autohinter, RID, bool);
  144. GDVIRTUAL1RC(bool, _font_is_force_autohinter, RID);
  145. virtual void font_set_hinting(const RID &p_font_rid, Hinting p_hinting) override;
  146. virtual Hinting font_get_hinting(const RID &p_font_rid) const override;
  147. GDVIRTUAL2(_font_set_hinting, RID, Hinting);
  148. GDVIRTUAL1RC(Hinting, _font_get_hinting, RID);
  149. virtual void font_set_variation_coordinates(const RID &p_font_rid, const Dictionary &p_variation_coordinates) override;
  150. virtual Dictionary font_get_variation_coordinates(const RID &p_font_rid) const override;
  151. GDVIRTUAL2(_font_set_variation_coordinates, RID, Dictionary);
  152. GDVIRTUAL1RC(Dictionary, _font_get_variation_coordinates, RID);
  153. virtual void font_set_oversampling(const RID &p_font_rid, double p_oversampling) override;
  154. virtual double font_get_oversampling(const RID &p_font_rid) const override;
  155. GDVIRTUAL2(_font_set_oversampling, RID, double);
  156. GDVIRTUAL1RC(double, _font_get_oversampling, RID);
  157. virtual TypedArray<Vector2i> font_get_size_cache_list(const RID &p_font_rid) const override;
  158. virtual void font_clear_size_cache(const RID &p_font_rid) override;
  159. virtual void font_remove_size_cache(const RID &p_font_rid, const Vector2i &p_size) override;
  160. GDVIRTUAL1RC(TypedArray<Vector2i>, _font_get_size_cache_list, RID);
  161. GDVIRTUAL1(_font_clear_size_cache, RID);
  162. GDVIRTUAL2(_font_remove_size_cache, RID, const Vector2i &);
  163. virtual void font_set_ascent(const RID &p_font_rid, int64_t p_size, double p_ascent) override;
  164. virtual double font_get_ascent(const RID &p_font_rid, int64_t p_size) const override;
  165. GDVIRTUAL3(_font_set_ascent, RID, int64_t, double);
  166. GDVIRTUAL2RC(double, _font_get_ascent, RID, int64_t);
  167. virtual void font_set_descent(const RID &p_font_rid, int64_t p_size, double p_descent) override;
  168. virtual double font_get_descent(const RID &p_font_rid, int64_t p_size) const override;
  169. GDVIRTUAL3(_font_set_descent, RID, int64_t, double);
  170. GDVIRTUAL2RC(double, _font_get_descent, RID, int64_t);
  171. virtual void font_set_underline_position(const RID &p_font_rid, int64_t p_size, double p_underline_position) override;
  172. virtual double font_get_underline_position(const RID &p_font_rid, int64_t p_size) const override;
  173. GDVIRTUAL3(_font_set_underline_position, RID, int64_t, double);
  174. GDVIRTUAL2RC(double, _font_get_underline_position, RID, int64_t);
  175. virtual void font_set_underline_thickness(const RID &p_font_rid, int64_t p_size, double p_underline_thickness) override;
  176. virtual double font_get_underline_thickness(const RID &p_font_rid, int64_t p_size) const override;
  177. GDVIRTUAL3(_font_set_underline_thickness, RID, int64_t, double);
  178. GDVIRTUAL2RC(double, _font_get_underline_thickness, RID, int64_t);
  179. virtual void font_set_scale(const RID &p_font_rid, int64_t p_size, double p_scale) override;
  180. virtual double font_get_scale(const RID &p_font_rid, int64_t p_size) const override;
  181. GDVIRTUAL3(_font_set_scale, RID, int64_t, double);
  182. GDVIRTUAL2RC(double, _font_get_scale, RID, int64_t);
  183. virtual int64_t font_get_texture_count(const RID &p_font_rid, const Vector2i &p_size) const override;
  184. virtual void font_clear_textures(const RID &p_font_rid, const Vector2i &p_size) override;
  185. virtual void font_remove_texture(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) override;
  186. GDVIRTUAL2RC(int64_t, _font_get_texture_count, RID, const Vector2i &);
  187. GDVIRTUAL2(_font_clear_textures, RID, const Vector2i &);
  188. GDVIRTUAL3(_font_remove_texture, RID, const Vector2i &, int64_t);
  189. virtual void font_set_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const Ref<Image> &p_image) override;
  190. virtual Ref<Image> font_get_texture_image(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override;
  191. GDVIRTUAL4(_font_set_texture_image, RID, const Vector2i &, int64_t, const Ref<Image> &);
  192. GDVIRTUAL3RC(Ref<Image>, _font_get_texture_image, RID, const Vector2i &, int64_t);
  193. virtual void font_set_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index, const PackedInt32Array &p_offset) override;
  194. virtual PackedInt32Array font_get_texture_offsets(const RID &p_font_rid, const Vector2i &p_size, int64_t p_texture_index) const override;
  195. GDVIRTUAL4(_font_set_texture_offsets, RID, const Vector2i &, int64_t, const PackedInt32Array &);
  196. GDVIRTUAL3RC(PackedInt32Array, _font_get_texture_offsets, RID, const Vector2i &, int64_t);
  197. virtual PackedInt32Array font_get_glyph_list(const RID &p_font_rid, const Vector2i &p_size) const override;
  198. virtual void font_clear_glyphs(const RID &p_font_rid, const Vector2i &p_size) override;
  199. virtual void font_remove_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) override;
  200. GDVIRTUAL2RC(PackedInt32Array, _font_get_glyph_list, RID, const Vector2i &);
  201. GDVIRTUAL2(_font_clear_glyphs, RID, const Vector2i &);
  202. GDVIRTUAL3(_font_remove_glyph, RID, const Vector2i &, int64_t);
  203. virtual Vector2 font_get_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph) const override;
  204. virtual void font_set_glyph_advance(const RID &p_font_rid, int64_t p_size, int64_t p_glyph, const Vector2 &p_advance) override;
  205. GDVIRTUAL3RC(Vector2, _font_get_glyph_advance, RID, int64_t, int64_t);
  206. GDVIRTUAL4(_font_set_glyph_advance, RID, int64_t, int64_t, const Vector2 &);
  207. virtual Vector2 font_get_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  208. virtual void font_set_glyph_offset(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_offset) override;
  209. GDVIRTUAL3RC(Vector2, _font_get_glyph_offset, RID, const Vector2i &, int64_t);
  210. GDVIRTUAL4(_font_set_glyph_offset, RID, const Vector2i &, int64_t, const Vector2 &);
  211. virtual Vector2 font_get_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  212. virtual void font_set_glyph_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Vector2 &p_gl_size) override;
  213. GDVIRTUAL3RC(Vector2, _font_get_glyph_size, RID, const Vector2i &, int64_t);
  214. GDVIRTUAL4(_font_set_glyph_size, RID, const Vector2i &, int64_t, const Vector2 &);
  215. virtual Rect2 font_get_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  216. virtual void font_set_glyph_uv_rect(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, const Rect2 &p_uv_rect) override;
  217. GDVIRTUAL3RC(Rect2, _font_get_glyph_uv_rect, RID, const Vector2i &, int64_t);
  218. GDVIRTUAL4(_font_set_glyph_uv_rect, RID, const Vector2i &, int64_t, const Rect2 &);
  219. virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  220. virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override;
  221. GDVIRTUAL3RC(int64_t, _font_get_glyph_texture_idx, RID, const Vector2i &, int64_t);
  222. GDVIRTUAL4(_font_set_glyph_texture_idx, RID, const Vector2i &, int64_t, int64_t);
  223. virtual RID font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  224. GDVIRTUAL3RC(RID, _font_get_glyph_texture_rid, RID, const Vector2i &, int64_t);
  225. virtual Size2 font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
  226. GDVIRTUAL3RC(Size2, _font_get_glyph_texture_size, RID, const Vector2i &, int64_t);
  227. virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override;
  228. GDVIRTUAL3RC(Dictionary, _font_get_glyph_contours, RID, int64_t, int64_t);
  229. virtual TypedArray<Vector2i> font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const override;
  230. virtual void font_clear_kerning_map(const RID &p_font_rid, int64_t p_size) override;
  231. virtual void font_remove_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) override;
  232. GDVIRTUAL2RC(TypedArray<Vector2i>, _font_get_kerning_list, RID, int64_t);
  233. GDVIRTUAL2(_font_clear_kerning_map, RID, int64_t);
  234. GDVIRTUAL3(_font_remove_kerning, RID, int64_t, const Vector2i &);
  235. virtual void font_set_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) override;
  236. virtual Vector2 font_get_kerning(const RID &p_font_rid, int64_t p_size, const Vector2i &p_glyph_pair) const override;
  237. GDVIRTUAL4(_font_set_kerning, RID, int64_t, const Vector2i &, const Vector2 &);
  238. GDVIRTUAL3RC(Vector2, _font_get_kerning, RID, int64_t, const Vector2i &);
  239. virtual int64_t font_get_glyph_index(const RID &p_font_rid, int64_t p_size, int64_t p_char, int64_t p_variation_selector = 0) const override;
  240. GDVIRTUAL4RC(int64_t, _font_get_glyph_index, RID, int64_t, int64_t, int64_t);
  241. virtual bool font_has_char(const RID &p_font_rid, int64_t p_char) const override;
  242. virtual String font_get_supported_chars(const RID &p_font_rid) const override;
  243. GDVIRTUAL2RC(bool, _font_has_char, RID, int64_t);
  244. GDVIRTUAL1RC(String, _font_get_supported_chars, RID);
  245. virtual void font_render_range(const RID &p_font, const Vector2i &p_size, int64_t p_start, int64_t p_end) override;
  246. virtual void font_render_glyph(const RID &p_font_rid, const Vector2i &p_size, int64_t p_index) override;
  247. GDVIRTUAL4(_font_render_range, RID, const Vector2i &, int64_t, int64_t);
  248. GDVIRTUAL3(_font_render_glyph, RID, const Vector2i &, int64_t);
  249. virtual void font_draw_glyph(const RID &p_font, const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
  250. virtual void font_draw_glyph_outline(const RID &p_font, const RID &p_canvas, int64_t p_size, int64_t p_outline_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
  251. GDVIRTUAL6C(_font_draw_glyph, RID, RID, int64_t, const Vector2 &, int64_t, const Color &);
  252. GDVIRTUAL7C(_font_draw_glyph_outline, RID, RID, int64_t, int64_t, const Vector2 &, int64_t, const Color &);
  253. virtual bool font_is_language_supported(const RID &p_font_rid, const String &p_language) const override;
  254. virtual void font_set_language_support_override(const RID &p_font_rid, const String &p_language, bool p_supported) override;
  255. virtual bool font_get_language_support_override(const RID &p_font_rid, const String &p_language) override;
  256. virtual void font_remove_language_support_override(const RID &p_font_rid, const String &p_language) override;
  257. virtual PackedStringArray font_get_language_support_overrides(const RID &p_font_rid) override;
  258. GDVIRTUAL2RC(bool, _font_is_language_supported, RID, const String &);
  259. GDVIRTUAL3(_font_set_language_support_override, RID, const String &, bool);
  260. GDVIRTUAL2R(bool, _font_get_language_support_override, RID, const String &);
  261. GDVIRTUAL2(_font_remove_language_support_override, RID, const String &);
  262. GDVIRTUAL1R(PackedStringArray, _font_get_language_support_overrides, RID);
  263. virtual bool font_is_script_supported(const RID &p_font_rid, const String &p_script) const override;
  264. virtual void font_set_script_support_override(const RID &p_font_rid, const String &p_script, bool p_supported) override;
  265. virtual bool font_get_script_support_override(const RID &p_font_rid, const String &p_script) override;
  266. virtual void font_remove_script_support_override(const RID &p_font_rid, const String &p_script) override;
  267. virtual PackedStringArray font_get_script_support_overrides(const RID &p_font_rid) override;
  268. GDVIRTUAL2RC(bool, _font_is_script_supported, RID, const String &);
  269. GDVIRTUAL3(_font_set_script_support_override, RID, const String &, bool);
  270. GDVIRTUAL2R(bool, _font_get_script_support_override, RID, const String &);
  271. GDVIRTUAL2(_font_remove_script_support_override, RID, const String &);
  272. GDVIRTUAL1R(PackedStringArray, _font_get_script_support_overrides, RID);
  273. virtual void font_set_opentype_feature_overrides(const RID &p_font_rid, const Dictionary &p_overrides) override;
  274. virtual Dictionary font_get_opentype_feature_overrides(const RID &p_font_rid) const override;
  275. GDVIRTUAL2(_font_set_opentype_feature_overrides, RID, const Dictionary &);
  276. GDVIRTUAL1RC(Dictionary, _font_get_opentype_feature_overrides, RID);
  277. virtual Dictionary font_supported_feature_list(const RID &p_font_rid) const override;
  278. virtual Dictionary font_supported_variation_list(const RID &p_font_rid) const override;
  279. GDVIRTUAL1RC(Dictionary, _font_supported_feature_list, RID);
  280. GDVIRTUAL1RC(Dictionary, _font_supported_variation_list, RID);
  281. virtual double font_get_global_oversampling() const override;
  282. virtual void font_set_global_oversampling(double p_oversampling) override;
  283. GDVIRTUAL0RC(double, _font_get_global_oversampling);
  284. GDVIRTUAL1(_font_set_global_oversampling, double);
  285. virtual Vector2 get_hex_code_box_size(int64_t p_size, int64_t p_index) const override;
  286. virtual void draw_hex_code_box(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, int64_t p_index, const Color &p_color) const override;
  287. GDVIRTUAL2RC(Vector2, _get_hex_code_box_size, int64_t, int64_t);
  288. GDVIRTUAL5C(_draw_hex_code_box, RID, int64_t, const Vector2 &, int64_t, const Color &);
  289. /* Shaped text buffer interface */
  290. virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
  291. GDVIRTUAL2R(RID, _create_shaped_text, Direction, Orientation);
  292. virtual void shaped_text_clear(const RID &p_shaped) override;
  293. GDVIRTUAL1(_shaped_text_clear, RID);
  294. virtual void shaped_text_set_direction(const RID &p_shaped, Direction p_direction = DIRECTION_AUTO) override;
  295. virtual Direction shaped_text_get_direction(const RID &p_shaped) const override;
  296. virtual Direction shaped_text_get_inferred_direction(const RID &p_shaped) const override;
  297. GDVIRTUAL2(_shaped_text_set_direction, RID, Direction);
  298. GDVIRTUAL1RC(Direction, _shaped_text_get_direction, RID);
  299. GDVIRTUAL1RC(Direction, _shaped_text_get_inferred_direction, RID);
  300. virtual void shaped_text_set_bidi_override(const RID &p_shaped, const Array &p_override) override;
  301. GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &);
  302. virtual void shaped_text_set_custom_punctuation(const RID &p_shaped, const String &p_punct) override;
  303. virtual String shaped_text_get_custom_punctuation(const RID &p_shaped) const override;
  304. GDVIRTUAL2(_shaped_text_set_custom_punctuation, RID, String);
  305. GDVIRTUAL1RC(String, _shaped_text_get_custom_punctuation, RID);
  306. virtual void shaped_text_set_orientation(const RID &p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
  307. virtual Orientation shaped_text_get_orientation(const RID &p_shaped) const override;
  308. GDVIRTUAL2(_shaped_text_set_orientation, RID, Orientation);
  309. GDVIRTUAL1RC(Orientation, _shaped_text_get_orientation, RID);
  310. virtual void shaped_text_set_preserve_invalid(const RID &p_shaped, bool p_enabled) override;
  311. virtual bool shaped_text_get_preserve_invalid(const RID &p_shaped) const override;
  312. GDVIRTUAL2(_shaped_text_set_preserve_invalid, RID, bool);
  313. GDVIRTUAL1RC(bool, _shaped_text_get_preserve_invalid, RID);
  314. virtual void shaped_text_set_preserve_control(const RID &p_shaped, bool p_enabled) override;
  315. virtual bool shaped_text_get_preserve_control(const RID &p_shaped) const override;
  316. GDVIRTUAL2(_shaped_text_set_preserve_control, RID, bool);
  317. GDVIRTUAL1RC(bool, _shaped_text_get_preserve_control, RID);
  318. virtual void shaped_text_set_spacing(const RID &p_shaped, SpacingType p_spacing, int64_t p_value) override;
  319. virtual int64_t shaped_text_get_spacing(const RID &p_shaped, SpacingType p_spacing) const override;
  320. GDVIRTUAL3(_shaped_text_set_spacing, RID, SpacingType, int64_t);
  321. GDVIRTUAL2RC(int64_t, _shaped_text_get_spacing, RID, SpacingType);
  322. virtual bool shaped_text_add_string(const RID &p_shaped, const String &p_text, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "", const Variant &p_meta = Variant()) override;
  323. virtual bool shaped_text_add_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, int64_t p_length = 1, double p_baseline = 0.0) override;
  324. virtual bool shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align = INLINE_ALIGNMENT_CENTER, double p_baseline = 0.0) override;
  325. GDVIRTUAL7R(bool, _shaped_text_add_string, RID, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);
  326. GDVIRTUAL6R(bool, _shaped_text_add_object, RID, const Variant &, const Size2 &, InlineAlignment, int64_t, double);
  327. GDVIRTUAL5R(bool, _shaped_text_resize_object, RID, const Variant &, const Size2 &, InlineAlignment, double);
  328. virtual int64_t shaped_get_span_count(const RID &p_shaped) const override;
  329. virtual Variant shaped_get_span_meta(const RID &p_shaped, int64_t p_index) const override;
  330. virtual void shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features = Dictionary()) override;
  331. GDVIRTUAL1RC(int64_t, _shaped_get_span_count, RID);
  332. GDVIRTUAL2RC(Variant, _shaped_get_span_meta, RID, int64_t);
  333. GDVIRTUAL5(_shaped_set_span_update_font, RID, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &);
  334. virtual RID shaped_text_substr(const RID &p_shaped, int64_t p_start, int64_t p_length) const override;
  335. virtual RID shaped_text_get_parent(const RID &p_shaped) const override;
  336. GDVIRTUAL3RC(RID, _shaped_text_substr, RID, int64_t, int64_t);
  337. GDVIRTUAL1RC(RID, _shaped_text_get_parent, RID);
  338. virtual double shaped_text_fit_to_width(const RID &p_shaped, double p_width, BitField<TextServer::JustificationFlag> p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
  339. virtual double shaped_text_tab_align(const RID &p_shaped, const PackedFloat32Array &p_tab_stops) override;
  340. GDVIRTUAL3R(double, _shaped_text_fit_to_width, RID, double, BitField<TextServer::JustificationFlag>);
  341. GDVIRTUAL2R(double, _shaped_text_tab_align, RID, const PackedFloat32Array &);
  342. virtual bool shaped_text_shape(const RID &p_shaped) override;
  343. virtual bool shaped_text_update_breaks(const RID &p_shaped) override;
  344. virtual bool shaped_text_update_justification_ops(const RID &p_shaped) override;
  345. GDVIRTUAL1R(bool, _shaped_text_shape, RID);
  346. GDVIRTUAL1R(bool, _shaped_text_update_breaks, RID);
  347. GDVIRTUAL1R(bool, _shaped_text_update_justification_ops, RID);
  348. virtual bool shaped_text_is_ready(const RID &p_shaped) const override;
  349. GDVIRTUAL1RC(bool, _shaped_text_is_ready, RID);
  350. virtual const Glyph *shaped_text_get_glyphs(const RID &p_shaped) const override;
  351. virtual const Glyph *shaped_text_sort_logical(const RID &p_shaped) override;
  352. virtual int64_t shaped_text_get_glyph_count(const RID &p_shaped) const override;
  353. GDVIRTUAL1RC(GDExtensionConstPtr<const Glyph>, _shaped_text_get_glyphs, RID);
  354. GDVIRTUAL1R(GDExtensionConstPtr<const Glyph>, _shaped_text_sort_logical, RID);
  355. GDVIRTUAL1RC(int64_t, _shaped_text_get_glyph_count, RID);
  356. virtual Vector2i shaped_text_get_range(const RID &p_shaped) const override;
  357. GDVIRTUAL1RC(Vector2i, _shaped_text_get_range, RID);
  358. virtual PackedInt32Array shaped_text_get_line_breaks_adv(const RID &p_shaped, const PackedFloat32Array &p_width, int64_t p_start = 0, bool p_once = true, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
  359. virtual PackedInt32Array shaped_text_get_line_breaks(const RID &p_shaped, double p_width, int64_t p_start = 0, BitField<TextServer::LineBreakFlag> p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
  360. virtual PackedInt32Array shaped_text_get_word_breaks(const RID &p_shaped, BitField<TextServer::GraphemeFlag> p_grapheme_flags = GRAPHEME_IS_SPACE | GRAPHEME_IS_PUNCTUATION) const override;
  361. GDVIRTUAL5RC(PackedInt32Array, _shaped_text_get_line_breaks_adv, RID, const PackedFloat32Array &, int64_t, bool, BitField<TextServer::LineBreakFlag>);
  362. GDVIRTUAL4RC(PackedInt32Array, _shaped_text_get_line_breaks, RID, double, int64_t, BitField<TextServer::LineBreakFlag>);
  363. GDVIRTUAL2RC(PackedInt32Array, _shaped_text_get_word_breaks, RID, BitField<TextServer::GraphemeFlag>);
  364. virtual int64_t shaped_text_get_trim_pos(const RID &p_shaped) const override;
  365. virtual int64_t shaped_text_get_ellipsis_pos(const RID &p_shaped) const override;
  366. virtual const Glyph *shaped_text_get_ellipsis_glyphs(const RID &p_shaped) const override;
  367. virtual int64_t shaped_text_get_ellipsis_glyph_count(const RID &p_shaped) const override;
  368. GDVIRTUAL1RC(int64_t, _shaped_text_get_trim_pos, RID);
  369. GDVIRTUAL1RC(int64_t, _shaped_text_get_ellipsis_pos, RID);
  370. GDVIRTUAL1RC(GDExtensionConstPtr<const Glyph>, _shaped_text_get_ellipsis_glyphs, RID);
  371. GDVIRTUAL1RC(int64_t, _shaped_text_get_ellipsis_glyph_count, RID);
  372. virtual void shaped_text_overrun_trim_to_width(const RID &p_shaped, double p_width, BitField<TextServer::TextOverrunFlag> p_trim_flags) override;
  373. GDVIRTUAL3(_shaped_text_overrun_trim_to_width, RID, double, BitField<TextServer::TextOverrunFlag>);
  374. virtual Array shaped_text_get_objects(const RID &p_shaped) const override;
  375. virtual Rect2 shaped_text_get_object_rect(const RID &p_shaped, const Variant &p_key) const override;
  376. GDVIRTUAL1RC(Array, _shaped_text_get_objects, RID);
  377. GDVIRTUAL2RC(Rect2, _shaped_text_get_object_rect, RID, const Variant &);
  378. virtual Size2 shaped_text_get_size(const RID &p_shaped) const override;
  379. virtual double shaped_text_get_ascent(const RID &p_shaped) const override;
  380. virtual double shaped_text_get_descent(const RID &p_shaped) const override;
  381. virtual double shaped_text_get_width(const RID &p_shaped) const override;
  382. virtual double shaped_text_get_underline_position(const RID &p_shaped) const override;
  383. virtual double shaped_text_get_underline_thickness(const RID &p_shaped) const override;
  384. GDVIRTUAL1RC(Size2, _shaped_text_get_size, RID);
  385. GDVIRTUAL1RC(double, _shaped_text_get_ascent, RID);
  386. GDVIRTUAL1RC(double, _shaped_text_get_descent, RID);
  387. GDVIRTUAL1RC(double, _shaped_text_get_width, RID);
  388. GDVIRTUAL1RC(double, _shaped_text_get_underline_position, RID);
  389. GDVIRTUAL1RC(double, _shaped_text_get_underline_thickness, RID);
  390. virtual Direction shaped_text_get_dominant_direction_in_range(const RID &p_shaped, int64_t p_start, int64_t p_end) const override;
  391. GDVIRTUAL3RC(int64_t, _shaped_text_get_dominant_direction_in_range, RID, int64_t, int64_t);
  392. virtual CaretInfo shaped_text_get_carets(const RID &p_shaped, int64_t p_position) const override;
  393. virtual Vector<Vector2> shaped_text_get_selection(const RID &p_shaped, int64_t p_start, int64_t p_end) const override;
  394. GDVIRTUAL3C(_shaped_text_get_carets, RID, int64_t, GDExtensionPtr<CaretInfo>);
  395. GDVIRTUAL3RC(Vector<Vector2>, _shaped_text_get_selection, RID, int64_t, int64_t);
  396. virtual int64_t shaped_text_hit_test_grapheme(const RID &p_shaped, double p_coords) const override;
  397. virtual int64_t shaped_text_hit_test_position(const RID &p_shaped, double p_coords) const override;
  398. GDVIRTUAL2RC(int64_t, _shaped_text_hit_test_grapheme, RID, double);
  399. GDVIRTUAL2RC(int64_t, _shaped_text_hit_test_position, RID, double);
  400. virtual void shaped_text_draw(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, const Color &p_color = Color(1, 1, 1)) const override;
  401. virtual void shaped_text_draw_outline(const RID &p_shaped, const RID &p_canvas, const Vector2 &p_pos, double p_clip_l = -1.0, double p_clip_r = -1.0, int64_t p_outline_size = 1, const Color &p_color = Color(1, 1, 1)) const override;
  402. GDVIRTUAL6C(_shaped_text_draw, RID, RID, const Vector2 &, double, double, const Color &);
  403. GDVIRTUAL7C(_shaped_text_draw_outline, RID, RID, const Vector2 &, double, double, int64_t, const Color &);
  404. virtual Vector2 shaped_text_get_grapheme_bounds(const RID &p_shaped, int64_t p_pos) const override;
  405. virtual int64_t shaped_text_next_grapheme_pos(const RID &p_shaped, int64_t p_pos) const override;
  406. virtual int64_t shaped_text_prev_grapheme_pos(const RID &p_shaped, int64_t p_pos) const override;
  407. GDVIRTUAL2RC(Vector2, _shaped_text_get_grapheme_bounds, RID, int64_t);
  408. GDVIRTUAL2RC(int64_t, _shaped_text_next_grapheme_pos, RID, int64_t);
  409. GDVIRTUAL2RC(int64_t, _shaped_text_prev_grapheme_pos, RID, int64_t);
  410. virtual String format_number(const String &p_string, const String &p_language = "") const override;
  411. virtual String parse_number(const String &p_string, const String &p_language = "") const override;
  412. virtual String percent_sign(const String &p_language = "") const override;
  413. GDVIRTUAL2RC(String, _format_number, const String &, const String &);
  414. GDVIRTUAL2RC(String, _parse_number, const String &, const String &);
  415. GDVIRTUAL1RC(String, _percent_sign, const String &);
  416. virtual String strip_diacritics(const String &p_string) const override;
  417. GDVIRTUAL1RC(String, _strip_diacritics, const String &);
  418. virtual PackedInt32Array string_get_word_breaks(const String &p_string, const String &p_language = "", int64_t p_chars_per_line = 0) const override;
  419. GDVIRTUAL3RC(PackedInt32Array, _string_get_word_breaks, const String &, const String &, int64_t);
  420. virtual bool is_valid_identifier(const String &p_string) const override;
  421. GDVIRTUAL1RC(bool, _is_valid_identifier, const String &);
  422. virtual String string_to_upper(const String &p_string, const String &p_language = "") const override;
  423. virtual String string_to_lower(const String &p_string, const String &p_language = "") const override;
  424. GDVIRTUAL2RC(String, _string_to_upper, const String &, const String &);
  425. GDVIRTUAL2RC(String, _string_to_lower, const String &, const String &);
  426. TypedArray<Vector3i> parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
  427. GDVIRTUAL3RC(TypedArray<Vector3i>, _parse_structured_text, StructuredTextParser, const Array &, const String &);
  428. virtual int64_t is_confusable(const String &p_string, const PackedStringArray &p_dict) const override;
  429. virtual bool spoof_check(const String &p_string) const override;
  430. GDVIRTUAL2RC(int64_t, _is_confusable, const String &, const PackedStringArray &);
  431. GDVIRTUAL1RC(bool, _spoof_check, const String &);
  432. virtual void cleanup() override;
  433. GDVIRTUAL0(_cleanup);
  434. TextServerExtension();
  435. ~TextServerExtension();
  436. };
  437. #endif // TEXT_SERVER_EXTENSION_H