text_server_gdnative.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*************************************************************************/
  2. /* text_server_gdnative.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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_GDNATIVE_H
  31. #define TEXT_SERVER_GDNATIVE_H
  32. #include "modules/gdnative/gdnative.h"
  33. #include "servers/text_server.h"
  34. class TextServerGDNative : public TextServer {
  35. GDCLASS(TextServerGDNative, TextServer);
  36. const godot_text_interface_gdnative *interface = nullptr;
  37. void *data = nullptr;
  38. protected:
  39. static void _bind_methods(){};
  40. public:
  41. virtual bool has_feature(Feature p_feature) override;
  42. virtual String get_name() const override;
  43. virtual void free(RID p_rid) override;
  44. virtual bool has(RID p_rid) override;
  45. virtual bool load_support_data(const String &p_filename) override;
  46. #ifdef TOOLS_ENABLED
  47. virtual String get_support_data_filename() override;
  48. virtual String get_support_data_info() override;
  49. virtual bool save_support_data(const String &p_filename) override;
  50. #endif
  51. virtual bool is_locale_right_to_left(const String &p_locale) override;
  52. /* Font interface */
  53. virtual RID create_font_system(const String &p_name, int p_base_size = 16) override;
  54. virtual RID create_font_resource(const String &p_filename, int p_base_size = 16) override;
  55. virtual RID create_font_memory(const uint8_t *p_data, size_t p_size, const String &p_type, int p_base_size = 16) override;
  56. virtual float font_get_height(RID p_font, int p_size) const override;
  57. virtual float font_get_ascent(RID p_font, int p_size) const override;
  58. virtual float font_get_descent(RID p_font, int p_size) const override;
  59. virtual float font_get_underline_position(RID p_font, int p_size) const override;
  60. virtual float font_get_underline_thickness(RID p_font, int p_size) const override;
  61. virtual int font_get_spacing_space(RID p_font) const override;
  62. virtual void font_set_spacing_space(RID p_font, int p_value) override;
  63. virtual int font_get_spacing_glyph(RID p_font) const override;
  64. virtual void font_set_spacing_glyph(RID p_font, int p_value) override;
  65. virtual void font_set_antialiased(RID p_font, bool p_antialiased) override;
  66. virtual bool font_get_antialiased(RID p_font) const override;
  67. virtual Dictionary font_get_feature_list(RID p_font) const override;
  68. virtual Dictionary font_get_variation_list(RID p_font) const override;
  69. virtual void font_set_variation(RID p_font, const String &p_name, double p_value) override;
  70. virtual double font_get_variation(RID p_font, const String &p_name) const override;
  71. virtual void font_set_hinting(RID p_font, Hinting p_hinting) override;
  72. virtual Hinting font_get_hinting(RID p_font) const override;
  73. virtual void font_set_distance_field_hint(RID p_font, bool p_distance_field) override;
  74. virtual bool font_get_distance_field_hint(RID p_font) const override;
  75. virtual void font_set_force_autohinter(RID p_font, bool p_enabeld) override;
  76. virtual bool font_get_force_autohinter(RID p_font) const override;
  77. virtual bool font_has_char(RID p_font, char32_t p_char) const override;
  78. virtual String font_get_supported_chars(RID p_font) const override;
  79. virtual bool font_has_outline(RID p_font) const override;
  80. virtual float font_get_base_size(RID p_font) const override;
  81. virtual bool font_is_language_supported(RID p_font, const String &p_language) const override;
  82. virtual void font_set_language_support_override(RID p_font, const String &p_language, bool p_supported) override;
  83. virtual bool font_get_language_support_override(RID p_font, const String &p_language) override;
  84. virtual void font_remove_language_support_override(RID p_font, const String &p_language) override;
  85. Vector<String> font_get_language_support_overrides(RID p_font) override;
  86. virtual bool font_is_script_supported(RID p_font, const String &p_script) const override;
  87. virtual void font_set_script_support_override(RID p_font, const String &p_script, bool p_supported) override;
  88. virtual bool font_get_script_support_override(RID p_font, const String &p_script) override;
  89. virtual void font_remove_script_support_override(RID p_font, const String &p_script) override;
  90. Vector<String> font_get_script_support_overrides(RID p_font) override;
  91. virtual uint32_t font_get_glyph_index(RID p_font, char32_t p_char, char32_t p_variation_selector = 0x0000) const override;
  92. virtual Vector2 font_get_glyph_advance(RID p_font, uint32_t p_index, int p_size) const override;
  93. virtual Vector2 font_get_glyph_kerning(RID p_font, uint32_t p_index_a, uint32_t p_index_b, int p_size) const override;
  94. virtual Vector2 font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, uint32_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
  95. virtual Vector2 font_draw_glyph_outline(RID p_font, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, uint32_t p_index, const Color &p_color = Color(1, 1, 1)) const override;
  96. virtual float font_get_oversampling() const override;
  97. virtual void font_set_oversampling(float p_oversampling) override;
  98. virtual Vector<String> get_system_fonts() const override;
  99. /* Shaped text buffer interface */
  100. virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
  101. virtual void shaped_text_clear(RID p_shaped) override;
  102. virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override;
  103. virtual Direction shaped_text_get_direction(RID p_shaped) const override;
  104. virtual void shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) override;
  105. virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
  106. virtual Orientation shaped_text_get_orientation(RID p_shaped) const override;
  107. virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override;
  108. virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override;
  109. virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override;
  110. virtual bool shaped_text_get_preserve_control(RID p_shaped) const override;
  111. virtual bool shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features = Dictionary(), const String &p_language = "") override;
  112. virtual bool shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER, int p_length = 1) override;
  113. virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER) override;
  114. virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override;
  115. virtual RID shaped_text_get_parent(RID p_shaped) const override;
  116. virtual float shaped_text_fit_to_width(RID p_shaped, float p_width, uint8_t /*JustificationFlag*/ p_jst_flags = JUSTIFICATION_WORD_BOUND | JUSTIFICATION_KASHIDA) override;
  117. virtual float shaped_text_tab_align(RID p_shaped, const Vector<float> &p_tab_stops) override;
  118. virtual bool shaped_text_shape(RID p_shaped) override;
  119. virtual bool shaped_text_update_breaks(RID p_shaped) override;
  120. virtual bool shaped_text_update_justification_ops(RID p_shaped) override;
  121. virtual bool shaped_text_is_ready(RID p_shaped) const override;
  122. virtual Vector<Glyph> shaped_text_get_glyphs(RID p_shaped) const override;
  123. virtual Vector2i shaped_text_get_range(RID p_shaped) const override;
  124. virtual Vector<Glyph> shaped_text_sort_logical(RID p_shaped) override;
  125. virtual Vector<Vector2i> shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<float> &p_width, int p_start = 0, bool p_once = true, uint8_t /*TextBreakFlag*/ p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
  126. virtual Vector<Vector2i> shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start = 0, uint8_t p_break_flags = BREAK_MANDATORY | BREAK_WORD_BOUND) const override;
  127. virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped) const override;
  128. virtual Array shaped_text_get_objects(RID p_shaped) const override;
  129. virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override;
  130. virtual Size2 shaped_text_get_size(RID p_shaped) const override;
  131. virtual float shaped_text_get_ascent(RID p_shaped) const override;
  132. virtual float shaped_text_get_descent(RID p_shaped) const override;
  133. virtual float shaped_text_get_width(RID p_shaped) const override;
  134. virtual float shaped_text_get_underline_position(RID p_shaped) const override;
  135. virtual float shaped_text_get_underline_thickness(RID p_shaped) const override;
  136. virtual String format_number(const String &p_string, const String &p_language = "") const override;
  137. virtual String parse_number(const String &p_string, const String &p_language = "") const override;
  138. virtual String percent_sign(const String &p_language = "") const override;
  139. static TextServer *create_func(Error &r_error, void *p_user_data);
  140. TextServerGDNative();
  141. ~TextServerGDNative();
  142. };
  143. #endif // TEXT_SERVER_GDNATIVE_H