text_server_extension.cpp 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281
  1. /*************************************************************************/
  2. /* text_server_extension.cpp */
  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. #include "text_server_extension.h"
  31. void TextServerExtension::_bind_methods() {
  32. GDVIRTUAL_BIND(_has_feature, "feature");
  33. GDVIRTUAL_BIND(_get_name);
  34. GDVIRTUAL_BIND(_get_features);
  35. GDVIRTUAL_BIND(_free, "rid");
  36. GDVIRTUAL_BIND(_has, "rid");
  37. GDVIRTUAL_BIND(_load_support_data, "filename");
  38. GDVIRTUAL_BIND(_get_support_data_filename);
  39. GDVIRTUAL_BIND(_get_support_data_info);
  40. GDVIRTUAL_BIND(_save_support_data, "filename");
  41. GDVIRTUAL_BIND(_is_locale_right_to_left, "locale");
  42. GDVIRTUAL_BIND(_name_to_tag, "name");
  43. GDVIRTUAL_BIND(_tag_to_name, "tag");
  44. /* Font interface */
  45. GDVIRTUAL_BIND(_create_font);
  46. GDVIRTUAL_BIND(_font_set_data, "font_rid", "data");
  47. GDVIRTUAL_BIND(_font_set_data_ptr, "font_rid", "data_ptr", "data_size");
  48. GDVIRTUAL_BIND(_font_set_antialiased, "font_rid", "antialiased");
  49. GDVIRTUAL_BIND(_font_is_antialiased, "font_rid");
  50. GDVIRTUAL_BIND(_font_set_multichannel_signed_distance_field, "font_rid", "msdf");
  51. GDVIRTUAL_BIND(_font_is_multichannel_signed_distance_field, "font_rid");
  52. GDVIRTUAL_BIND(_font_set_msdf_pixel_range, "font_rid", "msdf_pixel_range");
  53. GDVIRTUAL_BIND(_font_get_msdf_pixel_range, "font_rid");
  54. GDVIRTUAL_BIND(_font_set_msdf_size, "font_rid", "msdf_size");
  55. GDVIRTUAL_BIND(_font_get_msdf_size, "font_rid");
  56. GDVIRTUAL_BIND(_font_set_fixed_size, "font_rid", "fixed_size");
  57. GDVIRTUAL_BIND(_font_get_fixed_size, "font_rid");
  58. GDVIRTUAL_BIND(_font_set_force_autohinter, "font_rid", "force_autohinter");
  59. GDVIRTUAL_BIND(_font_is_force_autohinter, "font_rid");
  60. GDVIRTUAL_BIND(_font_set_hinting, "font_rid", "hinting");
  61. GDVIRTUAL_BIND(_font_get_hinting, "font_rid");
  62. GDVIRTUAL_BIND(_font_set_variation_coordinates, "font_rid", "variation_coordinates");
  63. GDVIRTUAL_BIND(_font_get_variation_coordinates, "font_rid");
  64. GDVIRTUAL_BIND(_font_set_oversampling, "font_rid", "oversampling");
  65. GDVIRTUAL_BIND(_font_get_oversampling, "font_rid");
  66. GDVIRTUAL_BIND(_font_get_size_cache_list, "font_rid");
  67. GDVIRTUAL_BIND(_font_clear_size_cache, "font_rid");
  68. GDVIRTUAL_BIND(_font_remove_size_cache, "font_rid", "size");
  69. GDVIRTUAL_BIND(_font_set_ascent, "font_rid", "size", "ascent");
  70. GDVIRTUAL_BIND(_font_get_ascent, "font_rid", "size");
  71. GDVIRTUAL_BIND(_font_set_descent, "font_rid", "size", "descent");
  72. GDVIRTUAL_BIND(_font_get_descent, "font_rid", "size");
  73. GDVIRTUAL_BIND(_font_set_underline_position, "font_rid", "size", "underline_position");
  74. GDVIRTUAL_BIND(_font_get_underline_position, "font_rid", "size");
  75. GDVIRTUAL_BIND(_font_set_underline_thickness, "font_rid", "size", "underline_thickness");
  76. GDVIRTUAL_BIND(_font_get_underline_thickness, "font_rid", "size");
  77. GDVIRTUAL_BIND(_font_set_scale, "font_rid", "size", "scale");
  78. GDVIRTUAL_BIND(_font_get_scale, "font_rid", "size");
  79. GDVIRTUAL_BIND(_font_set_spacing, "font_rid", "size", "spacing", "value");
  80. GDVIRTUAL_BIND(_font_get_spacing, "font_rid", "size", "spacing");
  81. GDVIRTUAL_BIND(_font_get_texture_count, "font_rid", "size");
  82. GDVIRTUAL_BIND(_font_clear_textures, "font_rid", "size");
  83. GDVIRTUAL_BIND(_font_remove_texture, "font_rid", "size", "texture_index");
  84. GDVIRTUAL_BIND(_font_set_texture_image, "font_rid", "size", "texture_index", "image");
  85. GDVIRTUAL_BIND(_font_get_texture_image, "font_rid", "size", "texture_index");
  86. GDVIRTUAL_BIND(_font_set_texture_offsets, "font_rid", "size", "texture_index", "offset");
  87. GDVIRTUAL_BIND(_font_get_texture_offsets, "font_rid", "size", "texture_index");
  88. GDVIRTUAL_BIND(_font_get_glyph_list, "font_rid", "size");
  89. GDVIRTUAL_BIND(_font_clear_glyphs, "font_rid", "size");
  90. GDVIRTUAL_BIND(_font_remove_glyph, "font_rid", "size", "glyph");
  91. GDVIRTUAL_BIND(_font_get_glyph_advance, "font_rid", "size", "glyph");
  92. GDVIRTUAL_BIND(_font_set_glyph_advance, "font_rid", "size", "glyph", "advance");
  93. GDVIRTUAL_BIND(_font_get_glyph_offset, "font_rid", "size", "glyph");
  94. GDVIRTUAL_BIND(_font_set_glyph_offset, "font_rid", "size", "glyph", "offset");
  95. GDVIRTUAL_BIND(_font_get_glyph_size, "font_rid", "size", "glyph");
  96. GDVIRTUAL_BIND(_font_set_glyph_size, "font_rid", "size", "glyph", "gl_size");
  97. GDVIRTUAL_BIND(_font_get_glyph_uv_rect, "font_rid", "size", "glyph");
  98. GDVIRTUAL_BIND(_font_set_glyph_uv_rect, "font_rid", "size", "glyph", "uv_rect");
  99. GDVIRTUAL_BIND(_font_get_glyph_texture_idx, "font_rid", "size", "glyph");
  100. GDVIRTUAL_BIND(_font_set_glyph_texture_idx, "font_rid", "size", "glyph", "texture_idx");
  101. GDVIRTUAL_BIND(_font_get_glyph_contours, "font_rid", "size", "index");
  102. GDVIRTUAL_BIND(_font_get_kerning_list, "font_rid", "size");
  103. GDVIRTUAL_BIND(_font_clear_kerning_map, "font_rid", "size");
  104. GDVIRTUAL_BIND(_font_remove_kerning, "font_rid", "size", "glyph_pair");
  105. GDVIRTUAL_BIND(_font_set_kerning, "font_rid", "size", "glyph_pair", "kerning");
  106. GDVIRTUAL_BIND(_font_get_kerning, "font_rid", "size", "glyph_pair");
  107. GDVIRTUAL_BIND(_font_get_glyph_index, "font_rid", "size", "char", "variation_selector");
  108. GDVIRTUAL_BIND(_font_has_char, "font_rid", "char");
  109. GDVIRTUAL_BIND(_font_get_supported_chars, "font_rid");
  110. GDVIRTUAL_BIND(_font_render_range, "font_rid", "size", "start", "end");
  111. GDVIRTUAL_BIND(_font_render_glyph, "font_rid", "size", "index");
  112. GDVIRTUAL_BIND(_font_draw_glyph, "font_rid", "canvas", "size", "pos", "index", "color");
  113. GDVIRTUAL_BIND(_font_draw_glyph_outline, "font_rid", "canvas", "size", "outline_size", "pos", "index", "color");
  114. GDVIRTUAL_BIND(_font_is_language_supported, "font_rid", "language");
  115. GDVIRTUAL_BIND(_font_set_language_support_override, "font_rid", "language", "supported");
  116. GDVIRTUAL_BIND(_font_get_language_support_override, "font_rid", "language");
  117. GDVIRTUAL_BIND(_font_remove_language_support_override, "font_rid", "language");
  118. GDVIRTUAL_BIND(_font_get_language_support_overrides, "font_rid");
  119. GDVIRTUAL_BIND(_font_is_script_supported, "font_rid", "script");
  120. GDVIRTUAL_BIND(_font_set_script_support_override, "font_rid", "script", "supported");
  121. GDVIRTUAL_BIND(_font_get_script_support_override, "font_rid", "script");
  122. GDVIRTUAL_BIND(_font_remove_script_support_override, "font_rid", "script");
  123. GDVIRTUAL_BIND(_font_get_script_support_overrides, "font_rid");
  124. GDVIRTUAL_BIND(_font_supported_feature_list, "font_rid");
  125. GDVIRTUAL_BIND(_font_supported_variation_list, "font_rid");
  126. GDVIRTUAL_BIND(_font_get_global_oversampling);
  127. GDVIRTUAL_BIND(_font_set_global_oversampling, "oversampling");
  128. GDVIRTUAL_BIND(_get_hex_code_box_size, "size", "index");
  129. GDVIRTUAL_BIND(_draw_hex_code_box, "canvas", "size", "pos", "index", "color");
  130. /* Shaped text buffer interface */
  131. GDVIRTUAL_BIND(_create_shaped_text, "direction", "orientation");
  132. GDVIRTUAL_BIND(_shaped_text_clear, "shaped");
  133. GDVIRTUAL_BIND(_shaped_text_set_direction, "shaped", "direction");
  134. GDVIRTUAL_BIND(_shaped_text_get_direction, "shaped");
  135. GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override");
  136. GDVIRTUAL_BIND(_shaped_text_set_orientation, "shaped", "orientation");
  137. GDVIRTUAL_BIND(_shaped_text_get_orientation, "shaped");
  138. GDVIRTUAL_BIND(_shaped_text_set_preserve_invalid, "shaped", "enabled");
  139. GDVIRTUAL_BIND(_shaped_text_get_preserve_invalid, "shaped");
  140. GDVIRTUAL_BIND(_shaped_text_set_preserve_control, "shaped", "enabled");
  141. GDVIRTUAL_BIND(_shaped_text_get_preserve_control, "shaped");
  142. GDVIRTUAL_BIND(_shaped_text_add_string, "shaped", "text", "fonts", "size", "opentype_features", "language");
  143. GDVIRTUAL_BIND(_shaped_text_add_object, "shaped", "key", "size", "inline_align", "length");
  144. GDVIRTUAL_BIND(_shaped_text_resize_object, "shaped", "key", "size", "inline_align");
  145. GDVIRTUAL_BIND(_shaped_text_substr, "shaped", "start", "length");
  146. GDVIRTUAL_BIND(_shaped_text_get_parent, "shaped");
  147. GDVIRTUAL_BIND(_shaped_text_fit_to_width, "shaped", "width", "jst_flags");
  148. GDVIRTUAL_BIND(_shaped_text_tab_align, "shaped", "tab_stops");
  149. GDVIRTUAL_BIND(_shaped_text_shape, "shaped");
  150. GDVIRTUAL_BIND(_shaped_text_update_breaks, "shaped");
  151. GDVIRTUAL_BIND(_shaped_text_update_justification_ops, "shaped");
  152. GDVIRTUAL_BIND(_shaped_text_is_ready, "shaped");
  153. GDVIRTUAL_BIND(_shaped_text_get_glyphs, "shaped", "r_glyphs");
  154. GDVIRTUAL_BIND(_shaped_text_sort_logical, "shaped", "r_glyphs");
  155. GDVIRTUAL_BIND(_shaped_text_get_glyph_count, "shaped");
  156. GDVIRTUAL_BIND(_shaped_text_get_range, "shaped");
  157. GDVIRTUAL_BIND(_shaped_text_get_line_breaks_adv, "shaped", "width", "start", "once", "break_flags");
  158. GDVIRTUAL_BIND(_shaped_text_get_line_breaks, "shaped", "width", "start", "break_flags");
  159. GDVIRTUAL_BIND(_shaped_text_get_word_breaks, "shaped", "grapheme_flags");
  160. GDVIRTUAL_BIND(_shaped_text_get_trim_pos, "shaped");
  161. GDVIRTUAL_BIND(_shaped_text_get_ellipsis_pos, "shaped");
  162. GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyph_count, "shaped");
  163. GDVIRTUAL_BIND(_shaped_text_get_ellipsis_glyphs, "shaped", "r_glyphs");
  164. GDVIRTUAL_BIND(_shaped_text_overrun_trim_to_width, "shaped", "width", "trim_flags");
  165. GDVIRTUAL_BIND(_shaped_text_get_objects, "shaped");
  166. GDVIRTUAL_BIND(_shaped_text_get_object_rect, "shaped", "key");
  167. GDVIRTUAL_BIND(_shaped_text_get_size, "shaped");
  168. GDVIRTUAL_BIND(_shaped_text_get_ascent, "shaped");
  169. GDVIRTUAL_BIND(_shaped_text_get_descent, "shaped");
  170. GDVIRTUAL_BIND(_shaped_text_get_width, "shaped");
  171. GDVIRTUAL_BIND(_shaped_text_get_underline_position, "shaped");
  172. GDVIRTUAL_BIND(_shaped_text_get_underline_thickness, "shaped");
  173. GDVIRTUAL_BIND(_shaped_text_get_dominant_direction_in_range, "shaped", "start", "end");
  174. GDVIRTUAL_BIND(_shaped_text_get_carets, "shaped", "position", "caret");
  175. GDVIRTUAL_BIND(_shaped_text_get_selection, "shaped", "start", "end");
  176. GDVIRTUAL_BIND(_shaped_text_hit_test_grapheme, "shaped", "coord");
  177. GDVIRTUAL_BIND(_shaped_text_hit_test_position, "shaped", "coord");
  178. GDVIRTUAL_BIND(_shaped_text_draw, "shaped", "canvas", "pos", "clip_l", "clip_r", "color");
  179. GDVIRTUAL_BIND(_shaped_text_draw_outline, "shaped", "canvas", "pos", "clip_l", "clip_r", "outline_size", "color");
  180. GDVIRTUAL_BIND(_shaped_text_next_grapheme_pos, "shaped", "pos");
  181. GDVIRTUAL_BIND(_shaped_text_prev_grapheme_pos, "shaped", "pos");
  182. GDVIRTUAL_BIND(_format_number, "string", "language");
  183. GDVIRTUAL_BIND(_parse_number, "string", "language");
  184. GDVIRTUAL_BIND(_percent_sign, "language");
  185. }
  186. bool TextServerExtension::has_feature(Feature p_feature) const {
  187. bool ret;
  188. if (GDVIRTUAL_CALL(_has_feature, p_feature, ret)) {
  189. return ret;
  190. }
  191. return false;
  192. }
  193. String TextServerExtension::get_name() const {
  194. String ret;
  195. if (GDVIRTUAL_CALL(_get_name, ret)) {
  196. return ret;
  197. }
  198. return "Unknown";
  199. }
  200. uint32_t TextServerExtension::get_features() const {
  201. uint32_t ret;
  202. if (GDVIRTUAL_CALL(_get_features, ret)) {
  203. return ret;
  204. }
  205. return 0;
  206. }
  207. void TextServerExtension::free(RID p_rid) {
  208. GDVIRTUAL_CALL(_free, p_rid);
  209. }
  210. bool TextServerExtension::has(RID p_rid) {
  211. bool ret;
  212. if (GDVIRTUAL_CALL(_has, p_rid, ret)) {
  213. return ret;
  214. }
  215. return false;
  216. }
  217. bool TextServerExtension::load_support_data(const String &p_filename) {
  218. bool ret;
  219. if (GDVIRTUAL_CALL(_load_support_data, p_filename, ret)) {
  220. return ret;
  221. }
  222. return false;
  223. }
  224. String TextServerExtension::get_support_data_filename() const {
  225. String ret;
  226. if (GDVIRTUAL_CALL(_get_support_data_filename, ret)) {
  227. return ret;
  228. }
  229. return String();
  230. }
  231. String TextServerExtension::get_support_data_info() const {
  232. String ret;
  233. if (GDVIRTUAL_CALL(_get_support_data_info, ret)) {
  234. return ret;
  235. }
  236. return String();
  237. }
  238. bool TextServerExtension::save_support_data(const String &p_filename) const {
  239. bool ret;
  240. if (GDVIRTUAL_CALL(_save_support_data, p_filename, ret)) {
  241. return ret;
  242. }
  243. return false;
  244. }
  245. bool TextServerExtension::is_locale_right_to_left(const String &p_locale) const {
  246. bool ret;
  247. if (GDVIRTUAL_CALL(_is_locale_right_to_left, p_locale, ret)) {
  248. return ret;
  249. }
  250. return false;
  251. }
  252. int32_t TextServerExtension::name_to_tag(const String &p_name) const {
  253. int32_t ret;
  254. if (GDVIRTUAL_CALL(_name_to_tag, p_name, ret)) {
  255. return ret;
  256. }
  257. return 0;
  258. }
  259. String TextServerExtension::tag_to_name(int32_t p_tag) const {
  260. String ret;
  261. if (GDVIRTUAL_CALL(_tag_to_name, p_tag, ret)) {
  262. return ret;
  263. }
  264. return "";
  265. }
  266. /*************************************************************************/
  267. /* Font */
  268. /*************************************************************************/
  269. RID TextServerExtension::create_font() {
  270. RID ret;
  271. if (GDVIRTUAL_CALL(_create_font, ret)) {
  272. return ret;
  273. }
  274. return RID();
  275. }
  276. void TextServerExtension::font_set_data(RID p_font_rid, const PackedByteArray &p_data) {
  277. GDVIRTUAL_CALL(_font_set_data, p_font_rid, p_data);
  278. }
  279. void TextServerExtension::font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) {
  280. GDVIRTUAL_CALL(_font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size);
  281. }
  282. void TextServerExtension::font_set_antialiased(RID p_font_rid, bool p_antialiased) {
  283. GDVIRTUAL_CALL(_font_set_antialiased, p_font_rid, p_antialiased);
  284. }
  285. bool TextServerExtension::font_is_antialiased(RID p_font_rid) const {
  286. bool ret;
  287. if (GDVIRTUAL_CALL(_font_is_antialiased, p_font_rid, ret)) {
  288. return ret;
  289. }
  290. return false;
  291. }
  292. void TextServerExtension::font_set_multichannel_signed_distance_field(RID p_font_rid, bool p_msdf) {
  293. GDVIRTUAL_CALL(_font_set_multichannel_signed_distance_field, p_font_rid, p_msdf);
  294. }
  295. bool TextServerExtension::font_is_multichannel_signed_distance_field(RID p_font_rid) const {
  296. bool ret;
  297. if (GDVIRTUAL_CALL(_font_is_multichannel_signed_distance_field, p_font_rid, ret)) {
  298. return ret;
  299. }
  300. return false;
  301. }
  302. void TextServerExtension::font_set_msdf_pixel_range(RID p_font_rid, int p_msdf_pixel_range) {
  303. GDVIRTUAL_CALL(_font_set_msdf_pixel_range, p_font_rid, p_msdf_pixel_range);
  304. }
  305. int TextServerExtension::font_get_msdf_pixel_range(RID p_font_rid) const {
  306. int ret;
  307. if (GDVIRTUAL_CALL(_font_get_msdf_pixel_range, p_font_rid, ret)) {
  308. return ret;
  309. }
  310. return 0;
  311. }
  312. void TextServerExtension::font_set_msdf_size(RID p_font_rid, int p_msdf_size) {
  313. GDVIRTUAL_CALL(_font_set_msdf_size, p_font_rid, p_msdf_size);
  314. }
  315. int TextServerExtension::font_get_msdf_size(RID p_font_rid) const {
  316. int ret;
  317. if (GDVIRTUAL_CALL(_font_get_msdf_size, p_font_rid, ret)) {
  318. return ret;
  319. }
  320. return 0;
  321. }
  322. void TextServerExtension::font_set_fixed_size(RID p_font_rid, int p_fixed_size) {
  323. GDVIRTUAL_CALL(_font_set_fixed_size, p_font_rid, p_fixed_size);
  324. }
  325. int TextServerExtension::font_get_fixed_size(RID p_font_rid) const {
  326. int ret;
  327. if (GDVIRTUAL_CALL(_font_get_fixed_size, p_font_rid, ret)) {
  328. return ret;
  329. }
  330. return 0;
  331. }
  332. void TextServerExtension::font_set_force_autohinter(RID p_font_rid, bool p_force_autohinter) {
  333. GDVIRTUAL_CALL(_font_set_force_autohinter, p_font_rid, p_force_autohinter);
  334. }
  335. bool TextServerExtension::font_is_force_autohinter(RID p_font_rid) const {
  336. bool ret;
  337. if (GDVIRTUAL_CALL(_font_is_force_autohinter, p_font_rid, ret)) {
  338. return ret;
  339. }
  340. return false;
  341. }
  342. void TextServerExtension::font_set_hinting(RID p_font_rid, TextServer::Hinting p_hinting) {
  343. GDVIRTUAL_CALL(_font_set_hinting, p_font_rid, p_hinting);
  344. }
  345. TextServer::Hinting TextServerExtension::font_get_hinting(RID p_font_rid) const {
  346. int ret;
  347. if (GDVIRTUAL_CALL(_font_get_hinting, p_font_rid, ret)) {
  348. return (TextServer::Hinting)ret;
  349. }
  350. return TextServer::Hinting::HINTING_NONE;
  351. }
  352. void TextServerExtension::font_set_variation_coordinates(RID p_font_rid, const Dictionary &p_variation_coordinates) {
  353. GDVIRTUAL_CALL(_font_set_variation_coordinates, p_font_rid, p_variation_coordinates);
  354. }
  355. Dictionary TextServerExtension::font_get_variation_coordinates(RID p_font_rid) const {
  356. Dictionary ret;
  357. if (GDVIRTUAL_CALL(_font_get_variation_coordinates, p_font_rid, ret)) {
  358. return ret;
  359. }
  360. return Dictionary();
  361. }
  362. void TextServerExtension::font_set_oversampling(RID p_font_rid, float p_oversampling) {
  363. GDVIRTUAL_CALL(_font_set_oversampling, p_font_rid, p_oversampling);
  364. }
  365. float TextServerExtension::font_get_oversampling(RID p_font_rid) const {
  366. float ret;
  367. if (GDVIRTUAL_CALL(_font_get_oversampling, p_font_rid, ret)) {
  368. return ret;
  369. }
  370. return 0.f;
  371. }
  372. Array TextServerExtension::font_get_size_cache_list(RID p_font_rid) const {
  373. Array ret;
  374. if (GDVIRTUAL_CALL(_font_get_size_cache_list, p_font_rid, ret)) {
  375. return ret;
  376. }
  377. return Array();
  378. }
  379. void TextServerExtension::font_clear_size_cache(RID p_font_rid) {
  380. GDVIRTUAL_CALL(_font_clear_size_cache, p_font_rid);
  381. }
  382. void TextServerExtension::font_remove_size_cache(RID p_font_rid, const Vector2i &p_size) {
  383. GDVIRTUAL_CALL(_font_remove_size_cache, p_font_rid, p_size);
  384. }
  385. void TextServerExtension::font_set_ascent(RID p_font_rid, int p_size, float p_ascent) {
  386. GDVIRTUAL_CALL(_font_set_ascent, p_font_rid, p_size, p_ascent);
  387. }
  388. float TextServerExtension::font_get_ascent(RID p_font_rid, int p_size) const {
  389. float ret;
  390. if (GDVIRTUAL_CALL(_font_get_ascent, p_font_rid, p_size, ret)) {
  391. return ret;
  392. }
  393. return 0.f;
  394. }
  395. void TextServerExtension::font_set_descent(RID p_font_rid, int p_size, float p_descent) {
  396. GDVIRTUAL_CALL(_font_set_descent, p_font_rid, p_size, p_descent);
  397. }
  398. float TextServerExtension::font_get_descent(RID p_font_rid, int p_size) const {
  399. float ret;
  400. if (GDVIRTUAL_CALL(_font_get_descent, p_font_rid, p_size, ret)) {
  401. return ret;
  402. }
  403. return 0.f;
  404. }
  405. void TextServerExtension::font_set_underline_position(RID p_font_rid, int p_size, float p_underline_position) {
  406. GDVIRTUAL_CALL(_font_set_underline_position, p_font_rid, p_size, p_underline_position);
  407. }
  408. float TextServerExtension::font_get_underline_position(RID p_font_rid, int p_size) const {
  409. float ret;
  410. if (GDVIRTUAL_CALL(_font_get_underline_position, p_font_rid, p_size, ret)) {
  411. return ret;
  412. }
  413. return 0.f;
  414. }
  415. void TextServerExtension::font_set_underline_thickness(RID p_font_rid, int p_size, float p_underline_thickness) {
  416. GDVIRTUAL_CALL(_font_set_underline_thickness, p_font_rid, p_size, p_underline_thickness);
  417. }
  418. float TextServerExtension::font_get_underline_thickness(RID p_font_rid, int p_size) const {
  419. float ret;
  420. if (GDVIRTUAL_CALL(_font_get_underline_thickness, p_font_rid, p_size, ret)) {
  421. return ret;
  422. }
  423. return 0.f;
  424. }
  425. void TextServerExtension::font_set_scale(RID p_font_rid, int p_size, float p_scale) {
  426. GDVIRTUAL_CALL(_font_set_scale, p_font_rid, p_size, p_scale);
  427. }
  428. float TextServerExtension::font_get_scale(RID p_font_rid, int p_size) const {
  429. float ret;
  430. if (GDVIRTUAL_CALL(_font_get_scale, p_font_rid, p_size, ret)) {
  431. return ret;
  432. }
  433. return 0.f;
  434. }
  435. void TextServerExtension::font_set_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing, int p_value) {
  436. GDVIRTUAL_CALL(_font_set_spacing, p_font_rid, p_size, p_spacing, p_value);
  437. }
  438. int TextServerExtension::font_get_spacing(RID p_font_rid, int p_size, TextServer::SpacingType p_spacing) const {
  439. int ret;
  440. if (GDVIRTUAL_CALL(_font_get_spacing, p_font_rid, p_size, p_spacing, ret)) {
  441. return ret;
  442. }
  443. return 0;
  444. }
  445. int TextServerExtension::font_get_texture_count(RID p_font_rid, const Vector2i &p_size) const {
  446. int ret;
  447. if (GDVIRTUAL_CALL(_font_get_texture_count, p_font_rid, p_size, ret)) {
  448. return ret;
  449. }
  450. return 0;
  451. }
  452. void TextServerExtension::font_clear_textures(RID p_font_rid, const Vector2i &p_size) {
  453. GDVIRTUAL_CALL(_font_clear_textures, p_font_rid, p_size);
  454. }
  455. void TextServerExtension::font_remove_texture(RID p_font_rid, const Vector2i &p_size, int p_texture_index) {
  456. GDVIRTUAL_CALL(_font_remove_texture, p_font_rid, p_size, p_texture_index);
  457. }
  458. void TextServerExtension::font_set_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const Ref<Image> &p_image) {
  459. GDVIRTUAL_CALL(_font_set_texture_image, p_font_rid, p_size, p_texture_index, p_image);
  460. }
  461. Ref<Image> TextServerExtension::font_get_texture_image(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
  462. Ref<Image> ret;
  463. if (GDVIRTUAL_CALL(_font_get_texture_image, p_font_rid, p_size, p_texture_index, ret)) {
  464. return ret;
  465. }
  466. return Ref<Image>();
  467. }
  468. void TextServerExtension::font_set_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index, const PackedInt32Array &p_offset) {
  469. GDVIRTUAL_CALL(_font_set_texture_offsets, p_font_rid, p_size, p_texture_index, p_offset);
  470. }
  471. PackedInt32Array TextServerExtension::font_get_texture_offsets(RID p_font_rid, const Vector2i &p_size, int p_texture_index) const {
  472. PackedInt32Array ret;
  473. if (GDVIRTUAL_CALL(_font_get_texture_offsets, p_font_rid, p_size, p_texture_index, ret)) {
  474. return ret;
  475. }
  476. return PackedInt32Array();
  477. }
  478. Array TextServerExtension::font_get_glyph_list(RID p_font_rid, const Vector2i &p_size) const {
  479. Array ret;
  480. if (GDVIRTUAL_CALL(_font_get_glyph_list, p_font_rid, p_size, ret)) {
  481. return ret;
  482. }
  483. return Array();
  484. }
  485. void TextServerExtension::font_clear_glyphs(RID p_font_rid, const Vector2i &p_size) {
  486. GDVIRTUAL_CALL(_font_clear_glyphs, p_font_rid, p_size);
  487. }
  488. void TextServerExtension::font_remove_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) {
  489. GDVIRTUAL_CALL(_font_remove_glyph, p_font_rid, p_size, p_glyph);
  490. }
  491. Vector2 TextServerExtension::font_get_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph) const {
  492. Vector2 ret;
  493. if (GDVIRTUAL_CALL(_font_get_glyph_advance, p_font_rid, p_size, p_glyph, ret)) {
  494. return ret;
  495. }
  496. return Vector2();
  497. }
  498. void TextServerExtension::font_set_glyph_advance(RID p_font_rid, int p_size, int32_t p_glyph, const Vector2 &p_advance) {
  499. GDVIRTUAL_CALL(_font_set_glyph_advance, p_font_rid, p_size, p_glyph, p_advance);
  500. }
  501. Vector2 TextServerExtension::font_get_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
  502. Vector2 ret;
  503. if (GDVIRTUAL_CALL(_font_get_glyph_offset, p_font_rid, p_size, p_glyph, ret)) {
  504. return ret;
  505. }
  506. return Vector2();
  507. }
  508. void TextServerExtension::font_set_glyph_offset(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_offset) {
  509. GDVIRTUAL_CALL(_font_set_glyph_offset, p_font_rid, p_size, p_glyph, p_offset);
  510. }
  511. Vector2 TextServerExtension::font_get_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
  512. Vector2 ret;
  513. if (GDVIRTUAL_CALL(_font_get_glyph_size, p_font_rid, p_size, p_glyph, ret)) {
  514. return ret;
  515. }
  516. return Vector2();
  517. }
  518. void TextServerExtension::font_set_glyph_size(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Vector2 &p_gl_size) {
  519. GDVIRTUAL_CALL(_font_set_glyph_size, p_font_rid, p_size, p_glyph, p_gl_size);
  520. }
  521. Rect2 TextServerExtension::font_get_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
  522. Rect2 ret;
  523. if (GDVIRTUAL_CALL(_font_get_glyph_uv_rect, p_font_rid, p_size, p_glyph, ret)) {
  524. return ret;
  525. }
  526. return Rect2();
  527. }
  528. void TextServerExtension::font_set_glyph_uv_rect(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, const Rect2 &p_uv_rect) {
  529. GDVIRTUAL_CALL(_font_set_glyph_uv_rect, p_font_rid, p_size, p_glyph, p_uv_rect);
  530. }
  531. int TextServerExtension::font_get_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph) const {
  532. int ret;
  533. if (GDVIRTUAL_CALL(_font_get_glyph_texture_idx, p_font_rid, p_size, p_glyph, ret)) {
  534. return ret;
  535. }
  536. return 0;
  537. }
  538. void TextServerExtension::font_set_glyph_texture_idx(RID p_font_rid, const Vector2i &p_size, int32_t p_glyph, int p_texture_idx) {
  539. GDVIRTUAL_CALL(_font_set_glyph_texture_idx, p_font_rid, p_size, p_glyph, p_texture_idx);
  540. }
  541. Dictionary TextServerExtension::font_get_glyph_contours(RID p_font_rid, int p_size, int32_t p_index) const {
  542. Dictionary ret;
  543. if (GDVIRTUAL_CALL(_font_get_glyph_contours, p_font_rid, p_size, p_index, ret)) {
  544. return ret;
  545. }
  546. return Dictionary();
  547. }
  548. Array TextServerExtension::font_get_kerning_list(RID p_font_rid, int p_size) const {
  549. Array ret;
  550. if (GDVIRTUAL_CALL(_font_get_kerning_list, p_font_rid, p_size, ret)) {
  551. return ret;
  552. }
  553. return Array();
  554. }
  555. void TextServerExtension::font_clear_kerning_map(RID p_font_rid, int p_size) {
  556. GDVIRTUAL_CALL(_font_clear_kerning_map, p_font_rid, p_size);
  557. }
  558. void TextServerExtension::font_remove_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) {
  559. GDVIRTUAL_CALL(_font_remove_kerning, p_font_rid, p_size, p_glyph_pair);
  560. }
  561. void TextServerExtension::font_set_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair, const Vector2 &p_kerning) {
  562. GDVIRTUAL_CALL(_font_set_kerning, p_font_rid, p_size, p_glyph_pair, p_kerning);
  563. }
  564. Vector2 TextServerExtension::font_get_kerning(RID p_font_rid, int p_size, const Vector2i &p_glyph_pair) const {
  565. Vector2 ret;
  566. if (GDVIRTUAL_CALL(_font_get_kerning, p_font_rid, p_size, p_glyph_pair, ret)) {
  567. return ret;
  568. }
  569. return Vector2();
  570. }
  571. int32_t TextServerExtension::font_get_glyph_index(RID p_font_rid, int p_size, char32_t p_char, char32_t p_variation_selector) const {
  572. int32_t ret;
  573. if (GDVIRTUAL_CALL(_font_get_glyph_index, p_font_rid, p_size, p_char, p_variation_selector, ret)) {
  574. return ret;
  575. }
  576. return 0;
  577. }
  578. bool TextServerExtension::font_has_char(RID p_font_rid, char32_t p_char) const {
  579. bool ret;
  580. if (GDVIRTUAL_CALL(_font_has_char, p_font_rid, p_char, ret)) {
  581. return ret;
  582. }
  583. return false;
  584. }
  585. String TextServerExtension::font_get_supported_chars(RID p_font_rid) const {
  586. String ret;
  587. if (GDVIRTUAL_CALL(_font_get_supported_chars, p_font_rid, ret)) {
  588. return ret;
  589. }
  590. return String();
  591. }
  592. void TextServerExtension::font_render_range(RID p_font_rid, const Vector2i &p_size, char32_t p_start, char32_t p_end) {
  593. GDVIRTUAL_CALL(_font_render_range, p_font_rid, p_size, p_start, p_end);
  594. }
  595. void TextServerExtension::font_render_glyph(RID p_font_rid, const Vector2i &p_size, int32_t p_index) {
  596. GDVIRTUAL_CALL(_font_render_glyph, p_font_rid, p_size, p_index);
  597. }
  598. void TextServerExtension::font_draw_glyph(RID p_font_rid, RID p_canvas, int p_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
  599. GDVIRTUAL_CALL(_font_draw_glyph, p_font_rid, p_canvas, p_size, p_pos, p_index, p_color);
  600. }
  601. void TextServerExtension::font_draw_glyph_outline(RID p_font_rid, RID p_canvas, int p_size, int p_outline_size, const Vector2 &p_pos, int32_t p_index, const Color &p_color) const {
  602. GDVIRTUAL_CALL(_font_draw_glyph_outline, p_font_rid, p_canvas, p_size, p_outline_size, p_pos, p_index, p_color);
  603. }
  604. bool TextServerExtension::font_is_language_supported(RID p_font_rid, const String &p_language) const {
  605. bool ret;
  606. if (GDVIRTUAL_CALL(_font_is_language_supported, p_font_rid, p_language, ret)) {
  607. return ret;
  608. }
  609. return false;
  610. }
  611. void TextServerExtension::font_set_language_support_override(RID p_font_rid, const String &p_language, bool p_supported) {
  612. GDVIRTUAL_CALL(_font_set_language_support_override, p_font_rid, p_language, p_supported);
  613. }
  614. bool TextServerExtension::font_get_language_support_override(RID p_font_rid, const String &p_language) {
  615. bool ret;
  616. if (GDVIRTUAL_CALL(_font_get_language_support_override, p_font_rid, p_language, ret)) {
  617. return ret;
  618. }
  619. return false;
  620. }
  621. void TextServerExtension::font_remove_language_support_override(RID p_font_rid, const String &p_language) {
  622. GDVIRTUAL_CALL(_font_remove_language_support_override, p_font_rid, p_language);
  623. }
  624. Vector<String> TextServerExtension::font_get_language_support_overrides(RID p_font_rid) {
  625. Vector<String> ret;
  626. if (GDVIRTUAL_CALL(_font_get_language_support_overrides, p_font_rid, ret)) {
  627. return ret;
  628. }
  629. return Vector<String>();
  630. }
  631. bool TextServerExtension::font_is_script_supported(RID p_font_rid, const String &p_script) const {
  632. bool ret;
  633. if (GDVIRTUAL_CALL(_font_is_script_supported, p_font_rid, p_script, ret)) {
  634. return ret;
  635. }
  636. return false;
  637. }
  638. void TextServerExtension::font_set_script_support_override(RID p_font_rid, const String &p_script, bool p_supported) {
  639. GDVIRTUAL_CALL(_font_set_script_support_override, p_font_rid, p_script, p_supported);
  640. }
  641. bool TextServerExtension::font_get_script_support_override(RID p_font_rid, const String &p_script) {
  642. bool ret;
  643. if (GDVIRTUAL_CALL(_font_get_script_support_override, p_font_rid, p_script, ret)) {
  644. return ret;
  645. }
  646. return false;
  647. }
  648. void TextServerExtension::font_remove_script_support_override(RID p_font_rid, const String &p_script) {
  649. GDVIRTUAL_CALL(_font_remove_script_support_override, p_font_rid, p_script);
  650. }
  651. Vector<String> TextServerExtension::font_get_script_support_overrides(RID p_font_rid) {
  652. Vector<String> ret;
  653. if (GDVIRTUAL_CALL(_font_get_script_support_overrides, p_font_rid, ret)) {
  654. return ret;
  655. }
  656. return Vector<String>();
  657. }
  658. Dictionary TextServerExtension::font_supported_feature_list(RID p_font_rid) const {
  659. Dictionary ret;
  660. if (GDVIRTUAL_CALL(_font_supported_feature_list, p_font_rid, ret)) {
  661. return ret;
  662. }
  663. return Dictionary();
  664. }
  665. Dictionary TextServerExtension::font_supported_variation_list(RID p_font_rid) const {
  666. Dictionary ret;
  667. if (GDVIRTUAL_CALL(_font_supported_variation_list, p_font_rid, ret)) {
  668. return ret;
  669. }
  670. return Dictionary();
  671. }
  672. float TextServerExtension::font_get_global_oversampling() const {
  673. float ret;
  674. if (GDVIRTUAL_CALL(_font_get_global_oversampling, ret)) {
  675. return ret;
  676. }
  677. return 0.f;
  678. }
  679. void TextServerExtension::font_set_global_oversampling(float p_oversampling) {
  680. GDVIRTUAL_CALL(_font_set_global_oversampling, p_oversampling);
  681. }
  682. Vector2 TextServerExtension::get_hex_code_box_size(int p_size, char32_t p_index) const {
  683. Vector2 ret;
  684. if (GDVIRTUAL_CALL(_get_hex_code_box_size, p_size, p_index, ret)) {
  685. return ret;
  686. }
  687. return TextServer::get_hex_code_box_size(p_size, p_index);
  688. }
  689. void TextServerExtension::draw_hex_code_box(RID p_canvas, int p_size, const Vector2 &p_pos, char32_t p_index, const Color &p_color) const {
  690. if (!GDVIRTUAL_CALL(_draw_hex_code_box, p_canvas, p_size, p_pos, p_index, p_color)) {
  691. TextServer::draw_hex_code_box(p_canvas, p_size, p_pos, p_index, p_color);
  692. }
  693. }
  694. /*************************************************************************/
  695. /* Shaped text buffer interface */
  696. /*************************************************************************/
  697. RID TextServerExtension::create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) {
  698. RID ret;
  699. if (GDVIRTUAL_CALL(_create_shaped_text, p_direction, p_orientation, ret)) {
  700. return ret;
  701. }
  702. return RID();
  703. }
  704. void TextServerExtension::shaped_text_clear(RID p_shaped) {
  705. GDVIRTUAL_CALL(_shaped_text_clear, p_shaped);
  706. }
  707. void TextServerExtension::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) {
  708. GDVIRTUAL_CALL(_shaped_text_set_direction, p_shaped, p_direction);
  709. }
  710. TextServer::Direction TextServerExtension::shaped_text_get_direction(RID p_shaped) const {
  711. int ret;
  712. if (GDVIRTUAL_CALL(_shaped_text_get_direction, p_shaped, ret)) {
  713. return (TextServer::Direction)ret;
  714. }
  715. return TextServer::Direction::DIRECTION_AUTO;
  716. }
  717. void TextServerExtension::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
  718. GDVIRTUAL_CALL(_shaped_text_set_orientation, p_shaped, p_orientation);
  719. }
  720. TextServer::Orientation TextServerExtension::shaped_text_get_orientation(RID p_shaped) const {
  721. int ret;
  722. if (GDVIRTUAL_CALL(_shaped_text_get_orientation, p_shaped, ret)) {
  723. return (TextServer::Orientation)ret;
  724. }
  725. return TextServer::Orientation::ORIENTATION_HORIZONTAL;
  726. }
  727. void TextServerExtension::shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) {
  728. GDVIRTUAL_CALL(_shaped_text_set_bidi_override, p_shaped, p_override);
  729. }
  730. void TextServerExtension::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
  731. GDVIRTUAL_CALL(_shaped_text_set_preserve_invalid, p_shaped, p_enabled);
  732. }
  733. bool TextServerExtension::shaped_text_get_preserve_invalid(RID p_shaped) const {
  734. bool ret;
  735. if (GDVIRTUAL_CALL(_shaped_text_get_preserve_invalid, p_shaped, ret)) {
  736. return ret;
  737. }
  738. return false;
  739. }
  740. void TextServerExtension::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) {
  741. GDVIRTUAL_CALL(_shaped_text_set_preserve_control, p_shaped, p_enabled);
  742. }
  743. bool TextServerExtension::shaped_text_get_preserve_control(RID p_shaped) const {
  744. bool ret;
  745. if (GDVIRTUAL_CALL(_shaped_text_get_preserve_control, p_shaped, ret)) {
  746. return ret;
  747. }
  748. return false;
  749. }
  750. bool TextServerExtension::shaped_text_add_string(RID p_shaped, const String &p_text, const Vector<RID> &p_fonts, int p_size, const Dictionary &p_opentype_features, const String &p_language) {
  751. bool ret;
  752. Array fonts;
  753. for (int i = 0; i < p_fonts.size(); i++) {
  754. fonts.push_back(p_fonts[i]);
  755. }
  756. if (GDVIRTUAL_CALL(_shaped_text_add_string, p_shaped, p_text, fonts, p_size, p_opentype_features, p_language, ret)) {
  757. return ret;
  758. }
  759. return false;
  760. }
  761. bool TextServerExtension::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align, int p_length) {
  762. bool ret;
  763. if (GDVIRTUAL_CALL(_shaped_text_add_object, p_shaped, p_key, p_size, p_inline_align, p_length, ret)) {
  764. return ret;
  765. }
  766. return false;
  767. }
  768. bool TextServerExtension::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, InlineAlign p_inline_align) {
  769. bool ret;
  770. if (GDVIRTUAL_CALL(_shaped_text_resize_object, p_shaped, p_key, p_size, p_inline_align, ret)) {
  771. return ret;
  772. }
  773. return false;
  774. }
  775. RID TextServerExtension::shaped_text_substr(RID p_shaped, int p_start, int p_length) const {
  776. RID ret;
  777. if (GDVIRTUAL_CALL(_shaped_text_substr, p_shaped, p_start, p_length, ret)) {
  778. return ret;
  779. }
  780. return RID();
  781. }
  782. RID TextServerExtension::shaped_text_get_parent(RID p_shaped) const {
  783. RID ret;
  784. if (GDVIRTUAL_CALL(_shaped_text_get_parent, p_shaped, ret)) {
  785. return ret;
  786. }
  787. return RID();
  788. }
  789. float TextServerExtension::shaped_text_fit_to_width(RID p_shaped, float p_width, uint16_t p_jst_flags) {
  790. float ret;
  791. if (GDVIRTUAL_CALL(_shaped_text_fit_to_width, p_shaped, p_width, p_jst_flags, ret)) {
  792. return ret;
  793. }
  794. return 0.f;
  795. }
  796. float TextServerExtension::shaped_text_tab_align(RID p_shaped, const PackedFloat32Array &p_tab_stops) {
  797. float ret;
  798. if (GDVIRTUAL_CALL(_shaped_text_tab_align, p_shaped, p_tab_stops, ret)) {
  799. return ret;
  800. }
  801. return 0.f;
  802. }
  803. bool TextServerExtension::shaped_text_shape(RID p_shaped) {
  804. bool ret;
  805. if (GDVIRTUAL_CALL(_shaped_text_shape, p_shaped, ret)) {
  806. return ret;
  807. }
  808. return false;
  809. }
  810. bool TextServerExtension::shaped_text_update_breaks(RID p_shaped) {
  811. bool ret;
  812. if (GDVIRTUAL_CALL(_shaped_text_update_breaks, p_shaped, ret)) {
  813. return ret;
  814. }
  815. return false;
  816. }
  817. bool TextServerExtension::shaped_text_update_justification_ops(RID p_shaped) {
  818. bool ret;
  819. if (GDVIRTUAL_CALL(_shaped_text_update_justification_ops, p_shaped, ret)) {
  820. return ret;
  821. }
  822. return false;
  823. }
  824. bool TextServerExtension::shaped_text_is_ready(RID p_shaped) const {
  825. bool ret;
  826. if (GDVIRTUAL_CALL(_shaped_text_is_ready, p_shaped, ret)) {
  827. return ret;
  828. }
  829. return false;
  830. }
  831. const Glyph *TextServerExtension::shaped_text_get_glyphs(RID p_shaped) const {
  832. const Glyph *ret;
  833. if (GDVIRTUAL_CALL(_shaped_text_get_glyphs, p_shaped, &ret)) {
  834. return ret;
  835. }
  836. return nullptr;
  837. }
  838. const Glyph *TextServerExtension::shaped_text_sort_logical(RID p_shaped) {
  839. const Glyph *ret;
  840. if (GDVIRTUAL_CALL(_shaped_text_sort_logical, p_shaped, &ret)) {
  841. return ret;
  842. }
  843. return nullptr;
  844. }
  845. int TextServerExtension::shaped_text_get_glyph_count(RID p_shaped) const {
  846. int ret;
  847. if (GDVIRTUAL_CALL(_shaped_text_get_glyph_count, p_shaped, ret)) {
  848. return ret;
  849. }
  850. return 0;
  851. }
  852. Vector2i TextServerExtension::shaped_text_get_range(RID p_shaped) const {
  853. Vector2i ret;
  854. if (GDVIRTUAL_CALL(_shaped_text_get_range, p_shaped, ret)) {
  855. return ret;
  856. }
  857. return Vector2i();
  858. }
  859. PackedInt32Array TextServerExtension::shaped_text_get_line_breaks_adv(RID p_shaped, const PackedFloat32Array &p_width, int p_start, bool p_once, uint16_t p_break_flags) const {
  860. PackedInt32Array ret;
  861. if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks_adv, p_shaped, p_width, p_start, p_once, p_break_flags, ret)) {
  862. return ret;
  863. }
  864. return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_start, p_once, p_break_flags);
  865. }
  866. PackedInt32Array TextServerExtension::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint16_t p_break_flags) const {
  867. PackedInt32Array ret;
  868. if (GDVIRTUAL_CALL(_shaped_text_get_line_breaks, p_shaped, p_width, p_start, p_break_flags, ret)) {
  869. return ret;
  870. }
  871. return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_start, p_break_flags);
  872. }
  873. PackedInt32Array TextServerExtension::shaped_text_get_word_breaks(RID p_shaped, int p_grapheme_flags) const {
  874. PackedInt32Array ret;
  875. if (GDVIRTUAL_CALL(_shaped_text_get_word_breaks, p_shaped, p_grapheme_flags, ret)) {
  876. return ret;
  877. }
  878. return TextServer::shaped_text_get_word_breaks(p_shaped, p_grapheme_flags);
  879. }
  880. int TextServerExtension::shaped_text_get_trim_pos(RID p_shaped) const {
  881. int ret;
  882. if (GDVIRTUAL_CALL(_shaped_text_get_trim_pos, p_shaped, ret)) {
  883. return ret;
  884. }
  885. return -1;
  886. }
  887. int TextServerExtension::shaped_text_get_ellipsis_pos(RID p_shaped) const {
  888. int ret;
  889. if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_pos, p_shaped, ret)) {
  890. return ret;
  891. }
  892. return -1;
  893. }
  894. const Glyph *TextServerExtension::shaped_text_get_ellipsis_glyphs(RID p_shaped) const {
  895. const Glyph *ret;
  896. if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyphs, p_shaped, &ret)) {
  897. return ret;
  898. }
  899. return nullptr;
  900. }
  901. int TextServerExtension::shaped_text_get_ellipsis_glyph_count(RID p_shaped) const {
  902. int ret;
  903. if (GDVIRTUAL_CALL(_shaped_text_get_ellipsis_glyph_count, p_shaped, ret)) {
  904. return ret;
  905. }
  906. return -1;
  907. }
  908. void TextServerExtension::shaped_text_overrun_trim_to_width(RID p_shaped_line, float p_width, uint16_t p_trim_flags) {
  909. GDVIRTUAL_CALL(_shaped_text_overrun_trim_to_width, p_shaped_line, p_width, p_trim_flags);
  910. }
  911. Array TextServerExtension::shaped_text_get_objects(RID p_shaped) const {
  912. Array ret;
  913. if (GDVIRTUAL_CALL(_shaped_text_get_objects, p_shaped, ret)) {
  914. return ret;
  915. }
  916. return Array();
  917. }
  918. Rect2 TextServerExtension::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const {
  919. Rect2 ret;
  920. if (GDVIRTUAL_CALL(_shaped_text_get_object_rect, p_shaped, p_key, ret)) {
  921. return ret;
  922. }
  923. return Rect2();
  924. }
  925. Size2 TextServerExtension::shaped_text_get_size(RID p_shaped) const {
  926. Size2 ret;
  927. if (GDVIRTUAL_CALL(_shaped_text_get_size, p_shaped, ret)) {
  928. return ret;
  929. }
  930. return Size2();
  931. }
  932. float TextServerExtension::shaped_text_get_ascent(RID p_shaped) const {
  933. float ret;
  934. if (GDVIRTUAL_CALL(_shaped_text_get_ascent, p_shaped, ret)) {
  935. return ret;
  936. }
  937. return 0.f;
  938. }
  939. float TextServerExtension::shaped_text_get_descent(RID p_shaped) const {
  940. float ret;
  941. if (GDVIRTUAL_CALL(_shaped_text_get_descent, p_shaped, ret)) {
  942. return ret;
  943. }
  944. return 0.f;
  945. }
  946. float TextServerExtension::shaped_text_get_width(RID p_shaped) const {
  947. float ret;
  948. if (GDVIRTUAL_CALL(_shaped_text_get_width, p_shaped, ret)) {
  949. return ret;
  950. }
  951. return 0.f;
  952. }
  953. float TextServerExtension::shaped_text_get_underline_position(RID p_shaped) const {
  954. float ret;
  955. if (GDVIRTUAL_CALL(_shaped_text_get_underline_position, p_shaped, ret)) {
  956. return ret;
  957. }
  958. return 0.f;
  959. }
  960. float TextServerExtension::shaped_text_get_underline_thickness(RID p_shaped) const {
  961. float ret;
  962. if (GDVIRTUAL_CALL(_shaped_text_get_underline_thickness, p_shaped, ret)) {
  963. return ret;
  964. }
  965. return 0.f;
  966. }
  967. TextServer::Direction TextServerExtension::shaped_text_get_dominant_direction_in_range(RID p_shaped, int p_start, int p_end) const {
  968. int ret;
  969. if (GDVIRTUAL_CALL(_shaped_text_get_dominant_direction_in_range, p_shaped, p_start, p_end, ret)) {
  970. return (TextServer::Direction)ret;
  971. }
  972. return TextServer::shaped_text_get_dominant_direction_in_range(p_shaped, p_start, p_end);
  973. }
  974. CaretInfo TextServerExtension::shaped_text_get_carets(RID p_shaped, int p_position) const {
  975. CaretInfo ret;
  976. if (GDVIRTUAL_CALL(_shaped_text_get_carets, p_shaped, p_position, &ret)) {
  977. return ret;
  978. }
  979. return TextServer::shaped_text_get_carets(p_shaped, p_position);
  980. }
  981. Vector<Vector2> TextServerExtension::shaped_text_get_selection(RID p_shaped, int p_start, int p_end) const {
  982. Vector<Vector2> ret;
  983. if (GDVIRTUAL_CALL(_shaped_text_get_selection, p_shaped, p_start, p_end, ret)) {
  984. return ret;
  985. }
  986. return TextServer::shaped_text_get_selection(p_shaped, p_start, p_end);
  987. }
  988. int TextServerExtension::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const {
  989. int ret;
  990. if (GDVIRTUAL_CALL(_shaped_text_hit_test_grapheme, p_shaped, p_coords, ret)) {
  991. return ret;
  992. }
  993. return TextServer::shaped_text_hit_test_grapheme(p_shaped, p_coords);
  994. }
  995. int TextServerExtension::shaped_text_hit_test_position(RID p_shaped, float p_coords) const {
  996. int ret;
  997. if (GDVIRTUAL_CALL(_shaped_text_hit_test_position, p_shaped, p_coords, ret)) {
  998. return ret;
  999. }
  1000. return TextServer::shaped_text_hit_test_position(p_shaped, p_coords);
  1001. }
  1002. void TextServerExtension::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, const Color &p_color) const {
  1003. if (GDVIRTUAL_CALL(_shaped_text_draw, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color)) {
  1004. return;
  1005. }
  1006. TextServer::shaped_text_draw(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_color);
  1007. }
  1008. void TextServerExtension::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, int p_outline_size, const Color &p_color) const {
  1009. if (GDVIRTUAL_CALL(_shaped_text_draw_outline, p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color)) {
  1010. return;
  1011. }
  1012. shaped_text_draw_outline(p_shaped, p_canvas, p_pos, p_clip_l, p_clip_r, p_outline_size, p_color);
  1013. }
  1014. int TextServerExtension::shaped_text_next_grapheme_pos(RID p_shaped, int p_pos) const {
  1015. int ret;
  1016. if (GDVIRTUAL_CALL(_shaped_text_next_grapheme_pos, p_shaped, p_pos, ret)) {
  1017. return ret;
  1018. }
  1019. return TextServer::shaped_text_next_grapheme_pos(p_shaped, p_pos);
  1020. }
  1021. int TextServerExtension::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const {
  1022. int ret;
  1023. if (GDVIRTUAL_CALL(_shaped_text_prev_grapheme_pos, p_shaped, p_pos, ret)) {
  1024. return ret;
  1025. }
  1026. return TextServer::shaped_text_prev_grapheme_pos(p_shaped, p_pos);
  1027. }
  1028. String TextServerExtension::format_number(const String &p_string, const String &p_language) const {
  1029. String ret;
  1030. if (GDVIRTUAL_CALL(_format_number, p_string, p_language, ret)) {
  1031. return ret;
  1032. }
  1033. return TextServer::format_number(p_string, p_language);
  1034. }
  1035. String TextServerExtension::parse_number(const String &p_string, const String &p_language) const {
  1036. String ret;
  1037. if (GDVIRTUAL_CALL(_parse_number, p_string, p_language, ret)) {
  1038. return ret;
  1039. }
  1040. return TextServer::parse_number(p_string, p_language);
  1041. }
  1042. String TextServerExtension::percent_sign(const String &p_language) const {
  1043. String ret;
  1044. if (GDVIRTUAL_CALL(_percent_sign, p_language, ret)) {
  1045. return ret;
  1046. }
  1047. return TextServer::percent_sign(p_language);
  1048. }
  1049. TextServerExtension::TextServerExtension() {
  1050. //NOP
  1051. }
  1052. TextServerExtension::~TextServerExtension() {
  1053. //NOP
  1054. }