[Complex Text Layouts] Implement GDNative interface for TextServer.

This commit is contained in:
bruvzg 2020-08-12 14:07:49 +03:00
parent 200828276e
commit 07d14f5bb8
No known key found for this signature in database
GPG key ID: FCED35F1CECE0D3A
17 changed files with 1969 additions and 12 deletions

View file

@ -20,6 +20,7 @@ SConscript("net/SCsub")
SConscript("xr/SCsub")
SConscript("pluginscript/SCsub")
SConscript("videodecoder/SCsub")
SConscript("text/SCsub")
import gdnative_builders

View file

@ -90,6 +90,18 @@ void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot
}
}
void GDAPI godot_array_new_packed_vector2i_array(godot_array *r_dest, const godot_packed_vector2i_array *p_pv2a) {
Array *dest = (Array *)r_dest;
Vector<Vector2i> *pca = (Vector<Vector2i> *)p_pv2a;
memnew_placement(dest, Array);
dest->resize(pca->size());
for (int i = 0; i < dest->size(); i++) {
Variant v = pca->operator[](i);
dest->operator[](i) = v;
}
}
void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa) {
Array *dest = (Array *)r_dest;
Vector<String> *pca = (Vector<String> *)p_psa;

View file

@ -49,6 +49,7 @@ static_assert(sizeof(godot_packed_float32_array) == sizeof(Vector<float>), "Vect
static_assert(sizeof(godot_packed_float64_array) == sizeof(Vector<double>), "Vector<double> size mismatch");
static_assert(sizeof(godot_packed_string_array) == sizeof(Vector<String>), "Vector<String> size mismatch");
static_assert(sizeof(godot_packed_vector2_array) == sizeof(Vector<Vector2>), "Vector<Vector2> size mismatch");
static_assert(sizeof(godot_packed_vector2i_array) == sizeof(Vector<Vector2i>), "Vector<Vector2i> size mismatch");
static_assert(sizeof(godot_packed_vector3_array) == sizeof(Vector<Vector3>), "Vector<Vector3> size mismatch");
static_assert(sizeof(godot_packed_color_array) == sizeof(Vector<Color>), "Vector<Color> size mismatch");
@ -799,6 +800,118 @@ void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self
((Vector<Vector2> *)p_self)->~Vector();
}
// vector2i
void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *r_dest) {
Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest;
memnew_placement(dest, Vector<Vector2i>);
}
void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src) {
Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest;
const Vector<Vector2i> *src = (const Vector<Vector2i> *)p_src;
memnew_placement(dest, Vector<Vector2i>(*src));
}
void GDAPI godot_packed_vector2i_array_new_with_array(godot_packed_vector2i_array *r_dest, const godot_array *p_a) {
Vector<Vector2i> *dest = (Vector<Vector2i> *)r_dest;
Array *a = (Array *)p_a;
memnew_placement(dest, Vector<Vector2i>);
dest->resize(a->size());
for (int i = 0; i < a->size(); i++) {
dest->set(i, (*a)[i]);
}
}
const godot_vector2i GDAPI *godot_packed_vector2i_array_ptr(const godot_packed_vector2i_array *p_self) {
const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self;
return (const godot_vector2i *)self->ptr();
}
godot_vector2i GDAPI *godot_packed_vector2i_array_ptrw(godot_packed_vector2i_array *p_self) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
return (godot_vector2i *)self->ptrw();
}
void GDAPI godot_packed_vector2i_array_append(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector2i &s = *(Vector2i *)p_data;
self->push_back(s);
}
void GDAPI godot_packed_vector2i_array_append_array(godot_packed_vector2i_array *p_self, const godot_packed_vector2i_array *p_array) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector<Vector2i> *array = (Vector<Vector2i> *)p_array;
self->append_array(*array);
}
godot_error GDAPI godot_packed_vector2i_array_insert(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector2i &s = *(Vector2i *)p_data;
return (godot_error)self->insert(p_idx, s);
}
godot_bool GDAPI godot_packed_vector2i_array_has(godot_packed_vector2i_array *p_self, const godot_vector2i *p_value) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector2i &v = *(Vector2i *)p_value;
return (godot_bool)self->has(v);
}
void GDAPI godot_packed_vector2i_array_sort(godot_packed_vector2i_array *p_self) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
self->sort();
}
void GDAPI godot_packed_vector2i_array_invert(godot_packed_vector2i_array *p_self) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
self->invert();
}
void GDAPI godot_packed_vector2i_array_push_back(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector2i &s = *(Vector2i *)p_data;
self->push_back(s);
}
void GDAPI godot_packed_vector2i_array_remove(godot_packed_vector2i_array *p_self, const godot_int p_idx) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
self->remove(p_idx);
}
void GDAPI godot_packed_vector2i_array_resize(godot_packed_vector2i_array *p_self, const godot_int p_size) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
self->resize(p_size);
}
void GDAPI godot_packed_vector2i_array_set(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
Vector2i &s = *(Vector2i *)p_data;
self->set(p_idx, s);
}
godot_vector2i GDAPI godot_packed_vector2i_array_get(const godot_packed_vector2i_array *p_self, const godot_int p_idx) {
const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self;
godot_vector2i v;
Vector2i *s = (Vector2i *)&v;
*s = self->get(p_idx);
return v;
}
godot_int GDAPI godot_packed_vector2i_array_size(const godot_packed_vector2i_array *p_self) {
const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self;
return self->size();
}
godot_bool GDAPI godot_packed_vector2i_array_empty(const godot_packed_vector2i_array *p_self) {
const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self;
return self->empty();
}
void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) {
((Vector<Vector2i> *)p_self)->~Vector();
}
// vector3
void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest) {

View file

@ -259,6 +259,14 @@
["const godot_packed_vector2_array *", "p_pv2a"]
]
},
{
"name": "godot_array_new_packed_vector2i_array",
"return_type": "void",
"arguments": [
["godot_array *", "r_dest"],
["const godot_packed_vector2i_array *", "p_pv2a"]
]
},
{
"name": "godot_array_new_packed_string_array",
"return_type": "void",
@ -2637,6 +2645,152 @@
["godot_packed_vector2_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_new",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "r_dest"]
]
},
{
"name": "godot_packed_vector2i_array_new_copy",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "r_dest"],
["const godot_packed_vector2i_array *", "p_src"]
]
},
{
"name": "godot_packed_vector2i_array_new_with_array",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "r_dest"],
["const godot_array *", "p_a"]
]
},
{
"name": "godot_packed_vector2i_array_empty",
"return_type": "godot_bool",
"arguments": [
["const godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_append",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_vector2i *", "p_data"]
]
},
{
"name": "godot_packed_vector2i_array_append_array",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_packed_vector2i_array *", "p_array"]
]
},
{
"name": "godot_packed_vector2i_array_insert",
"return_type": "godot_error",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector2i *", "p_data"]
]
},
{
"name": "godot_packed_vector2i_array_has",
"return_type": "godot_bool",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_vector2i *", "p_value"]
]
},
{
"name": "godot_packed_vector2i_array_sort",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_invert",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_push_back",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_vector2i *", "p_data"]
]
},
{
"name": "godot_packed_vector2i_array_remove",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
"name": "godot_packed_vector2i_array_resize",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
"name": "godot_packed_vector2i_array_ptr",
"return_type": "const godot_vector2i *",
"arguments": [
["const godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_ptrw",
"return_type": "godot_vector2i *",
"arguments": [
["godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_set",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_vector2i *", "p_data"]
]
},
{
"name": "godot_packed_vector2i_array_get",
"return_type": "godot_vector2i",
"arguments": [
["const godot_packed_vector2i_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
"name": "godot_packed_vector2i_array_size",
"return_type": "godot_int",
"arguments": [
["const godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector2i_array_destroy",
"return_type": "void",
"arguments": [
["godot_packed_vector2i_array *", "p_self"]
]
},
{
"name": "godot_packed_vector3_array_new",
"return_type": "void",
@ -7615,6 +7769,306 @@
]
}
]
},
{
"name": "text",
"type": "TEXT",
"version": {
"major": 1,
"minor": 0
},
"next": null,
"api": [
{
"name": "godot_text_register_interface",
"return_type": "void",
"arguments": [
["const godot_text_interface_gdnative *", "p_interface"],
["const godot_string *", "p_name"],
["uint32_t", "p_features"]
]
},
{
"name": "godot_glyph_new",
"return_type": "void",
"arguments": [
["godot_glyph *", "r_dest"]
]
},
{
"name": "godot_glyph_get_range",
"return_type": "godot_vector2i",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_range",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["const godot_vector2i *", "p_range"]
]
},
{
"name": "godot_glyph_get_count",
"return_type": "godot_int",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_count",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_int", "p_count"]
]
},
{
"name": "godot_glyph_get_repeat",
"return_type": "godot_int",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_repeat",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_int", "p_repeat"]
]
},
{
"name": "godot_glyph_get_flags",
"return_type": "godot_int",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_flags",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_int", "p_flags"]
]
},
{
"name": "godot_glyph_get_offset",
"return_type": "godot_vector2",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_offset",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["const godot_vector2 *", "p_offset"]
]
},
{
"name": "godot_glyph_get_advance",
"return_type": "godot_real",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_advance",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_real", "p_advance"]
]
},
{
"name": "godot_glyph_get_font",
"return_type": "godot_rid",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_font",
"return_type": "void ",
"arguments": [
["godot_glyph *", "p_self"],
["godot_rid *", "p_font"]
]
},
{
"name": "godot_glyph_get_font_size",
"return_type": "godot_int",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_font_size",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_int", "p_size"]
]
},
{
"name": "godot_glyph_get_index",
"return_type": "godot_int",
"arguments": [
["const godot_glyph *", "p_self"]
]
},
{
"name": "godot_glyph_set_index",
"return_type": "void",
"arguments": [
["godot_glyph *", "p_self"],
["godot_int", "p_index"]
]
},
{
"name": "godot_packed_glyph_array_new",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "r_dest"]
]
},
{
"name": "godot_packed_glyph_array_new_copy",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "r_dest"],
["const godot_packed_glyph_array *", "p_src"]
]
},
{
"name": "godot_packed_glyph_array_empty",
"return_type": "godot_bool",
"arguments": [
["const godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_append",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_glyph *", "p_data"]
]
},
{
"name": "godot_packed_glyph_array_append_array",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_packed_glyph_array *", "p_array"]
]
},
{
"name": "godot_packed_glyph_array_insert",
"return_type": "godot_error",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_glyph *", "p_data"]
]
},
{
"name": "godot_packed_glyph_array_has",
"return_type": "godot_bool",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_glyph *", "p_value"]
]
},
{
"name": "godot_packed_glyph_array_sort",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_invert",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_push_back",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_glyph *", "p_data"]
]
},
{
"name": "godot_packed_glyph_array_remove",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
"name": "godot_packed_glyph_array_resize",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_int", "p_size"]
]
},
{
"name": "godot_packed_glyph_array_ptr",
"return_type": "const godot_glyph *",
"arguments": [
["const godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_ptrw",
"return_type": "godot_glyph *",
"arguments": [
["godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_set",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"],
["const godot_int", "p_idx"],
["const godot_glyph *", "p_data"]
]
},
{
"name": "godot_packed_glyph_array_get",
"return_type": "godot_glyph",
"arguments": [
["const godot_packed_glyph_array *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
"name": "godot_packed_glyph_array_size",
"return_type": "godot_int",
"arguments": [
["const godot_packed_glyph_array *", "p_self"]
]
},
{
"name": "godot_packed_glyph_array_destroy",
"return_type": "void",
"arguments": [
["godot_packed_glyph_array *", "p_self"]
]
}
]
}
]
}

View file

@ -24,6 +24,7 @@ def _build_gdnative_api_struct_header(api):
"#include <net/godot_net.h>",
"#include <pluginscript/godot_pluginscript.h>",
"#include <videodecoder/godot_videodecoder.h>",
"#include <text/godot_text.h>",
"",
"#ifdef __cplusplus",
'extern "C" {',

View file

@ -65,6 +65,7 @@ void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
void GDAPI godot_array_new_packed_color_array(godot_array *r_dest, const godot_packed_color_array *p_pca);
void GDAPI godot_array_new_packed_vector3_array(godot_array *r_dest, const godot_packed_vector3_array *p_pv3a);
void GDAPI godot_array_new_packed_vector2_array(godot_array *r_dest, const godot_packed_vector2_array *p_pv2a);
void GDAPI godot_array_new_packed_vector2i_array(godot_array *r_dest, const godot_packed_vector2i_array *p_pv2a);
void GDAPI godot_array_new_packed_string_array(godot_array *r_dest, const godot_packed_string_array *p_psa);
void GDAPI godot_array_new_packed_float32_array(godot_array *r_dest, const godot_packed_float32_array *p_pra);
void GDAPI godot_array_new_packed_float64_array(godot_array *r_dest, const godot_packed_float64_array *p_pra);

View file

@ -114,6 +114,17 @@ typedef struct {
} godot_packed_vector2_array;
#endif
/////// PackedVector2iArray
#define GODOT_PACKED_VECTOR2I_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2I_ARRAY_SIZE];
} godot_packed_vector2i_array;
#endif
/////// PackedVector3Array
#define GODOT_PACKED_VECTOR3_ARRAY_SIZE (2 * sizeof(void *))
@ -404,6 +415,42 @@ godot_bool GDAPI godot_packed_vector2_array_empty(const godot_packed_vector2_arr
void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self);
// vector2i
void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *r_dest);
void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src);
void GDAPI godot_packed_vector2i_array_new_with_array(godot_packed_vector2i_array *r_dest, const godot_array *p_a);
const godot_vector2i GDAPI *godot_packed_vector2i_array_ptr(const godot_packed_vector2i_array *p_self);
godot_vector2i GDAPI *godot_packed_vector2i_array_ptrw(godot_packed_vector2i_array *p_self);
void GDAPI godot_packed_vector2i_array_append(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data);
void GDAPI godot_packed_vector2i_array_append_array(godot_packed_vector2i_array *p_self, const godot_packed_vector2i_array *p_array);
godot_error GDAPI godot_packed_vector2i_array_insert(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data);
godot_bool GDAPI godot_packed_vector2i_array_has(godot_packed_vector2i_array *p_self, const godot_vector2i *p_value);
void GDAPI godot_packed_vector2i_array_sort(godot_packed_vector2i_array *p_self);
void GDAPI godot_packed_vector2i_array_invert(godot_packed_vector2i_array *p_self);
void GDAPI godot_packed_vector2i_array_push_back(godot_packed_vector2i_array *p_self, const godot_vector2i *p_data);
void GDAPI godot_packed_vector2i_array_remove(godot_packed_vector2i_array *p_self, const godot_int p_idx);
void GDAPI godot_packed_vector2i_array_resize(godot_packed_vector2i_array *p_self, const godot_int p_size);
void GDAPI godot_packed_vector2i_array_set(godot_packed_vector2i_array *p_self, const godot_int p_idx, const godot_vector2i *p_data);
godot_vector2i GDAPI godot_packed_vector2i_array_get(const godot_packed_vector2i_array *p_self, const godot_int p_idx);
godot_int GDAPI godot_packed_vector2i_array_size(const godot_packed_vector2i_array *p_self);
godot_bool GDAPI godot_packed_vector2i_array_empty(const godot_packed_vector2i_array *p_self);
void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self);
// vector3
void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *r_dest);

View file

@ -0,0 +1,228 @@
/*************************************************************************/
/* godot_text.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_NATIVETEXT_H
#define GODOT_NATIVETEXT_H
#include <gdnative/gdnative.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GODOT_TEXT_API_MAJOR 1
#define GODOT_TEXT_API_MINOR 0
#define GODOT_GLYPH_SIZE 40
#ifndef GODOT_TEXT_API_GODOT_GLYPH_TYPE_DEFINED
#define GODOT_TEXT_API_GODOT_GLYPH_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_GLYPH_SIZE];
} godot_glyph;
#endif
#define GODOT_PACKED_GLYPH_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_TEXT_API_GODOT_PACKED_GLYPH_ARRAY_TYPE_DEFINED
#define GODOT_TEXT_API_GODOT_PACKED_GLYPH_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_GLYPH_ARRAY_SIZE];
} godot_packed_glyph_array;
#endif
typedef struct {
godot_gdnative_api_version version;
void *(*constructor)(godot_object *);
void (*destructor)(void *);
godot_string (*get_name)(const void *);
godot_bool (*has_feature)(const void *, godot_int);
bool (*load_support_data)(void *, const godot_string *);
godot_string (*get_support_data_filename)(const void *);
godot_string (*get_support_data_info)(const void *);
bool (*save_support_data)(void *, const godot_string *);
bool (*is_locale_right_to_left)(void *, const godot_string *);
void (*free)(void *, godot_rid *);
bool (*has)(void *, godot_rid *);
godot_rid (*create_font_system)(void *, const godot_string *, int);
godot_rid (*create_font_resource)(void *, const godot_string *, int);
godot_rid (*create_font_memory)(void *, const uint8_t *, size_t, godot_string *, int);
float (*font_get_height)(void *, godot_rid *, int);
float (*font_get_ascent)(void *, godot_rid *, int);
float (*font_get_descent)(void *, godot_rid *, int);
float (*font_get_underline_position)(void *, godot_rid *, int);
float (*font_get_underline_thickness)(void *, godot_rid *, int);
void (*font_set_antialiased)(void *, godot_rid *, bool);
bool (*font_get_antialiased)(void *, godot_rid *);
godot_dictionary (*font_get_feature_list)(void *, godot_rid *);
void (*font_set_distance_field_hint)(void *, godot_rid *, bool);
bool (*font_get_distance_field_hint)(void *, godot_rid *);
void (*font_set_hinting)(void *, godot_rid *, godot_int);
godot_int (*font_get_hinting)(void *, godot_rid *);
void (*font_set_force_autohinter)(void *, godot_rid *, bool);
bool (*font_get_force_autohinter)(void *, godot_rid *);
bool (*font_has_char)(void *, godot_rid *, char32_t);
godot_string (*font_get_supported_chars)(void *, godot_rid *);
bool (*font_has_outline)(void *, godot_rid *);
int (*font_get_base_size)(void *, godot_rid *);
bool (*font_is_language_supported)(void *, godot_rid *, const godot_string *);
void (*font_set_language_support_override)(void *, godot_rid *, const godot_string *, bool);
bool (*font_get_language_support_override)(void *, godot_rid *, const godot_string *);
void (*font_remove_language_support_override)(void *, godot_rid *, const godot_string *);
godot_packed_string_array (*font_get_language_support_overrides)(void *, godot_rid *);
bool (*font_is_script_supported)(void *, godot_rid *, const godot_string *);
void (*font_set_script_support_override)(void *, godot_rid *, const godot_string *, bool);
bool (*font_get_script_support_override)(void *, godot_rid *, const godot_string *);
void (*font_remove_script_support_override)(void *, godot_rid *, const godot_string *);
godot_packed_string_array (*font_get_script_support_overrides)(void *, godot_rid *);
uint32_t (*font_get_glyph_index)(void *, godot_rid *, char32_t, char32_t);
godot_vector2 (*font_get_glyph_advance)(void *, godot_rid *, uint32_t, int);
godot_vector2 (*font_get_glyph_kerning)(void *, godot_rid *, uint32_t, uint32_t, int);
godot_vector2 (*font_draw_glyph)(void *, godot_rid *, godot_rid *, int, const godot_vector2 *, uint32_t, const godot_color *);
godot_vector2 (*font_draw_glyph_outline)(void *, godot_rid *, godot_rid *, int, int, const godot_vector2 *, uint32_t, const godot_color *);
float (*font_get_oversampling)(void *);
void (*font_set_oversampling)(void *, float);
godot_packed_string_array (*get_system_fonts)(void *);
godot_rid (*create_shaped_text)(void *, godot_int, godot_int);
void (*shaped_text_clear)(void *, godot_rid *);
void (*shaped_text_set_direction)(void *, godot_rid *, godot_int);
godot_int (*shaped_text_get_direction)(void *, godot_rid *);
void (*shaped_text_set_bidi_override)(void *, godot_rid *, const godot_packed_vector2i_array *);
void (*shaped_text_set_orientation)(void *, godot_rid *, godot_int);
godot_int (*shaped_text_get_orientation)(void *, godot_rid *);
void (*shaped_text_set_preserve_invalid)(void *, godot_rid *, bool);
bool (*shaped_text_get_preserve_invalid)(void *, godot_rid *);
void (*shaped_text_set_preserve_control)(void *, godot_rid *, bool);
bool (*shaped_text_get_preserve_control)(void *, godot_rid *);
bool (*shaped_text_add_string)(void *, godot_rid *, const godot_string *, const godot_rid **, int, const godot_dictionary *, const godot_string *);
bool (*shaped_text_add_object)(void *, godot_rid *, const godot_variant *, const godot_vector2 *, godot_int, godot_int);
bool (*shaped_text_resize_object)(void *, godot_rid *, const godot_variant *, const godot_vector2 *, godot_int);
godot_rid (*shaped_text_substr)(void *, godot_rid *, godot_int, godot_int);
godot_rid (*shaped_text_get_parent)(void *, godot_rid *);
float (*shaped_text_fit_to_width)(void *, godot_rid *, float, uint8_t);
float (*shaped_text_tab_align)(void *, godot_rid *, godot_packed_float32_array *);
bool (*shaped_text_shape)(void *, godot_rid *);
bool (*shaped_text_update_breaks)(void *, godot_rid *);
bool (*shaped_text_update_justification_ops)(void *, godot_rid *);
bool (*shaped_text_is_ready)(void *, godot_rid *);
godot_packed_glyph_array (*shaped_text_get_glyphs)(void *, godot_rid *);
godot_vector2i (*shaped_text_get_range)(void *, godot_rid *);
godot_packed_glyph_array (*shaped_text_sort_logical)(void *, godot_rid *);
godot_packed_vector2i_array (*shaped_text_get_line_breaks_adv)(void *, godot_rid *, godot_packed_float32_array *, int, bool, uint8_t);
godot_packed_vector2i_array (*shaped_text_get_line_breaks)(void *, godot_rid *, float, int, uint8_t);
godot_packed_vector2i_array (*shaped_text_get_word_breaks)(void *, godot_rid *);
godot_array (*shaped_text_get_objects)(void *, godot_rid *);
godot_rect2 (*shaped_text_get_object_rect)(void *, godot_rid *, const godot_variant *);
godot_vector2 (*shaped_text_get_size)(void *, godot_rid *);
float (*shaped_text_get_ascent)(void *, godot_rid *);
float (*shaped_text_get_descent)(void *, godot_rid *);
float (*shaped_text_get_width)(void *, godot_rid *);
float (*shaped_text_get_underline_position)(void *, godot_rid *);
float (*shaped_text_get_underline_thickness)(void *, godot_rid *);
godot_string (*format_number)(void *, const godot_string *, const godot_string *);
godot_string (*parse_number)(void *, const godot_string *, const godot_string *);
godot_string (*percent_sign)(void *, const godot_string *);
} godot_text_interface_gdnative;
void GDAPI godot_text_register_interface(const godot_text_interface_gdnative *p_interface, const godot_string *p_name, uint32_t p_features);
// Glyph
void GDAPI godot_glyph_new(godot_glyph *r_dest);
godot_vector2i GDAPI godot_glyph_get_range(const godot_glyph *p_self);
void GDAPI godot_glyph_set_range(godot_glyph *p_self, const godot_vector2i *p_range);
godot_int GDAPI godot_glyph_get_count(const godot_glyph *p_self);
void GDAPI godot_glyph_set_count(godot_glyph *p_self, godot_int p_count);
godot_int GDAPI godot_glyph_get_repeat(const godot_glyph *p_self);
void GDAPI godot_glyph_set_repeat(godot_glyph *p_self, godot_int p_repeat);
godot_int GDAPI godot_glyph_get_flags(const godot_glyph *p_self);
void GDAPI godot_glyph_set_flags(godot_glyph *p_self, godot_int p_flags);
godot_vector2 GDAPI godot_glyph_get_offset(const godot_glyph *p_self);
void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_offset);
godot_real GDAPI godot_glyph_get_advance(const godot_glyph *p_self);
void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real p_advance);
godot_rid GDAPI godot_glyph_get_font(const godot_glyph *p_self);
void GDAPI godot_glyph_set_font(godot_glyph *p_self, godot_rid *p_font);
godot_int GDAPI godot_glyph_get_font_size(const godot_glyph *p_self);
void GDAPI godot_glyph_set_font_size(godot_glyph *p_self, godot_int p_size);
godot_int GDAPI godot_glyph_get_index(const godot_glyph *p_self);
void GDAPI godot_glyph_set_index(godot_glyph *p_self, godot_int p_index);
// GlyphArray
void GDAPI godot_packed_glyph_array_new(godot_packed_glyph_array *r_dest);
void GDAPI godot_packed_glyph_array_new_copy(godot_packed_glyph_array *r_dest, const godot_packed_glyph_array *p_src);
const godot_glyph GDAPI *godot_packed_glyph_array_ptr(const godot_packed_glyph_array *p_self);
godot_glyph GDAPI *godot_packed_glyph_array_ptrw(godot_packed_glyph_array *p_self);
void GDAPI godot_packed_glyph_array_append(godot_packed_glyph_array *p_self, const godot_glyph *p_data);
void GDAPI godot_packed_glyph_array_append_array(godot_packed_glyph_array *p_self, const godot_packed_glyph_array *p_array);
godot_error GDAPI godot_packed_glyph_array_insert(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data);
godot_bool GDAPI godot_packed_glyph_array_has(godot_packed_glyph_array *p_self, const godot_glyph *p_value);
void GDAPI godot_packed_glyph_array_sort(godot_packed_glyph_array *p_self);
void GDAPI godot_packed_glyph_array_invert(godot_packed_glyph_array *p_self);
void GDAPI godot_packed_glyph_array_push_back(godot_packed_glyph_array *p_self, const godot_glyph *p_data);
void GDAPI godot_packed_glyph_array_remove(godot_packed_glyph_array *p_self, godot_int p_idx);
void GDAPI godot_packed_glyph_array_resize(godot_packed_glyph_array *p_self, godot_int p_size);
void GDAPI godot_packed_glyph_array_set(godot_packed_glyph_array *p_self, godot_int p_idx, const godot_glyph *p_data);
godot_glyph GDAPI godot_packed_glyph_array_get(const godot_packed_glyph_array *p_self, godot_int p_idx);
godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_self);
godot_bool GDAPI godot_packed_glyph_array_empty(const godot_packed_glyph_array *p_self);
void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self);
// Grapheme
#ifdef __cplusplus
}
#endif
#endif /* !GODOT_NATIVETEXT_H */

View file

@ -0,0 +1,6 @@
#!/usr/bin/env python
Import("env")
Import("env_gdnative")
env_gdnative.add_source_files(env.modules_sources, "*.cpp")

View file

@ -0,0 +1,6 @@
def can_build(env, platform):
return True
def configure(env):
pass

View file

@ -0,0 +1,36 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "text_server_gdnative.h"
void register_text_server_gdn_types() {}
void unregister_text_server_gdn_types() {}

View file

@ -0,0 +1,37 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEXT_REGISTER_TYPES_H
#define TEXT_REGISTER_TYPES_H
void register_text_server_gdn_types();
void unregister_text_server_gdn_types();
#endif // TEXT_REGISTER_TYPES_H

View file

@ -0,0 +1,835 @@
/*************************************************************************/
/* text_server_gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "text_server_gdnative.h"
bool TextServerGDNative::has_feature(Feature p_feature) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->has_feature(data, (godot_int)p_feature);
}
String TextServerGDNative::get_name() const {
ERR_FAIL_COND_V(interface == nullptr, String());
godot_string result = interface->get_name(data);
String name = *(String *)&result;
godot_string_destroy(&result);
return name;
}
void TextServerGDNative::free(RID p_rid) {
ERR_FAIL_COND(interface == nullptr);
interface->free(data, (godot_rid *)&p_rid);
}
bool TextServerGDNative::has(RID p_rid) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->has(data, (godot_rid *)&p_rid);
}
bool TextServerGDNative::load_support_data(const String &p_filename) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->load_support_data(data, (godot_string *)&p_filename);
}
#ifdef TOOLS_ENABLED
String TextServerGDNative::get_support_data_filename() {
ERR_FAIL_COND_V(interface == nullptr, String());
godot_string result = interface->get_support_data_filename(data);
String name = *(String *)&result;
godot_string_destroy(&result);
return name;
}
String TextServerGDNative::get_support_data_info() {
ERR_FAIL_COND_V(interface == nullptr, String());
godot_string result = interface->get_support_data_info(data);
String info = *(String *)&result;
godot_string_destroy(&result);
return info;
}
bool TextServerGDNative::save_support_data(const String &p_filename) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->save_support_data(data, (godot_string *)&p_filename);
}
#endif
bool TextServerGDNative::is_locale_right_to_left(const String &p_locale) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->is_locale_right_to_left(data, (godot_string *)&p_locale);
}
/*************************************************************************/
/* Font interface */
/*************************************************************************/
RID TextServerGDNative::create_font_system(const String &p_name, int p_base_size) {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->create_font_system(data, (const godot_string *)&p_name, p_base_size);
RID rid = *(RID *)&result;
return rid;
}
RID TextServerGDNative::create_font_resource(const String &p_filename, int p_base_size) {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->create_font_resource(data, (const godot_string *)&p_filename, p_base_size);
RID rid = *(RID *)&result;
return rid;
}
RID TextServerGDNative::create_font_memory(const uint8_t *p_data, size_t p_size, const String &p_type, int p_base_size) {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->create_font_memory(data, p_data, p_size, (godot_string *)&p_type, p_base_size);
RID rid = *(RID *)&result;
return rid;
}
float TextServerGDNative::font_get_height(RID p_font, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_height(data, (godot_rid *)&p_font, p_size);
}
float TextServerGDNative::font_get_ascent(RID p_font, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_ascent(data, (godot_rid *)&p_font, p_size);
}
float TextServerGDNative::font_get_descent(RID p_font, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_descent(data, (godot_rid *)&p_font, p_size);
}
float TextServerGDNative::font_get_underline_position(RID p_font, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_underline_position(data, (godot_rid *)&p_font, p_size);
}
float TextServerGDNative::font_get_underline_thickness(RID p_font, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_underline_thickness(data, (godot_rid *)&p_font, p_size);
}
void TextServerGDNative::font_set_antialiased(RID p_font, bool p_antialiased) {
ERR_FAIL_COND(interface == nullptr);
interface->font_set_antialiased(data, (godot_rid *)&p_font, p_antialiased);
}
bool TextServerGDNative::font_get_antialiased(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_get_antialiased(data, (godot_rid *)&p_font);
}
void TextServerGDNative::font_set_hinting(RID p_font, TextServer::Hinting p_hinting) {
ERR_FAIL_COND(interface == nullptr);
interface->font_set_hinting(data, (godot_rid *)&p_font, (godot_int)p_hinting);
}
TextServer::Hinting TextServerGDNative::font_get_hinting(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, TextServer::HINTING_NONE);
return (TextServer::Hinting)interface->font_get_hinting(data, (godot_rid *)&p_font);
}
Dictionary TextServerGDNative::font_get_feature_list(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, Dictionary());
godot_dictionary result = interface->font_get_feature_list(data, (godot_rid *)&p_font);
Dictionary info = *(Dictionary *)&result;
godot_dictionary_destroy(&result);
return info;
}
void TextServerGDNative::font_set_distance_field_hint(RID p_font, bool p_distance_field) {
ERR_FAIL_COND(interface == nullptr);
interface->font_set_distance_field_hint(data, (godot_rid *)&p_font, p_distance_field);
}
bool TextServerGDNative::font_get_distance_field_hint(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_get_distance_field_hint(data, (godot_rid *)&p_font);
}
void TextServerGDNative::font_set_force_autohinter(RID p_font, bool p_enabeld) {
ERR_FAIL_COND(interface == nullptr);
interface->font_set_force_autohinter(data, (godot_rid *)&p_font, p_enabeld);
}
bool TextServerGDNative::font_get_force_autohinter(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_get_force_autohinter(data, (godot_rid *)&p_font);
}
bool TextServerGDNative::font_has_char(RID p_font, char32_t p_char) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_has_char(data, (godot_rid *)&p_font, p_char);
}
String TextServerGDNative::font_get_supported_chars(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, String());
godot_string result = interface->font_get_supported_chars(data, (godot_rid *)&p_font);
String ret = *(String *)&result;
godot_string_destroy(&result);
return ret;
}
bool TextServerGDNative::font_has_outline(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_has_outline(data, (godot_rid *)&p_font);
}
float TextServerGDNative::font_get_base_size(RID p_font) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->font_get_base_size(data, (godot_rid *)&p_font);
}
bool TextServerGDNative::font_is_language_supported(RID p_font, const String &p_language) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_is_language_supported(data, (godot_rid *)&p_font, (godot_string *)&p_language);
}
void TextServerGDNative::font_set_language_support_override(RID p_font, const String &p_language, bool p_supported) {
ERR_FAIL_COND(interface == nullptr);
return interface->font_set_language_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_language, p_supported);
}
bool TextServerGDNative::font_get_language_support_override(RID p_font, const String &p_language) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_get_language_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_language);
}
void TextServerGDNative::font_remove_language_support_override(RID p_font, const String &p_language) {
ERR_FAIL_COND(interface == nullptr);
interface->font_remove_language_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_language);
}
Vector<String> TextServerGDNative::font_get_language_support_overrides(RID p_font) {
ERR_FAIL_COND_V(interface == nullptr, Vector<String>());
godot_packed_string_array result = interface->font_get_language_support_overrides(data, (godot_rid *)&p_font);
Vector<String> ret = *(Vector<String> *)&result;
godot_packed_string_array_destroy(&result);
return ret;
}
bool TextServerGDNative::font_is_script_supported(RID p_font, const String &p_script) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_is_script_supported(data, (godot_rid *)&p_font, (godot_string *)&p_script);
}
void TextServerGDNative::font_set_script_support_override(RID p_font, const String &p_script, bool p_supported) {
ERR_FAIL_COND(interface == nullptr);
return interface->font_set_script_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_script, p_supported);
}
bool TextServerGDNative::font_get_script_support_override(RID p_font, const String &p_script) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->font_get_script_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_script);
}
void TextServerGDNative::font_remove_script_support_override(RID p_font, const String &p_script) {
ERR_FAIL_COND(interface == nullptr);
interface->font_remove_script_support_override(data, (godot_rid *)&p_font, (godot_string *)&p_script);
}
Vector<String> TextServerGDNative::font_get_script_support_overrides(RID p_font) {
ERR_FAIL_COND_V(interface == nullptr, Vector<String>());
godot_packed_string_array result = interface->font_get_script_support_overrides(data, (godot_rid *)&p_font);
Vector<String> ret = *(Vector<String> *)&result;
godot_packed_string_array_destroy(&result);
return ret;
}
uint32_t TextServerGDNative::font_get_glyph_index(RID p_font, char32_t p_char, char32_t p_variation_selector) const {
ERR_FAIL_COND_V(interface == nullptr, 0);
return interface->font_get_glyph_index(data, (godot_rid *)&p_font, p_char, p_variation_selector);
}
Vector2 TextServerGDNative::font_get_glyph_advance(RID p_font, uint32_t p_index, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, Vector2());
godot_vector2 result = interface->font_get_glyph_advance(data, (godot_rid *)&p_font, p_index, p_size);
Vector2 advance = *(Vector2 *)&result;
return advance;
}
Vector2 TextServerGDNative::font_get_glyph_kerning(RID p_font, uint32_t p_index_a, uint32_t p_index_b, int p_size) const {
ERR_FAIL_COND_V(interface == nullptr, Vector2());
godot_vector2 result = interface->font_get_glyph_kerning(data, (godot_rid *)&p_font, p_index_a, p_index_b, p_size);
Vector2 kerning = *(Vector2 *)&result;
return kerning;
}
Vector2 TextServerGDNative::font_draw_glyph(RID p_font, RID p_canvas, int p_size, const Vector2 &p_pos, uint32_t p_index, const Color &p_color) const {
ERR_FAIL_COND_V(interface == nullptr, Vector2());
godot_vector2 result = interface->font_draw_glyph(data, (godot_rid *)&p_font, (godot_rid *)&p_canvas, p_size, (const godot_vector2 *)&p_pos, p_index, (const godot_color *)&p_color);
Vector2 advance = *(Vector2 *)&result;
return advance;
}
Vector2 TextServerGDNative::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) const {
ERR_FAIL_COND_V(interface == nullptr, Vector2());
godot_vector2 result = interface->font_draw_glyph_outline(data, (godot_rid *)&p_font, (godot_rid *)&p_canvas, p_size, p_outline_size, (const godot_vector2 *)&p_pos, p_index, (const godot_color *)&p_color);
Vector2 advance = *(Vector2 *)&result;
return advance;
}
float TextServerGDNative::font_get_oversampling() const {
ERR_FAIL_COND_V(interface == nullptr, 1.f);
return interface->font_get_oversampling(data);
}
void TextServerGDNative::font_set_oversampling(float p_oversampling) {
ERR_FAIL_COND(interface == nullptr);
return interface->font_set_oversampling(data, p_oversampling);
}
Vector<String> TextServerGDNative::get_system_fonts() const {
ERR_FAIL_COND_V(interface == nullptr, Vector<String>());
godot_packed_string_array result = interface->get_system_fonts(data);
Vector<String> fonts = *(Vector<String> *)&result;
godot_packed_string_array_destroy(&result);
return fonts;
}
/*************************************************************************/
/* Shaped text buffer interface */
/*************************************************************************/
RID TextServerGDNative::create_shaped_text(TextServer::Direction p_direction, TextServer::Orientation p_orientation) {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->create_shaped_text(data, (godot_int)p_direction, (godot_int)p_orientation);
RID rid = *(RID *)&result;
return rid;
}
void TextServerGDNative::shaped_text_clear(RID p_shaped) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_clear(data, (godot_rid *)&p_shaped);
}
void TextServerGDNative::shaped_text_set_direction(RID p_shaped, TextServer::Direction p_direction) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_set_direction(data, (godot_rid *)&p_shaped, (godot_int)p_direction);
}
TextServer::Direction TextServerGDNative::shaped_text_get_direction(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, TextServer::DIRECTION_LTR);
return (TextServer::Direction)interface->shaped_text_get_direction(data, (godot_rid *)&p_shaped);
}
void TextServerGDNative::shaped_text_set_orientation(RID p_shaped, TextServer::Orientation p_orientation) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_set_orientation(data, (godot_rid *)&p_shaped, (godot_int)p_orientation);
}
TextServer::Orientation TextServerGDNative::shaped_text_get_orientation(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, TextServer::ORIENTATION_HORIZONTAL);
return (TextServer::Orientation)interface->shaped_text_get_orientation(data, (godot_rid *)&p_shaped);
}
void TextServerGDNative::shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_set_bidi_override(data, (godot_rid *)&p_shaped, (const godot_packed_vector2i_array *)&p_override);
}
void TextServerGDNative::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_set_preserve_invalid(data, (godot_rid *)&p_shaped, p_enabled);
}
bool TextServerGDNative::shaped_text_get_preserve_invalid(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return (TextServer::Orientation)interface->shaped_text_get_preserve_invalid(data, (godot_rid *)&p_shaped);
}
void TextServerGDNative::shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) {
ERR_FAIL_COND(interface == nullptr);
interface->shaped_text_set_preserve_control(data, (godot_rid *)&p_shaped, p_enabled);
}
bool TextServerGDNative::shaped_text_get_preserve_control(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return (TextServer::Orientation)interface->shaped_text_get_preserve_control(data, (godot_rid *)&p_shaped);
}
bool TextServerGDNative::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) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_add_string(data, (godot_rid *)&p_shaped, (const godot_string *)&p_text, (const godot_rid **)p_fonts.ptr(), p_size, (const godot_dictionary *)&p_opentype_features, (const godot_string *)&p_language);
}
bool TextServerGDNative::shaped_text_add_object(RID p_shaped, Variant p_key, const Size2 &p_size, VAlign p_inline_align, int p_length) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_add_object(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key, (const godot_vector2 *)&p_size, (godot_int)p_inline_align, p_length);
}
bool TextServerGDNative::shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, VAlign p_inline_align) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_resize_object(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key, (const godot_vector2 *)&p_size, (godot_int)p_inline_align);
}
RID TextServerGDNative::shaped_text_substr(RID p_shaped, int p_start, int p_length) const {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->shaped_text_substr(data, (godot_rid *)&p_shaped, (godot_int)p_start, (godot_int)p_length);
RID rid = *(RID *)&result;
return rid;
}
RID TextServerGDNative::shaped_text_get_parent(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, RID());
godot_rid result = interface->shaped_text_get_parent(data, (godot_rid *)&p_shaped);
RID rid = *(RID *)&result;
return rid;
}
float TextServerGDNative::shaped_text_fit_to_width(RID p_shaped, float p_width, uint8_t p_jst_flags) {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_fit_to_width(data, (godot_rid *)&p_shaped, p_width, p_jst_flags);
}
float TextServerGDNative::shaped_text_tab_align(RID p_shaped, const Vector<float> &p_tab_stops) {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_tab_align(data, (godot_rid *)&p_shaped, (godot_packed_float32_array *)&p_tab_stops);
}
bool TextServerGDNative::shaped_text_shape(RID p_shaped) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_shape(data, (godot_rid *)&p_shaped);
}
bool TextServerGDNative::shaped_text_update_breaks(RID p_shaped) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_update_breaks(data, (godot_rid *)&p_shaped);
}
bool TextServerGDNative::shaped_text_update_justification_ops(RID p_shaped) {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_update_justification_ops(data, (godot_rid *)&p_shaped);
}
bool TextServerGDNative::shaped_text_is_ready(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, false);
return interface->shaped_text_is_ready(data, (godot_rid *)&p_shaped);
}
Vector<TextServer::Glyph> TextServerGDNative::shaped_text_get_glyphs(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, Vector<TextServer::Glyph>());
godot_packed_glyph_array result = interface->shaped_text_get_glyphs(data, (godot_rid *)&p_shaped);
Vector<TextServer::Glyph> glyphs = *(Vector<TextServer::Glyph> *)&result;
godot_packed_glyph_array_destroy(&result);
return glyphs;
}
Vector2i TextServerGDNative::shaped_text_get_range(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, Vector2i());
godot_vector2i result = interface->shaped_text_get_range(data, (godot_rid *)&p_shaped);
Vector2i range = *(Vector2i *)&result;
return range;
}
Vector<TextServer::Glyph> TextServerGDNative::shaped_text_sort_logical(RID p_shaped) {
ERR_FAIL_COND_V(interface == nullptr, Vector<TextServer::Glyph>());
godot_packed_glyph_array result = interface->shaped_text_sort_logical(data, (godot_rid *)&p_shaped);
Vector<TextServer::Glyph> glyphs = *(Vector<TextServer::Glyph> *)&result;
godot_packed_glyph_array_destroy(&result);
return glyphs;
}
Vector<Vector2i> TextServerGDNative::shaped_text_get_line_breaks_adv(RID p_shaped, const Vector<float> &p_width, int p_start, bool p_once, uint8_t p_break_flags) const {
ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>());
if (interface->shaped_text_get_line_breaks_adv != nullptr) {
godot_packed_vector2i_array result = interface->shaped_text_get_line_breaks_adv(data, (godot_rid *)&p_shaped, (godot_packed_float32_array *)&p_width, p_start, p_once, p_break_flags);
Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result;
godot_packed_vector2i_array_destroy(&result);
return breaks;
} else {
return TextServer::shaped_text_get_line_breaks_adv(p_shaped, p_width, p_break_flags);
}
}
Vector<Vector2i> TextServerGDNative::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint8_t p_break_flags) const {
ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>());
if (interface->shaped_text_get_line_breaks != nullptr) {
godot_packed_vector2i_array result = interface->shaped_text_get_line_breaks(data, (godot_rid *)&p_shaped, p_width, p_start, p_break_flags);
Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result;
godot_packed_vector2i_array_destroy(&result);
return breaks;
} else {
return TextServer::shaped_text_get_line_breaks(p_shaped, p_width, p_break_flags);
}
}
Vector<Vector2i> TextServerGDNative::shaped_text_get_word_breaks(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, Vector<Vector2i>());
if (interface->shaped_text_get_word_breaks != nullptr) {
godot_packed_vector2i_array result = interface->shaped_text_get_word_breaks(data, (godot_rid *)&p_shaped);
Vector<Vector2i> breaks = *(Vector<Vector2i> *)&result;
godot_packed_vector2i_array_destroy(&result);
return breaks;
} else {
return TextServer::shaped_text_get_word_breaks(p_shaped);
}
}
Array TextServerGDNative::shaped_text_get_objects(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, Array());
godot_array result = interface->shaped_text_get_objects(data, (godot_rid *)&p_shaped);
Array rect = *(Array *)&result;
return rect;
}
Rect2 TextServerGDNative::shaped_text_get_object_rect(RID p_shaped, Variant p_key) const {
ERR_FAIL_COND_V(interface == nullptr, Rect2());
godot_rect2 result = interface->shaped_text_get_object_rect(data, (godot_rid *)&p_shaped, (const godot_variant *)&p_key);
Rect2 rect = *(Rect2 *)&result;
return rect;
}
Size2 TextServerGDNative::shaped_text_get_size(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, Size2());
godot_vector2 result = interface->shaped_text_get_size(data, (godot_rid *)&p_shaped);
Size2 size = *(Size2 *)&result;
return size;
}
float TextServerGDNative::shaped_text_get_ascent(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_get_ascent(data, (godot_rid *)&p_shaped);
}
float TextServerGDNative::shaped_text_get_descent(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_get_descent(data, (godot_rid *)&p_shaped);
}
float TextServerGDNative::shaped_text_get_width(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_get_width(data, (godot_rid *)&p_shaped);
}
float TextServerGDNative::shaped_text_get_underline_position(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_get_underline_position(data, (godot_rid *)&p_shaped);
}
float TextServerGDNative::shaped_text_get_underline_thickness(RID p_shaped) const {
ERR_FAIL_COND_V(interface == nullptr, 0.f);
return interface->shaped_text_get_underline_thickness(data, (godot_rid *)&p_shaped);
}
String TextServerGDNative::format_number(const String &p_string, const String &p_language) const {
ERR_FAIL_COND_V(interface == nullptr, String());
godot_string result = interface->format_number(data, (const godot_string *)&p_string, (const godot_string *)&p_language);
if (interface->format_number == nullptr) {
return p_string;
}
String ret = *(String *)&result;
godot_string_destroy(&result);
return ret;
}
String TextServerGDNative::parse_number(const String &p_string, const String &p_language) const {
ERR_FAIL_COND_V(interface == nullptr, String());
if (interface->parse_number == nullptr) {
return p_string;
}
godot_string result = interface->parse_number(data, (const godot_string *)&p_string, (const godot_string *)&p_language);
String ret = *(String *)&result;
godot_string_destroy(&result);
return ret;
}
String TextServerGDNative::percent_sign(const String &p_language) const {
ERR_FAIL_COND_V(interface == nullptr, String());
if (interface->percent_sign == nullptr) {
return "%";
}
godot_string result = interface->percent_sign(data, (const godot_string *)&p_language);
String ret = *(String *)&result;
godot_string_destroy(&result);
return ret;
}
TextServer *TextServerGDNative::create_func(Error &r_error, void *p_user_data) {
const godot_text_interface_gdnative *interface = (const godot_text_interface_gdnative *)p_user_data;
r_error = OK;
TextServerGDNative *server = memnew(TextServerGDNative());
server->interface = interface;
server->data = interface->constructor((godot_object *)server);
return server;
}
TextServerGDNative::TextServerGDNative() {
data = nullptr;
interface = nullptr;
}
TextServerGDNative::~TextServerGDNative() {
if (interface != nullptr) {
interface->destructor(data);
data = nullptr;
interface = nullptr;
}
}
/*************************************************************************/
/* GDNative functions */
/*************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
static_assert(sizeof(godot_glyph) == sizeof(TextServer::Glyph), "Glyph size mismatch");
static_assert(sizeof(godot_packed_glyph_array) == sizeof(Vector<TextServer::Glyph>), "Vector<Glyph> size mismatch");
void GDAPI godot_text_register_interface(const godot_text_interface_gdnative *p_interface, const godot_string *p_name, uint32_t p_features) {
ERR_FAIL_COND(p_interface->version.major != 1);
String name = *(String *)p_name;
TextServerManager::register_create_function(name + "(GDNative)", p_features, TextServerGDNative::create_func, (void *)p_interface);
}
// Glyph
void GDAPI godot_glyph_new(godot_glyph *r_dest) {
TextServer::Glyph *dest = (TextServer::Glyph *)r_dest;
*dest = TextServer::Glyph();
}
godot_vector2i GDAPI godot_glyph_get_range(const godot_glyph *p_self) {
godot_vector2i dest;
Vector2i *d = (Vector2i *)&dest;
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
d->x = self->start;
d->y = self->end;
return dest;
}
void GDAPI godot_glyph_set_range(godot_glyph *p_self, const godot_vector2i *p_range) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
const Vector2i *range = (const Vector2i *)p_range;
self->start = range->x;
self->end = range->y;
}
godot_int GDAPI godot_glyph_get_count(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->count;
}
void GDAPI godot_glyph_set_count(godot_glyph *p_self, godot_int p_count) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->count = p_count;
}
godot_int GDAPI godot_glyph_get_repeat(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->repeat;
}
void GDAPI godot_glyph_set_repeat(godot_glyph *p_self, godot_int p_repeat) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->repeat = p_repeat;
}
godot_int GDAPI godot_glyph_get_flags(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->flags;
}
void GDAPI godot_glyph_set_flags(godot_glyph *p_self, godot_int p_flags) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->flags = p_flags;
}
godot_vector2 GDAPI godot_glyph_get_offset(const godot_glyph *p_self) {
godot_vector2 dest;
Vector2 *d = (Vector2 *)&dest;
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
d->x = self->x_off;
d->y = self->y_off;
return dest;
}
void GDAPI godot_glyph_set_offset(godot_glyph *p_self, const godot_vector2 *p_offset) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
const Vector2 *offset = (const Vector2 *)p_offset;
self->x_off = offset->x;
self->y_off = offset->y;
}
godot_real GDAPI godot_glyph_get_advance(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->advance;
}
void GDAPI godot_glyph_set_advance(godot_glyph *p_self, godot_real p_advance) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->advance = p_advance;
}
godot_rid GDAPI godot_glyph_get_font(const godot_glyph *p_self) {
godot_rid dest;
RID *d = (RID *)&dest;
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
*d = self->font_rid;
return dest;
}
void GDAPI godot_glyph_set_font(godot_glyph *p_self, godot_rid *p_font) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
const RID *font = (const RID *)p_font;
self->font_rid = *font;
}
godot_int GDAPI godot_glyph_get_font_size(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->font_size;
}
void GDAPI godot_glyph_set_font_size(godot_glyph *p_self, godot_int p_size) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->font_size = p_size;
}
godot_int GDAPI godot_glyph_get_index(const godot_glyph *p_self) {
const TextServer::Glyph *self = (const TextServer::Glyph *)p_self;
return self->index;
}
void GDAPI godot_glyph_set_index(godot_glyph *p_self, godot_int p_index) {
TextServer::Glyph *self = (TextServer::Glyph *)p_self;
self->index = p_index;
}
// GlyphArray
void GDAPI godot_packed_glyph_array_new(godot_packed_glyph_array *r_dest) {
Vector<TextServer::Glyph> *dest = (Vector<TextServer::Glyph> *)r_dest;
memnew_placement(dest, Vector<TextServer::Glyph>);
}
void GDAPI godot_packed_glyph_array_new_copy(godot_packed_glyph_array *r_dest, const godot_packed_glyph_array *p_src) {
Vector<TextServer::Glyph> *dest = (Vector<TextServer::Glyph> *)r_dest;
const Vector<TextServer::Glyph> *src = (const Vector<TextServer::Glyph> *)p_src;
memnew_placement(dest, Vector<TextServer::Glyph>(*src));
}
const godot_glyph GDAPI *godot_packed_glyph_array_ptr(const godot_packed_glyph_array *p_self) {
const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self;
return (const godot_glyph *)self->ptr();
}
godot_glyph GDAPI *godot_packed_glyph_array_ptrw(godot_packed_glyph_array *p_self) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
return (godot_glyph *)self->ptrw();
}
void GDAPI godot_packed_glyph_array_append(godot_packed_glyph_array *p_self, const godot_glyph *p_data) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
TextServer::Glyph &s = *(TextServer::Glyph *)p_data;
self->push_back(s);
}
void GDAPI godot_packed_glyph_array_append_array(godot_packed_glyph_array *p_self, const godot_packed_glyph_array *p_array) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
Vector<TextServer::Glyph> *array = (Vector<TextServer::Glyph> *)p_array;
self->append_array(*array);
}
godot_error GDAPI godot_packed_glyph_array_insert(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
TextServer::Glyph &s = *(TextServer::Glyph *)p_data;
return (godot_error)self->insert(p_idx, s);
}
godot_bool GDAPI godot_packed_glyph_array_has(godot_packed_glyph_array *p_self, const godot_glyph *p_value) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
TextServer::Glyph &v = *(TextServer::Glyph *)p_value;
return (godot_bool)self->has(v);
}
void GDAPI godot_packed_glyph_array_sort(godot_packed_glyph_array *p_self) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
self->sort();
}
void GDAPI godot_packed_glyph_array_invert(godot_packed_glyph_array *p_self) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
self->invert();
}
void GDAPI godot_packed_glyph_array_push_back(godot_packed_glyph_array *p_self, const godot_glyph *p_data) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
TextServer::Glyph &s = *(TextServer::Glyph *)p_data;
self->push_back(s);
}
void GDAPI godot_packed_glyph_array_remove(godot_packed_glyph_array *p_self, const godot_int p_idx) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
self->remove(p_idx);
}
void GDAPI godot_packed_glyph_array_resize(godot_packed_glyph_array *p_self, const godot_int p_size) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
self->resize(p_size);
}
void GDAPI godot_packed_glyph_array_set(godot_packed_glyph_array *p_self, const godot_int p_idx, const godot_glyph *p_data) {
Vector<TextServer::Glyph> *self = (Vector<TextServer::Glyph> *)p_self;
TextServer::Glyph &s = *(TextServer::Glyph *)p_data;
self->set(p_idx, s);
}
godot_glyph GDAPI godot_packed_glyph_array_get(const godot_packed_glyph_array *p_self, const godot_int p_idx) {
const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self;
godot_glyph v;
TextServer::Glyph *s = (TextServer::Glyph *)&v;
*s = self->get(p_idx);
return v;
}
godot_int GDAPI godot_packed_glyph_array_size(const godot_packed_glyph_array *p_self) {
const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self;
return self->size();
}
godot_bool GDAPI godot_packed_glyph_array_empty(const godot_packed_glyph_array *p_self) {
const Vector<TextServer::Glyph> *self = (const Vector<TextServer::Glyph> *)p_self;
return self->empty();
}
void GDAPI godot_packed_glyph_array_destroy(godot_packed_glyph_array *p_self) {
((Vector<TextServer::Glyph> *)p_self)->~Vector();
}
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,183 @@
/*************************************************************************/
/* text_server_gdnative.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEXT_SERVER_GDNATIVE_H
#define TEXT_SERVER_GDNATIVE_H
#include "modules/gdnative/gdnative.h"
#include "servers/text_server.h"
class TextServerGDNative : public TextServer {
GDCLASS(TextServerGDNative, TextServer);
const godot_text_interface_gdnative *interface = nullptr;
void *data = nullptr;
protected:
static void _bind_methods(){};
public:
virtual bool has_feature(Feature p_feature) override;
virtual String get_name() const override;
virtual void free(RID p_rid) override;
virtual bool has(RID p_rid) override;
virtual bool load_support_data(const String &p_filename) override;
#ifdef TOOLS_ENABLED
virtual String get_support_data_filename() override;
virtual String get_support_data_info() override;
virtual bool save_support_data(const String &p_filename) override;
#endif
virtual bool is_locale_right_to_left(const String &p_locale) override;
/* Font interface */
virtual RID create_font_system(const String &p_name, int p_base_size = 16) override;
virtual RID create_font_resource(const String &p_filename, int p_base_size = 16) override;
virtual RID create_font_memory(const uint8_t *p_data, size_t p_size, const String &p_type, int p_base_size = 16) override;
virtual float font_get_height(RID p_font, int p_size) const override;
virtual float font_get_ascent(RID p_font, int p_size) const override;
virtual float font_get_descent(RID p_font, int p_size) const override;
virtual float font_get_underline_position(RID p_font, int p_size) const override;
virtual float font_get_underline_thickness(RID p_font, int p_size) const override;
virtual void font_set_antialiased(RID p_font, bool p_antialiased) override;
virtual bool font_get_antialiased(RID p_font) const override;
virtual Dictionary font_get_feature_list(RID p_font) const override;
virtual void font_set_hinting(RID p_font, Hinting p_hinting) override;
virtual Hinting font_get_hinting(RID p_font) const override;
virtual void font_set_distance_field_hint(RID p_font, bool p_distance_field) override;
virtual bool font_get_distance_field_hint(RID p_font) const override;
virtual void font_set_force_autohinter(RID p_font, bool p_enabeld) override;
virtual bool font_get_force_autohinter(RID p_font) const override;
virtual bool font_has_char(RID p_font, char32_t p_char) const override;
virtual String font_get_supported_chars(RID p_font) const override;
virtual bool font_has_outline(RID p_font) const override;
virtual float font_get_base_size(RID p_font) const override;
virtual bool font_is_language_supported(RID p_font, const String &p_language) const override;
virtual void font_set_language_support_override(RID p_font, const String &p_language, bool p_supported) override;
virtual bool font_get_language_support_override(RID p_font, const String &p_language) override;
virtual void font_remove_language_support_override(RID p_font, const String &p_language) override;
Vector<String> font_get_language_support_overrides(RID p_font) override;
virtual bool font_is_script_supported(RID p_font, const String &p_script) const override;
virtual void font_set_script_support_override(RID p_font, const String &p_script, bool p_supported) override;
virtual bool font_get_script_support_override(RID p_font, const String &p_script) override;
virtual void font_remove_script_support_override(RID p_font, const String &p_script) override;
Vector<String> font_get_script_support_overrides(RID p_font) override;
virtual uint32_t font_get_glyph_index(RID p_font, char32_t p_char, char32_t p_variation_selector = 0x0000) const override;
virtual Vector2 font_get_glyph_advance(RID p_font, uint32_t p_index, int p_size) const override;
virtual Vector2 font_get_glyph_kerning(RID p_font, uint32_t p_index_a, uint32_t p_index_b, int p_size) const override;
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;
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;
virtual float font_get_oversampling() const override;
virtual void font_set_oversampling(float p_oversampling) override;
virtual Vector<String> get_system_fonts() const override;
/* Shaped text buffer interface */
virtual RID create_shaped_text(Direction p_direction = DIRECTION_AUTO, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
virtual void shaped_text_clear(RID p_shaped) override;
virtual void shaped_text_set_direction(RID p_shaped, Direction p_direction = DIRECTION_AUTO) override;
virtual Direction shaped_text_get_direction(RID p_shaped) const override;
virtual void shaped_text_set_bidi_override(RID p_shaped, const Vector<Vector2i> &p_override) override;
virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) override;
virtual Orientation shaped_text_get_orientation(RID p_shaped) const override;
virtual void shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) override;
virtual bool shaped_text_get_preserve_invalid(RID p_shaped) const override;
virtual void shaped_text_set_preserve_control(RID p_shaped, bool p_enabled) override;
virtual bool shaped_text_get_preserve_control(RID p_shaped) const override;
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;
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;
virtual bool shaped_text_resize_object(RID p_shaped, Variant p_key, const Size2 &p_size, VAlign p_inline_align = VALIGN_CENTER) override;
virtual RID shaped_text_substr(RID p_shaped, int p_start, int p_length) const override;
virtual RID shaped_text_get_parent(RID p_shaped) const override;
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;
virtual float shaped_text_tab_align(RID p_shaped, const Vector<float> &p_tab_stops) override;
virtual bool shaped_text_shape(RID p_shaped) override;
virtual bool shaped_text_update_breaks(RID p_shaped) override;
virtual bool shaped_text_update_justification_ops(RID p_shaped) override;
virtual bool shaped_text_is_ready(RID p_shaped) const override;
virtual Vector<Glyph> shaped_text_get_glyphs(RID p_shaped) const override;
virtual Vector2i shaped_text_get_range(RID p_shaped) const override;
virtual Vector<Glyph> shaped_text_sort_logical(RID p_shaped) override;
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;
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;
virtual Vector<Vector2i> shaped_text_get_word_breaks(RID p_shaped) const override;
virtual Array shaped_text_get_objects(RID p_shaped) const override;
virtual Rect2 shaped_text_get_object_rect(RID p_shaped, Variant p_key) const override;
virtual Size2 shaped_text_get_size(RID p_shaped) const override;
virtual float shaped_text_get_ascent(RID p_shaped) const override;
virtual float shaped_text_get_descent(RID p_shaped) const override;
virtual float shaped_text_get_width(RID p_shaped) const override;
virtual float shaped_text_get_underline_position(RID p_shaped) const override;
virtual float shaped_text_get_underline_thickness(RID p_shaped) const override;
virtual String format_number(const String &p_string, const String &p_language = "") const override;
virtual String parse_number(const String &p_string, const String &p_language = "") const override;
virtual String percent_sign(const String &p_language = "") const override;
static TextServer *create_func(Error &r_error, void *p_user_data);
TextServerGDNative();
~TextServerGDNative();
};
#endif // TEXT_SERVER_GDNATIVE_H

View file

@ -457,9 +457,6 @@ if env["builtin_icu"]:
]
)
if env_icu.msvc:
env_icu.AppendUnique(CCFLAGS=["/utf-8"])
env_icu.disable_warnings()
env_thirdparty = env_icu.Clone()
env_thirdparty.disable_warnings()

View file

@ -539,13 +539,13 @@ Vector2 BitmapFontDataAdvanced::draw_glyph(RID p_canvas, int p_size, const Vecto
cpos += c->align * (float(p_size) / float(base_size));
cpos.y -= ascent * (float(p_size) / float(base_size));
if (RenderingServer::get_singleton() != nullptr) {
if (distance_field_hint) {
RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, true);
}
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, c->rect.size * (float(p_size) / float(base_size))), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, RID(), RID(), Color(1, 1, 1, 1), false);
if (distance_field_hint) {
RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, false);
}
//if (distance_field_hint) { // Not implemented.
// RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, true);
//}
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, c->rect.size * (float(p_size) / float(base_size))), textures[c->texture_idx]->get_rid(), c->rect, p_color, false, false);
//if (distance_field_hint) {
// RenderingServer::get_singleton()->canvas_item_set_distance_field_mode(p_canvas, false);
//}
}
}

View file

@ -924,7 +924,7 @@ Vector2 DynamicFontDataAdvanced::draw_glyph(RID p_canvas, int p_size, const Vect
}
if (RenderingServer::get_singleton() != nullptr) {
RID texture = fds->textures[ch.texture_idx].texture->get_rid();
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, ch.rect.size), texture, ch.rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, ch.rect.size), texture, ch.rect_uv, modulate, false, false);
}
}
@ -955,7 +955,7 @@ Vector2 DynamicFontDataAdvanced::draw_glyph_outline(RID p_canvas, int p_size, in
}
if (RenderingServer::get_singleton() != nullptr) {
RID texture = fds->textures[ch.texture_idx].texture->get_rid();
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, ch.rect.size), texture, ch.rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas, Rect2(cpos, ch.rect.size), texture, ch.rect_uv, modulate, false, false);
}
}