Forráskód Böngészése

Merge pull request #84287 from bruvzg/rtl_img_resize_and_dropcap_flow

[TextServer] Fix line breaks for dropcap and resizing embedded objects.
Rémi Verschelde 1 éve
szülő
commit
3d0041ff97

+ 2 - 0
modules/text_server_adv/text_server_adv.cpp

@@ -4312,6 +4312,8 @@ bool TextServerAdvanced::_shaped_text_resize_object(const RID &p_shaped, const V
 				sd->width += gl.advance * gl.repeat;
 				sd->width += gl.advance * gl.repeat;
 			}
 			}
 		}
 		}
+		sd->sort_valid = false;
+		sd->glyphs_logical.clear();
 		_realign(sd);
 		_realign(sd);
 	}
 	}
 	return true;
 	return true;

+ 1 - 1
scene/gui/rich_text_label.cpp

@@ -307,7 +307,7 @@ float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font
 				Size2 img_size = img->size;
 				Size2 img_size = img->size;
 				if (img->size_in_percent) {
 				if (img->size_in_percent) {
 					img_size = _get_image_size(img->image, p_width * img->rq_size.width / 100.f, p_width * img->rq_size.height / 100.f, img->region);
 					img_size = _get_image_size(img->image, p_width * img->rq_size.width / 100.f, p_width * img->rq_size.height / 100.f, img->region);
-					l.text_buf->resize_object((uint64_t)it, img_size, img->inline_align, 1);
+					l.text_buf->resize_object((uint64_t)it, img_size, img->inline_align);
 				}
 				}
 			} break;
 			} break;
 			case ITEM_TABLE: {
 			case ITEM_TABLE: {

+ 5 - 6
scene/resources/text_paragraph.cpp

@@ -175,17 +175,16 @@ void TextParagraph::_shape_lines() {
 			for (int i = 0; i < line_breaks.size(); i = i + 2) {
 			for (int i = 0; i < line_breaks.size(); i = i + 2) {
 				RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
 				RID line = TS->shaped_text_substr(rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
 				float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x;
 				float h = (TS->shaped_text_get_orientation(line) == TextServer::ORIENTATION_HORIZONTAL) ? TS->shaped_text_get_size(line).y : TS->shaped_text_get_size(line).x;
-				if (v_offset < h) {
-					TS->free_rid(line);
-					break;
-				}
 				if (!tab_stops.is_empty()) {
 				if (!tab_stops.is_empty()) {
 					TS->shaped_text_tab_align(line, tab_stops);
 					TS->shaped_text_tab_align(line, tab_stops);
 				}
 				}
-				dropcap_lines++;
-				v_offset -= h;
 				start = line_breaks[i + 1];
 				start = line_breaks[i + 1];
 				lines_rid.push_back(line);
 				lines_rid.push_back(line);
+				if (v_offset < h) {
+					break;
+				}
+				dropcap_lines++;
+				v_offset -= h;
 			}
 			}
 		}
 		}
 		// Use fixed for the rest of lines.
 		// Use fixed for the rest of lines.