diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs | 10 | ||||
| -rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs | 11 | ||||
| -rw-r--r-- | modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs | 12 | ||||
| -rw-r--r-- | modules/svg/image_loader_svg.cpp | 4 | ||||
| -rw-r--r-- | modules/text_server_adv/thorvg_svg_in_ot.cpp | 12 | ||||
| -rw-r--r-- | modules/text_server_adv/thorvg_svg_in_ot.h | 2 | ||||
| -rw-r--r-- | modules/text_server_fb/thorvg_svg_in_ot.cpp | 12 | ||||
| -rw-r--r-- | modules/text_server_fb/thorvg_svg_in_ot.h | 2 |
8 files changed, 33 insertions, 32 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs index e849939ebb..0dac8205b6 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector2I.cs @@ -504,15 +504,15 @@ namespace Godot } /// <summary> - /// Converts a <see cref="Vector2"/> to a <see cref="Vector2I"/>. + /// Converts a <see cref="Vector2"/> to a <see cref="Vector2I"/> by truncating + /// components' fractional parts (rounding towards zero). For a different + /// behavior consider passing the result of <see cref="Vector2.Ceil"/>, + /// <see cref="Vector2.Floor"/> or <see cref="Vector2.Round"/> to this conversion operator instead. /// </summary> /// <param name="value">The vector to convert.</param> public static explicit operator Vector2I(Vector2 value) { - return new Vector2I( - Mathf.RoundToInt(value.X), - Mathf.RoundToInt(value.Y) - ); + return new Vector2I((int)value.X, (int)value.Y); } /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs index fe899527ef..a2927533f8 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector3I.cs @@ -559,16 +559,15 @@ namespace Godot } /// <summary> - /// Converts a <see cref="Vector3"/> to a <see cref="Vector3I"/>. + /// Converts a <see cref="Vector3"/> to a <see cref="Vector3I"/> by truncating + /// components' fractional parts (rounding towards zero). For a different + /// behavior consider passing the result of <see cref="Vector3.Ceil"/>, + /// <see cref="Vector3.Floor"/> or <see cref="Vector3.Round"/> to this conversion operator instead. /// </summary> /// <param name="value">The vector to convert.</param> public static explicit operator Vector3I(Vector3 value) { - return new Vector3I( - Mathf.RoundToInt(value.X), - Mathf.RoundToInt(value.Y), - Mathf.RoundToInt(value.Z) - ); + return new Vector3I((int)value.X, (int)value.Y, (int)value.Z); } /// <summary> diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs index f065327066..bb552b939d 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Vector4I.cs @@ -580,17 +580,15 @@ namespace Godot } /// <summary> - /// Converts a <see cref="Vector4"/> to a <see cref="Vector4I"/>. + /// Converts a <see cref="Vector4"/> to a <see cref="Vector4I"/> by truncating + /// components' fractional parts (rounding towards zero). For a different + /// behavior consider passing the result of <see cref="Vector4.Ceil"/>, + /// <see cref="Vector4.Floor"/> or <see cref="Vector4.Round"/> to this conversion operator instead. /// </summary> /// <param name="value">The vector to convert.</param> public static explicit operator Vector4I(Vector4 value) { - return new Vector4I( - Mathf.RoundToInt(value.X), - Mathf.RoundToInt(value.Y), - Mathf.RoundToInt(value.Z), - Mathf.RoundToInt(value.W) - ); + return new Vector4I((int)value.X, (int)value.Y, (int)value.Z, (int)value.W); } /// <summary> diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index e239b33374..ad7feeda49 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -79,8 +79,8 @@ Error ImageLoaderSVG::create_image_from_utf8_buffer(Ref<Image> p_image, const Pa float fw, fh; picture->size(&fw, &fh); - uint32_t width = round(fw * p_scale); - uint32_t height = round(fh * p_scale); + uint32_t width = MAX(1, round(fw * p_scale)); + uint32_t height = MAX(1, round(fh * p_scale)); const uint32_t max_dimension = 16384; if (width > max_dimension || height > max_dimension) { diff --git a/modules/text_server_adv/thorvg_svg_in_ot.cpp b/modules/text_server_adv/thorvg_svg_in_ot.cpp index 1406e3aaa0..4fd4c7c1f6 100644 --- a/modules/text_server_adv/thorvg_svg_in_ot.cpp +++ b/modules/text_server_adv/thorvg_svg_in_ot.cpp @@ -126,10 +126,11 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin xml_body += vformat("</%s>", parser->get_node_name()); } } - String temp_xml = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 0 0\">" + xml_body; + String temp_xml_str = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 0 0\">" + xml_body; + CharString temp_xml = temp_xml_str.utf8(); std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen(); - tvg::Result result = picture->load(temp_xml.utf8().get_data(), temp_xml.utf8().length(), "svg+xml", false); + tvg::Result result = picture->load(temp_xml.get_data(), temp_xml.length(), "svg+xml", false); if (result != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (bounds detection)."); } @@ -146,10 +147,11 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin new_h = (new_w / aspect); } - gl_state.xml_code = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + rtos(min_x) + " " + rtos(min_y) + " " + rtos(new_w) + " " + rtos(new_h) + "\">" + xml_body; + String xml_code_str = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + rtos(min_x) + " " + rtos(min_y) + " " + rtos(new_w) + " " + rtos(new_h) + "\">" + xml_body; + gl_state.xml_code = xml_code_str.utf8(); picture = tvg::Picture::gen(); - result = picture->load(gl_state.xml_code.utf8().get_data(), gl_state.xml_code.utf8().length(), "svg+xml", false); + result = picture->load(gl_state.xml_code.get_data(), gl_state.xml_code.length(), "svg+xml", false); if (result != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (glyph metrics)."); } @@ -237,7 +239,7 @@ FT_Error tvg_svg_in_ot_render(FT_GlyphSlot p_slot, FT_Pointer *p_state) { ERR_FAIL_COND_V_MSG(!gl_state.ready, FT_Err_Invalid_SVG_Document, "SVG glyph not ready."); std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen(); - tvg::Result res = picture->load(gl_state.xml_code.utf8().get_data(), gl_state.xml_code.utf8().length(), "svg+xml", false); + tvg::Result res = picture->load(gl_state.xml_code.get_data(), gl_state.xml_code.length(), "svg+xml", false); if (res != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (glyph rendering)."); } diff --git a/modules/text_server_adv/thorvg_svg_in_ot.h b/modules/text_server_adv/thorvg_svg_in_ot.h index 4035a984b6..e9bf05c2c3 100644 --- a/modules/text_server_adv/thorvg_svg_in_ot.h +++ b/modules/text_server_adv/thorvg_svg_in_ot.h @@ -65,7 +65,7 @@ struct GL_State { float y = 0; float w = 0; float h = 0; - String xml_code; + CharString xml_code; tvg::Matrix m; }; diff --git a/modules/text_server_fb/thorvg_svg_in_ot.cpp b/modules/text_server_fb/thorvg_svg_in_ot.cpp index 1406e3aaa0..4fd4c7c1f6 100644 --- a/modules/text_server_fb/thorvg_svg_in_ot.cpp +++ b/modules/text_server_fb/thorvg_svg_in_ot.cpp @@ -126,10 +126,11 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin xml_body += vformat("</%s>", parser->get_node_name()); } } - String temp_xml = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 0 0\">" + xml_body; + String temp_xml_str = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 0 0\">" + xml_body; + CharString temp_xml = temp_xml_str.utf8(); std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen(); - tvg::Result result = picture->load(temp_xml.utf8().get_data(), temp_xml.utf8().length(), "svg+xml", false); + tvg::Result result = picture->load(temp_xml.get_data(), temp_xml.length(), "svg+xml", false); if (result != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (bounds detection)."); } @@ -146,10 +147,11 @@ FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Poin new_h = (new_w / aspect); } - gl_state.xml_code = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + rtos(min_x) + " " + rtos(min_y) + " " + rtos(new_w) + " " + rtos(new_h) + "\">" + xml_body; + String xml_code_str = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"" + rtos(min_x) + " " + rtos(min_y) + " " + rtos(new_w) + " " + rtos(new_h) + "\">" + xml_body; + gl_state.xml_code = xml_code_str.utf8(); picture = tvg::Picture::gen(); - result = picture->load(gl_state.xml_code.utf8().get_data(), gl_state.xml_code.utf8().length(), "svg+xml", false); + result = picture->load(gl_state.xml_code.get_data(), gl_state.xml_code.length(), "svg+xml", false); if (result != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (glyph metrics)."); } @@ -237,7 +239,7 @@ FT_Error tvg_svg_in_ot_render(FT_GlyphSlot p_slot, FT_Pointer *p_state) { ERR_FAIL_COND_V_MSG(!gl_state.ready, FT_Err_Invalid_SVG_Document, "SVG glyph not ready."); std::unique_ptr<tvg::Picture> picture = tvg::Picture::gen(); - tvg::Result res = picture->load(gl_state.xml_code.utf8().get_data(), gl_state.xml_code.utf8().length(), "svg+xml", false); + tvg::Result res = picture->load(gl_state.xml_code.get_data(), gl_state.xml_code.length(), "svg+xml", false); if (res != tvg::Result::Success) { ERR_FAIL_V_MSG(FT_Err_Invalid_SVG_Document, "Failed to load SVG document (glyph rendering)."); } diff --git a/modules/text_server_fb/thorvg_svg_in_ot.h b/modules/text_server_fb/thorvg_svg_in_ot.h index 4035a984b6..e9bf05c2c3 100644 --- a/modules/text_server_fb/thorvg_svg_in_ot.h +++ b/modules/text_server_fb/thorvg_svg_in_ot.h @@ -65,7 +65,7 @@ struct GL_State { float y = 0; float w = 0; float h = 0; - String xml_code; + CharString xml_code; tvg::Matrix m; }; |