summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-05-22 18:01:27 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-05-22 18:04:32 +0300
commit1f066837e4d54125aa3909538c606a0889a847d1 (patch)
tree033dc9b3539f5c9277aa1a4a6e1f12100954484d
parent7b8c574401b3b3a211fd478eaa3fbb99b6dbb798 (diff)
[TextMesh] Fix cubic cubic Bezier arc processing.
-rw-r--r--scene/resources/primitive_meshes.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 4d83f8772e..fb9b2823b4 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -2229,17 +2229,27 @@ void TextMesh::_generate_glyph_mesh_data(uint32_t p_hash, const Glyph &p_gl) con
}
} else if (points[j].z == TextServer::CONTOUR_CURVE_TAG_OFF_CUBIC) {
// Cubic Bezier arc.
+ int32_t cur = j;
int32_t next1 = (j == end) ? start : (j + 1);
int32_t next2 = (next1 == end) ? start : (next1 + 1);
int32_t prev = (j == start) ? end : (j - 1);
// There must be exactly two OFF points and two ON points for each cubic arc.
+ if (points[prev].z != TextServer::CONTOUR_CURVE_TAG_ON) {
+ cur = (cur == 0) ? end : cur - 1;
+ next1 = (next1 == 0) ? end : next1 - 1;
+ next2 = (next2 == 0) ? end : next2 - 1;
+ prev = (prev == 0) ? end : prev - 1;
+ } else {
+ j++;
+ }
ERR_FAIL_COND_MSG(points[prev].z != TextServer::CONTOUR_CURVE_TAG_ON, vformat("Invalid cubic arc point sequence at %d:%d", i, prev));
+ ERR_FAIL_COND_MSG(points[cur].z != TextServer::CONTOUR_CURVE_TAG_OFF_CUBIC, vformat("Invalid cubic arc point sequence at %d:%d", i, cur));
ERR_FAIL_COND_MSG(points[next1].z != TextServer::CONTOUR_CURVE_TAG_OFF_CUBIC, vformat("Invalid cubic arc point sequence at %d:%d", i, next1));
ERR_FAIL_COND_MSG(points[next2].z != TextServer::CONTOUR_CURVE_TAG_ON, vformat("Invalid cubic arc point sequence at %d:%d", i, next2));
Vector2 p0 = Vector2(points[prev].x, points[prev].y);
- Vector2 p1 = Vector2(points[j].x, points[j].y);
+ Vector2 p1 = Vector2(points[cur].x, points[cur].y);
Vector2 p2 = Vector2(points[next1].x, points[next1].y);
Vector2 p3 = Vector2(points[next2].x, points[next2].y);
@@ -2257,7 +2267,6 @@ void TextMesh::_generate_glyph_mesh_data(uint32_t p_hash, const Glyph &p_gl) con
polygon.push_back(ContourPoint(p, false));
t += step;
}
- i++;
} else {
ERR_FAIL_MSG(vformat("Unknown point tag at %d:%d", i, j));
}