summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/godot_body_2d.cpp2
-rw-r--r--servers/physics_2d/godot_body_2d.h1
-rw-r--r--servers/physics_2d/godot_body_direct_state_2d.cpp4
-rw-r--r--servers/physics_2d/godot_body_direct_state_2d.h1
-rw-r--r--servers/physics_2d/godot_physics_server_2d.cpp9
-rw-r--r--servers/physics_3d/godot_body_3d.cpp2
-rw-r--r--servers/physics_3d/godot_body_3d.h1
-rw-r--r--servers/physics_3d/godot_body_direct_state_3d.cpp4
-rw-r--r--servers/physics_3d/godot_body_direct_state_3d.h1
-rw-r--r--servers/physics_3d/godot_physics_server_3d.cpp9
-rw-r--r--servers/physics_server_2d.cpp2
-rw-r--r--servers/physics_server_2d.h1
-rw-r--r--servers/physics_server_3d.cpp2
-rw-r--r--servers/physics_server_3d.h1
-rw-r--r--servers/rendering/shader_language.cpp18
-rw-r--r--servers/text/text_server_extension.cpp60
-rw-r--r--servers/text/text_server_extension.h20
-rw-r--r--servers/text_server.cpp19
-rw-r--r--servers/text_server.h20
19 files changed, 168 insertions, 9 deletions
diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp
index 109914d585..442c580920 100644
--- a/servers/physics_2d/godot_body_2d.cpp
+++ b/servers/physics_2d/godot_body_2d.cpp
@@ -221,7 +221,7 @@ Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const {
return inertia;
}
case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: {
- return center_of_mass;
+ return center_of_mass_local;
}
case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h
index 817d5f1b0d..7b11b50739 100644
--- a/servers/physics_2d/godot_body_2d.h
+++ b/servers/physics_2d/godot_body_2d.h
@@ -282,6 +282,7 @@ public:
void reset_mass_properties();
_FORCE_INLINE_ const Vector2 &get_center_of_mass() const { return center_of_mass; }
+ _FORCE_INLINE_ const Vector2 &get_center_of_mass_local() const { return center_of_mass_local; }
_FORCE_INLINE_ real_t get_inv_mass() const { return _inv_mass; }
_FORCE_INLINE_ real_t get_inv_inertia() const { return _inv_inertia; }
_FORCE_INLINE_ real_t get_friction() const { return friction; }
diff --git a/servers/physics_2d/godot_body_direct_state_2d.cpp b/servers/physics_2d/godot_body_direct_state_2d.cpp
index deebc57f37..9c9bd56268 100644
--- a/servers/physics_2d/godot_body_direct_state_2d.cpp
+++ b/servers/physics_2d/godot_body_direct_state_2d.cpp
@@ -50,6 +50,10 @@ Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass() const {
return body->get_center_of_mass();
}
+Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass_local() const {
+ return body->get_center_of_mass_local();
+}
+
real_t GodotPhysicsDirectBodyState2D::get_inverse_mass() const {
return body->get_inv_mass();
}
diff --git a/servers/physics_2d/godot_body_direct_state_2d.h b/servers/physics_2d/godot_body_direct_state_2d.h
index 2f3e8e5095..ff25205d52 100644
--- a/servers/physics_2d/godot_body_direct_state_2d.h
+++ b/servers/physics_2d/godot_body_direct_state_2d.h
@@ -46,6 +46,7 @@ public:
virtual real_t get_total_linear_damp() const override;
virtual Vector2 get_center_of_mass() const override;
+ virtual Vector2 get_center_of_mass_local() const override;
virtual real_t get_inverse_mass() const override;
virtual real_t get_inverse_inertia() const override;
diff --git a/servers/physics_2d/godot_physics_server_2d.cpp b/servers/physics_2d/godot_physics_server_2d.cpp
index cf66b80076..617fa6470a 100644
--- a/servers/physics_2d/godot_physics_server_2d.cpp
+++ b/servers/physics_2d/godot_physics_server_2d.cpp
@@ -963,10 +963,17 @@ bool GodotPhysicsServer2D::body_test_motion(RID p_body, const MotionParameters &
PhysicsDirectBodyState2D *GodotPhysicsServer2D::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
+ if (!body_owner.owns(p_body)) {
+ return nullptr;
+ }
+
GodotBody2D *body = body_owner.get_or_null(p_body);
ERR_FAIL_COND_V(!body, nullptr);
- ERR_FAIL_COND_V(!body->get_space(), nullptr);
+ if (!body->get_space()) {
+ return nullptr;
+ }
+
ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
return body->get_direct_state();
diff --git a/servers/physics_3d/godot_body_3d.cpp b/servers/physics_3d/godot_body_3d.cpp
index 768c9e6572..acf60d61c2 100644
--- a/servers/physics_3d/godot_body_3d.cpp
+++ b/servers/physics_3d/godot_body_3d.cpp
@@ -267,7 +267,7 @@ Variant GodotBody3D::get_param(PhysicsServer3D::BodyParameter p_param) const {
}
} break;
case PhysicsServer3D::BODY_PARAM_CENTER_OF_MASS: {
- return center_of_mass;
+ return center_of_mass_local;
} break;
case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: {
return gravity_scale;
diff --git a/servers/physics_3d/godot_body_3d.h b/servers/physics_3d/godot_body_3d.h
index 4993ea6a1b..7fc2f58168 100644
--- a/servers/physics_3d/godot_body_3d.h
+++ b/servers/physics_3d/godot_body_3d.h
@@ -200,6 +200,7 @@ public:
_FORCE_INLINE_ Basis get_principal_inertia_axes() const { return principal_inertia_axes; }
_FORCE_INLINE_ Vector3 get_center_of_mass() const { return center_of_mass; }
+ _FORCE_INLINE_ Vector3 get_center_of_mass_local() const { return center_of_mass_local; }
_FORCE_INLINE_ Vector3 xform_local_to_principal(const Vector3 &p_pos) const { return principal_inertia_axes_local.xform(p_pos - center_of_mass_local); }
_FORCE_INLINE_ void set_linear_velocity(const Vector3 &p_velocity) { linear_velocity = p_velocity; }
diff --git a/servers/physics_3d/godot_body_direct_state_3d.cpp b/servers/physics_3d/godot_body_direct_state_3d.cpp
index 9c234a5752..a929cab6f9 100644
--- a/servers/physics_3d/godot_body_direct_state_3d.cpp
+++ b/servers/physics_3d/godot_body_direct_state_3d.cpp
@@ -49,6 +49,10 @@ Vector3 GodotPhysicsDirectBodyState3D::get_center_of_mass() const {
return body->get_center_of_mass();
}
+Vector3 GodotPhysicsDirectBodyState3D::get_center_of_mass_local() const {
+ return body->get_center_of_mass_local();
+}
+
Basis GodotPhysicsDirectBodyState3D::get_principal_inertia_axes() const {
return body->get_principal_inertia_axes();
}
diff --git a/servers/physics_3d/godot_body_direct_state_3d.h b/servers/physics_3d/godot_body_direct_state_3d.h
index 6c584a2634..35fd1543b0 100644
--- a/servers/physics_3d/godot_body_direct_state_3d.h
+++ b/servers/physics_3d/godot_body_direct_state_3d.h
@@ -46,6 +46,7 @@ public:
virtual real_t get_total_linear_damp() const override;
virtual Vector3 get_center_of_mass() const override;
+ virtual Vector3 get_center_of_mass_local() const override;
virtual Basis get_principal_inertia_axes() const override;
virtual real_t get_inverse_mass() const override;
diff --git a/servers/physics_3d/godot_physics_server_3d.cpp b/servers/physics_3d/godot_physics_server_3d.cpp
index 73654939ca..3e7f9faa27 100644
--- a/servers/physics_3d/godot_physics_server_3d.cpp
+++ b/servers/physics_3d/godot_physics_server_3d.cpp
@@ -881,10 +881,17 @@ bool GodotPhysicsServer3D::body_test_motion(RID p_body, const MotionParameters &
PhysicsDirectBodyState3D *GodotPhysicsServer3D::body_get_direct_state(RID p_body) {
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
+ if (!body_owner.owns(p_body)) {
+ return nullptr;
+ }
+
GodotBody3D *body = body_owner.get_or_null(p_body);
ERR_FAIL_NULL_V(body, nullptr);
- ERR_FAIL_NULL_V(body->get_space(), nullptr);
+ if (!body->get_space()) {
+ return nullptr;
+ }
+
ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification.");
return body->get_direct_state();
diff --git a/servers/physics_server_2d.cpp b/servers/physics_server_2d.cpp
index 466558c9db..fa89ccec65 100644
--- a/servers/physics_server_2d.cpp
+++ b/servers/physics_server_2d.cpp
@@ -78,6 +78,7 @@ void PhysicsDirectBodyState2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState2D::get_total_angular_damp);
ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState2D::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState2D::get_center_of_mass_local);
ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState2D::get_inverse_mass);
ClassDB::bind_method(D_METHOD("get_inverse_inertia"), &PhysicsDirectBodyState2D::get_inverse_inertia);
@@ -124,6 +125,7 @@ void PhysicsDirectBodyState2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "total_linear_damp"), "", "get_total_linear_damp");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "total_gravity"), "", "get_total_gravity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass"), "", "get_center_of_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center_of_mass_local"), "", "get_center_of_mass_local");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sleeping"), "set_sleep_state", "is_sleeping");
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h
index 55ac7e1fdc..fec03a8111 100644
--- a/servers/physics_server_2d.h
+++ b/servers/physics_server_2d.h
@@ -49,6 +49,7 @@ public:
virtual real_t get_total_angular_damp() const = 0; // get density of this body space/area
virtual Vector2 get_center_of_mass() const = 0;
+ virtual Vector2 get_center_of_mass_local() const = 0;
virtual real_t get_inverse_mass() const = 0; // get the mass
virtual real_t get_inverse_inertia() const = 0; // get density of this body space
diff --git a/servers/physics_server_3d.cpp b/servers/physics_server_3d.cpp
index a354b69a29..eb52cbfe5a 100644
--- a/servers/physics_server_3d.cpp
+++ b/servers/physics_server_3d.cpp
@@ -77,6 +77,7 @@ void PhysicsDirectBodyState3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_total_angular_damp"), &PhysicsDirectBodyState3D::get_total_angular_damp);
ClassDB::bind_method(D_METHOD("get_center_of_mass"), &PhysicsDirectBodyState3D::get_center_of_mass);
+ ClassDB::bind_method(D_METHOD("get_center_of_mass_local"), &PhysicsDirectBodyState3D::get_center_of_mass_local);
ClassDB::bind_method(D_METHOD("get_principal_inertia_axes"), &PhysicsDirectBodyState3D::get_principal_inertia_axes);
ClassDB::bind_method(D_METHOD("get_inverse_mass"), &PhysicsDirectBodyState3D::get_inverse_mass);
@@ -126,6 +127,7 @@ void PhysicsDirectBodyState3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "inverse_inertia"), "", "get_inverse_inertia");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "total_gravity"), "", "get_total_gravity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass"), "", "get_center_of_mass");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "center_of_mass_local"), "", "get_center_of_mass_local");
ADD_PROPERTY(PropertyInfo(Variant::BASIS, "principal_inertia_axes"), "", "get_principal_inertia_axes");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "angular_velocity"), "set_angular_velocity", "get_angular_velocity");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "linear_velocity"), "set_linear_velocity", "get_linear_velocity");
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h
index 8883443e34..b5113fd35f 100644
--- a/servers/physics_server_3d.h
+++ b/servers/physics_server_3d.h
@@ -48,6 +48,7 @@ public:
virtual real_t get_total_linear_damp() const = 0;
virtual Vector3 get_center_of_mass() const = 0;
+ virtual Vector3 get_center_of_mass_local() const = 0;
virtual Basis get_principal_inertia_axes() const = 0;
virtual real_t get_inverse_mass() const = 0; // get the mass
virtual Vector3 get_inverse_inertia() const = 0; // get density of this body space
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 04cc844483..d803d5fcf8 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -7439,7 +7439,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
int texture_uniforms = 0;
int texture_binding = 0;
- int uniforms = 0;
int instance_index = 0;
ShaderNode::Uniform::Scope uniform_scope = ShaderNode::Uniform::SCOPE_LOCAL;
@@ -7790,9 +7789,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
return ERR_PARSE_ERROR;
}
uniform2.texture_order = -1;
- if (uniform_scope != ShaderNode::Uniform::SCOPE_INSTANCE) {
- uniform2.order = uniforms++;
- }
}
if (uniform2.array_size > 0) {
@@ -8771,6 +8767,20 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct
tk = _get_token();
}
+ int uniforms = 0;
+
+ // Need to push arrays to first place in a uniform buffer in order to correct work.
+ for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
+ if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size > 0) {
+ E->get().order = uniforms++;
+ }
+ }
+ for (Map<StringName, ShaderNode::Uniform>::Element *E = shader->uniforms.front(); E; E = E->next()) {
+ if (E->get().texture_order == -1 && E->get().scope != ShaderNode::Uniform::SCOPE_INSTANCE && E->get().array_size == 0) {
+ E->get().order = uniforms++;
+ }
+ }
+
int error_line;
String error_message;
if (!_check_varying_usages(&error_line, &error_message)) {
diff --git a/servers/text/text_server_extension.cpp b/servers/text/text_server_extension.cpp
index a44fee7c95..0a7523e33a 100644
--- a/servers/text/text_server_extension.cpp
+++ b/servers/text/text_server_extension.cpp
@@ -55,6 +55,15 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_font_set_data, "font_rid", "data");
GDVIRTUAL_BIND(_font_set_data_ptr, "font_rid", "data_ptr", "data_size");
+ GDVIRTUAL_BIND(_font_set_style, "font_rid", "style");
+ GDVIRTUAL_BIND(_font_get_style, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_name, "font_rid", "name");
+ GDVIRTUAL_BIND(_font_get_name, "font_rid");
+
+ GDVIRTUAL_BIND(_font_set_style_name, "font_rid", "name_style");
+ GDVIRTUAL_BIND(_font_get_style_name, "font_rid");
+
GDVIRTUAL_BIND(_font_set_antialiased, "font_rid", "antialiased");
GDVIRTUAL_BIND(_font_is_antialiased, "font_rid");
@@ -185,6 +194,9 @@ void TextServerExtension::_bind_methods() {
GDVIRTUAL_BIND(_shaped_text_set_bidi_override, "shaped", "override");
+ GDVIRTUAL_BIND(_shaped_text_set_custom_punctuation, "shaped", "punct");
+ GDVIRTUAL_BIND(_shaped_text_get_custom_punctuation, "shaped");
+
GDVIRTUAL_BIND(_shaped_text_set_orientation, "shaped", "orientation");
GDVIRTUAL_BIND(_shaped_text_get_orientation, "shaped");
@@ -368,6 +380,42 @@ void TextServerExtension::font_set_data_ptr(RID p_font_rid, const uint8_t *p_dat
GDVIRTUAL_CALL(_font_set_data_ptr, p_font_rid, p_data_ptr, p_data_size);
}
+void TextServerExtension::font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) {
+ GDVIRTUAL_CALL(_font_set_style, p_font_rid, p_style);
+}
+
+uint32_t /*FontStyle*/ TextServerExtension::font_get_style(RID p_font_rid) const {
+ uint32_t ret;
+ if (GDVIRTUAL_CALL(_font_get_style, p_font_rid, ret)) {
+ return ret;
+ }
+ return 0;
+}
+
+void TextServerExtension::font_set_style_name(RID p_font_rid, const String &p_name) {
+ GDVIRTUAL_CALL(_font_set_style_name, p_font_rid, p_name);
+}
+
+String TextServerExtension::font_get_style_name(RID p_font_rid) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_font_get_style_name, p_font_rid, ret)) {
+ return ret;
+ }
+ return String();
+}
+
+void TextServerExtension::font_set_name(RID p_font_rid, const String &p_name) {
+ GDVIRTUAL_CALL(_font_set_name, p_font_rid, p_name);
+}
+
+String TextServerExtension::font_get_name(RID p_font_rid) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_font_get_name, p_font_rid, ret)) {
+ return ret;
+ }
+ return String();
+}
+
void TextServerExtension::font_set_antialiased(RID p_font_rid, bool p_antialiased) {
GDVIRTUAL_CALL(_font_set_antialiased, p_font_rid, p_antialiased);
}
@@ -906,6 +954,18 @@ void TextServerExtension::shaped_text_set_bidi_override(RID p_shaped, const Arra
GDVIRTUAL_CALL(_shaped_text_set_bidi_override, p_shaped, p_override);
}
+void TextServerExtension::shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) {
+ GDVIRTUAL_CALL(_shaped_text_set_custom_punctuation, p_shaped, p_punct);
+}
+
+String TextServerExtension::shaped_text_get_custom_punctuation(RID p_shaped) const {
+ String ret;
+ if (GDVIRTUAL_CALL(_shaped_text_get_custom_punctuation, p_shaped, ret)) {
+ return ret;
+ }
+ return String();
+}
+
void TextServerExtension::shaped_text_set_preserve_invalid(RID p_shaped, bool p_enabled) {
GDVIRTUAL_CALL(_shaped_text_set_preserve_invalid, p_shaped, p_enabled);
}
diff --git a/servers/text/text_server_extension.h b/servers/text/text_server_extension.h
index 954b2cf660..e419b4055d 100644
--- a/servers/text/text_server_extension.h
+++ b/servers/text/text_server_extension.h
@@ -84,6 +84,21 @@ public:
GDVIRTUAL2(_font_set_data, RID, const PackedByteArray &);
GDVIRTUAL3(_font_set_data_ptr, RID, GDNativeConstPtr<const uint8_t>, uint64_t);
+ virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) override;
+ virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_style, RID, uint32_t);
+ GDVIRTUAL1RC(uint32_t, _font_get_style, RID);
+
+ virtual void font_set_name(RID p_font_rid, const String &p_name) override;
+ virtual String font_get_name(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_name, RID, const String &);
+ GDVIRTUAL1RC(String, _font_get_name, RID);
+
+ virtual void font_set_style_name(RID p_font_rid, const String &p_name) override;
+ virtual String font_get_style_name(RID p_font_rid) const override;
+ GDVIRTUAL2(_font_set_style_name, RID, const String &);
+ GDVIRTUAL1RC(String, _font_get_style_name, RID);
+
virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) override;
virtual bool font_is_antialiased(RID p_font_rid) const override;
GDVIRTUAL2(_font_set_antialiased, RID, bool);
@@ -301,6 +316,11 @@ public:
virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) override;
GDVIRTUAL2(_shaped_text_set_bidi_override, RID, const Array &);
+ virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) override;
+ virtual String shaped_text_get_custom_punctuation(RID p_shaped) const override;
+ GDVIRTUAL2(_shaped_text_set_custom_punctuation, RID, String);
+ GDVIRTUAL1RC(String, _shaped_text_get_custom_punctuation, RID);
+
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;
GDVIRTUAL2(_shaped_text_set_orientation, RID, Orientation);
diff --git a/servers/text_server.cpp b/servers/text_server.cpp
index af4718678e..9034239fe0 100644
--- a/servers/text_server.cpp
+++ b/servers/text_server.cpp
@@ -208,6 +208,15 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("font_set_data", "font_rid", "data"), &TextServer::font_set_data);
+ ClassDB::bind_method(D_METHOD("font_set_style", "font_rid", "style"), &TextServer::font_set_style);
+ ClassDB::bind_method(D_METHOD("font_get_style", "font_rid"), &TextServer::font_get_style);
+
+ ClassDB::bind_method(D_METHOD("font_set_name", "font_rid", "name"), &TextServer::font_set_name);
+ ClassDB::bind_method(D_METHOD("font_get_name", "font_rid"), &TextServer::font_get_name);
+
+ ClassDB::bind_method(D_METHOD("font_set_style_name", "font_rid", "name"), &TextServer::font_set_style_name);
+ ClassDB::bind_method(D_METHOD("font_get_style_name", "font_rid"), &TextServer::font_get_style_name);
+
ClassDB::bind_method(D_METHOD("font_set_antialiased", "font_rid", "antialiased"), &TextServer::font_set_antialiased);
ClassDB::bind_method(D_METHOD("font_is_antialiased", "font_rid"), &TextServer::font_is_antialiased);
@@ -338,6 +347,9 @@ void TextServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("shaped_text_set_bidi_override", "shaped", "override"), &TextServer::shaped_text_set_bidi_override);
+ ClassDB::bind_method(D_METHOD("shaped_text_set_custom_punctuation", "shaped", "punct"), &TextServer::shaped_text_set_custom_punctuation);
+ ClassDB::bind_method(D_METHOD("shaped_text_get_custom_punctuation", "shaped"), &TextServer::shaped_text_get_custom_punctuation);
+
ClassDB::bind_method(D_METHOD("shaped_text_set_orientation", "shaped", "orientation"), &TextServer::shaped_text_set_orientation, DEFVAL(ORIENTATION_HORIZONTAL));
ClassDB::bind_method(D_METHOD("shaped_text_get_orientation", "shaped"), &TextServer::shaped_text_get_orientation);
@@ -470,11 +482,16 @@ void TextServer::_bind_methods() {
BIND_ENUM_CONSTANT(CONTOUR_CURVE_TAG_OFF_CONIC);
BIND_ENUM_CONSTANT(CONTOUR_CURVE_TAG_OFF_CUBIC);
- /* Font Spacing*/
+ /* Font Spacing */
BIND_ENUM_CONSTANT(SPACING_GLYPH);
BIND_ENUM_CONSTANT(SPACING_SPACE);
BIND_ENUM_CONSTANT(SPACING_TOP);
BIND_ENUM_CONSTANT(SPACING_BOTTOM);
+
+ /* Font Style */
+ BIND_ENUM_CONSTANT(FONT_BOLD);
+ BIND_ENUM_CONSTANT(FONT_ITALIC);
+ BIND_ENUM_CONSTANT(FONT_FIXED_WIDTH);
}
Vector2 TextServer::get_hex_code_box_size(int p_size, char32_t p_index) const {
diff --git a/servers/text_server.h b/servers/text_server.h
index a5484d8fbd..4f55f881e6 100644
--- a/servers/text_server.h
+++ b/servers/text_server.h
@@ -125,6 +125,12 @@ public:
SPACING_BOTTOM,
};
+ enum FontStyle {
+ FONT_BOLD = 1 << 0,
+ FONT_ITALIC = 1 << 1,
+ FONT_FIXED_WIDTH = 1 << 2,
+ };
+
void _draw_hex_code_box_number(RID p_canvas, int p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const;
protected:
@@ -144,6 +150,7 @@ protected:
int end = 0; // Substring end offset in the parent string.
String text;
+ String custom_punct;
TextServer::Direction direction = DIRECTION_LTR; // Desired text direction.
TextServer::Orientation orientation = ORIENTATION_HORIZONTAL;
@@ -224,6 +231,15 @@ public:
virtual void font_set_data(RID p_font_rid, const PackedByteArray &p_data) = 0;
virtual void font_set_data_ptr(RID p_font_rid, const uint8_t *p_data_ptr, size_t p_data_size) = 0;
+ virtual void font_set_style(RID p_font_rid, uint32_t /*FontStyle*/ p_style) = 0;
+ virtual uint32_t /*FontStyle*/ font_get_style(RID p_font_rid) const = 0;
+
+ virtual void font_set_name(RID p_font_rid, const String &p_name) = 0;
+ virtual String font_get_name(RID p_font_rid) const = 0;
+
+ virtual void font_set_style_name(RID p_font_rid, const String &p_name) = 0;
+ virtual String font_get_style_name(RID p_font_rid) const = 0;
+
virtual void font_set_antialiased(RID p_font_rid, bool p_antialiased) = 0;
virtual bool font_is_antialiased(RID p_font_rid) const = 0;
@@ -354,6 +370,9 @@ public:
virtual void shaped_text_set_bidi_override(RID p_shaped, const Array &p_override) = 0;
+ virtual void shaped_text_set_custom_punctuation(RID p_shaped, const String &p_punct) = 0;
+ virtual String shaped_text_get_custom_punctuation(RID p_shaped) const = 0;
+
virtual void shaped_text_set_orientation(RID p_shaped, Orientation p_orientation = ORIENTATION_HORIZONTAL) = 0;
virtual Orientation shaped_text_get_orientation(RID p_shaped) const = 0;
@@ -535,6 +554,7 @@ VARIANT_ENUM_CAST(TextServer::Hinting);
VARIANT_ENUM_CAST(TextServer::Feature);
VARIANT_ENUM_CAST(TextServer::ContourPointTag);
VARIANT_ENUM_CAST(TextServer::SpacingType);
+VARIANT_ENUM_CAST(TextServer::FontStyle);
GDVIRTUAL_NATIVE_PTR(Glyph);
GDVIRTUAL_NATIVE_PTR(Glyph *);