mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
[RTL] Use separate paragraph copy for the partially visible paragraphs.
This commit is contained in:
parent
019889d1da
commit
0d19e18b00
19 changed files with 346 additions and 51 deletions
|
|
@ -3285,7 +3285,7 @@ void TextServerFallback::full_copy(ShapedTextDataFallback *p_shaped) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int i = p_shaped->first_span; i <= p_shaped->last_span; i++) {
|
||||
for (int i = MAX(0, p_shaped->first_span); i <= MIN(p_shaped->last_span, parent->spans.size() - 1); i++) {
|
||||
ShapedTextDataFallback::Span span = parent->spans[i];
|
||||
span.start = MAX(p_shaped->start, span.start);
|
||||
span.end = MIN(p_shaped->end, span.end);
|
||||
|
|
@ -3324,6 +3324,39 @@ void TextServerFallback::_shaped_text_clear(const RID &p_shaped) {
|
|||
invalidate(sd);
|
||||
}
|
||||
|
||||
RID TextServerFallback::_shaped_text_duplicate(const RID &p_shaped) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, RID());
|
||||
|
||||
MutexLock lock(sd->mutex);
|
||||
|
||||
ShapedTextDataFallback *new_sd = memnew(ShapedTextDataFallback);
|
||||
new_sd->parent = p_shaped;
|
||||
new_sd->start = sd->start;
|
||||
new_sd->end = sd->end;
|
||||
new_sd->text = sd->text;
|
||||
new_sd->orientation = sd->orientation;
|
||||
new_sd->direction = sd->direction;
|
||||
new_sd->custom_punct = sd->custom_punct;
|
||||
new_sd->para_direction = sd->para_direction;
|
||||
new_sd->line_breaks_valid = sd->line_breaks_valid;
|
||||
new_sd->justification_ops_valid = sd->justification_ops_valid;
|
||||
new_sd->sort_valid = false;
|
||||
new_sd->upos = sd->upos;
|
||||
new_sd->uthk = sd->uthk;
|
||||
new_sd->runs.clear();
|
||||
new_sd->runs_dirty = true;
|
||||
for (int i = 0; i < TextServer::SPACING_MAX; i++) {
|
||||
new_sd->extra_spacing[i] = sd->extra_spacing[i];
|
||||
}
|
||||
full_copy(new_sd);
|
||||
new_sd->valid.clear();
|
||||
|
||||
return shaped_owner.make_rid(new_sd);
|
||||
}
|
||||
|
||||
void TextServerFallback::_shaped_text_set_direction(const RID &p_shaped, TextServer::Direction p_direction) {
|
||||
ERR_FAIL_COND_MSG(p_direction == DIRECTION_INHERITED, "Invalid text direction.");
|
||||
if (p_direction == DIRECTION_RTL) {
|
||||
|
|
@ -3832,6 +3865,14 @@ String TextServerFallback::_shaped_get_text(const RID &p_shaped) const {
|
|||
return sd->text;
|
||||
}
|
||||
|
||||
bool TextServerFallback::_shaped_text_has_object(const RID &p_shaped, const Variant &p_key) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, false);
|
||||
|
||||
MutexLock lock(sd->mutex);
|
||||
return sd->objects.has(p_key);
|
||||
}
|
||||
|
||||
bool TextServerFallback::_shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, double p_baseline) {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, false);
|
||||
|
|
|
|||
|
|
@ -811,6 +811,7 @@ public:
|
|||
MODBIND2R(RID, create_shaped_text, Direction, Orientation);
|
||||
|
||||
MODBIND1(shaped_text_clear, const RID &);
|
||||
MODBIND1R(RID, shaped_text_duplicate, const RID &);
|
||||
|
||||
MODBIND2(shaped_text_set_direction, const RID &, Direction);
|
||||
MODBIND1RC(Direction, shaped_text_get_direction, const RID &);
|
||||
|
|
@ -839,6 +840,7 @@ public:
|
|||
MODBIND7R(bool, shaped_text_add_string, const RID &, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);
|
||||
MODBIND6R(bool, shaped_text_add_object, const RID &, const Variant &, const Size2 &, InlineAlignment, int64_t, double);
|
||||
MODBIND5R(bool, shaped_text_resize_object, const RID &, const Variant &, const Size2 &, InlineAlignment, double);
|
||||
MODBIND2RC(bool, shaped_text_has_object, const RID &, const Variant &);
|
||||
MODBIND1RC(String, shaped_get_text, const RID &);
|
||||
|
||||
MODBIND1RC(int64_t, shaped_get_span_count, const RID &);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue