|
@@ -4019,7 +4019,7 @@ void TextServerAdvanced::full_copy(ShapedTextDataAdvanced *p_shaped) {
|
|
|
ShapedTextDataAdvanced *parent = shaped_owner.get_or_null(p_shaped->parent);
|
|
|
|
|
|
for (const KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : parent->objects) {
|
|
|
- if (E.value.pos >= p_shaped->start && E.value.pos < p_shaped->end) {
|
|
|
+ if (E.value.start >= p_shaped->start && E.value.start < p_shaped->end) {
|
|
|
p_shaped->objects[E.key] = E.value;
|
|
|
}
|
|
|
}
|
|
@@ -4319,7 +4319,8 @@ bool TextServerAdvanced::_shaped_text_add_object(const RID &p_shaped, const Vari
|
|
|
ShapedTextDataAdvanced::EmbeddedObject obj;
|
|
|
obj.inline_align = p_inline_align;
|
|
|
obj.rect.size = p_size;
|
|
|
- obj.pos = span.start;
|
|
|
+ obj.start = span.start;
|
|
|
+ obj.end = span.end;
|
|
|
obj.baseline = p_baseline;
|
|
|
|
|
|
sd->spans.push_back(span);
|
|
@@ -4354,7 +4355,7 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V
|
|
|
Variant key;
|
|
|
if (gl.count == 1) {
|
|
|
for (const KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : sd->objects) {
|
|
|
- if (E.value.pos == gl.start) {
|
|
|
+ if (E.value.start == gl.start) {
|
|
|
key = E.key;
|
|
|
break;
|
|
|
}
|
|
@@ -4405,7 +4406,7 @@ void TextServerAdvanced::_realign(ShapedTextDataAdvanced *p_sd) const {
|
|
|
double full_ascent = p_sd->ascent;
|
|
|
double full_descent = p_sd->descent;
|
|
|
for (KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : p_sd->objects) {
|
|
|
- if ((E.value.pos >= p_sd->start) && (E.value.pos < p_sd->end)) {
|
|
|
+ if ((E.value.start >= p_sd->start) && (E.value.start < p_sd->end)) {
|
|
|
if (p_sd->orientation == ORIENTATION_HORIZONTAL) {
|
|
|
switch (E.value.inline_align & INLINE_ALIGNMENT_TEXT_MASK) {
|
|
|
case INLINE_ALIGNMENT_TO_TOP: {
|
|
@@ -4617,7 +4618,7 @@ bool TextServerAdvanced::_shape_substr(ShapedTextDataAdvanced *p_new_sd, const S
|
|
|
bool find_embedded = false;
|
|
|
if (gl.count == 1) {
|
|
|
for (const KeyValue<Variant, ShapedTextDataAdvanced::EmbeddedObject> &E : p_sd->objects) {
|
|
|
- if (E.value.pos == gl.start) {
|
|
|
+ if (E.value.start == gl.start) {
|
|
|
find_embedded = true;
|
|
|
key = E.key;
|
|
|
p_new_sd->objects[key] = E.value;
|
|
@@ -6457,6 +6458,35 @@ Rect2 TextServerAdvanced::_shaped_text_get_object_rect(const RID &p_shaped, cons
|
|
|
return sd->objects[p_key].rect;
|
|
|
}
|
|
|
|
|
|
+Vector2i TextServerAdvanced::_shaped_text_get_object_range(const RID &p_shaped, const Variant &p_key) const {
|
|
|
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
|
|
|
+ ERR_FAIL_NULL_V(sd, Vector2i());
|
|
|
+
|
|
|
+ MutexLock lock(sd->mutex);
|
|
|
+ ERR_FAIL_COND_V(!sd->objects.has(p_key), Vector2i());
|
|
|
+ return Vector2i(sd->objects[p_key].start, sd->objects[p_key].end);
|
|
|
+}
|
|
|
+
|
|
|
+int64_t TextServerAdvanced::_shaped_text_get_object_glyph(const RID &p_shaped, const Variant &p_key) const {
|
|
|
+ const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
|
|
|
+ ERR_FAIL_NULL_V(sd, -1);
|
|
|
+
|
|
|
+ MutexLock lock(sd->mutex);
|
|
|
+ ERR_FAIL_COND_V(!sd->objects.has(p_key), -1);
|
|
|
+ if (!sd->valid) {
|
|
|
+ const_cast<TextServerAdvanced *>(this)->_shaped_text_shape(p_shaped);
|
|
|
+ }
|
|
|
+ const ShapedTextDataAdvanced::EmbeddedObject &obj = sd->objects[p_key];
|
|
|
+ int sd_size = sd->glyphs.size();
|
|
|
+ const Glyph *sd_glyphs = sd->glyphs.ptr();
|
|
|
+ for (int i = 0; i < sd_size; i++) {
|
|
|
+ if (obj.start == sd_glyphs[i].start) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
Size2 TextServerAdvanced::_shaped_text_get_size(const RID &p_shaped) const {
|
|
|
const ShapedTextDataAdvanced *sd = shaped_owner.get_or_null(p_shaped);
|
|
|
ERR_FAIL_NULL_V(sd, Size2());
|