Merge pull request #77655 from bitsawer/fix_strange_fragments

Fix suspicious code related to text rendering
This commit is contained in:
Yuri Sizov 2023-05-30 16:03:44 +02:00 committed by GitHub
commit c0ee762f46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 12 deletions

View file

@ -858,7 +858,7 @@ bool DynamicFontImportSettings::_char_update(int32_t p_char) {
if (import_variation_data->selected_chars.has(p_char)) {
import_variation_data->selected_chars.erase(p_char);
return false;
} else if (font_main.is_valid() && font_main.is_valid() && import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, p_char))) {
} else if (font_main.is_valid() && import_variation_data->selected_glyphs.has(font_main->get_glyph_index(16, p_char))) {
import_variation_data->selected_glyphs.erase(font_main->get_glyph_index(16, p_char));
return false;
} else {
@ -1083,7 +1083,7 @@ void DynamicFontImportSettings::open_settings(const String &p_path) {
font_preview_label->set_text(sample);
Ref<Font> bold_font = get_theme_font(SNAME("bold"), SNAME("EditorFonts"));
if (bold_font.is_valid() && bold_font.is_valid()) {
if (bold_font.is_valid()) {
font_name_label->add_theme_font_override("bold_font", bold_font);
}
font_name_label->set_text(font_name);

View file

@ -525,11 +525,7 @@ Size2 TextParagraph::get_non_wrapped_size() const {
_THREAD_SAFE_METHOD_
const_cast<TextParagraph *>(this)->_shape_lines();
if (TS->shaped_text_get_orientation(rid) == TextServer::ORIENTATION_HORIZONTAL) {
return Size2(TS->shaped_text_get_size(rid).x, TS->shaped_text_get_size(rid).y);
} else {
return Size2(TS->shaped_text_get_size(rid).x, TS->shaped_text_get_size(rid).y);
}
return TS->shaped_text_get_size(rid);
}
Size2 TextParagraph::get_size() const {
@ -675,11 +671,7 @@ Size2 TextParagraph::get_line_size(int p_line) const {
const_cast<TextParagraph *>(this)->_shape_lines();
ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)lines_rid.size(), Size2());
if (TS->shaped_text_get_orientation(lines_rid[p_line]) == TextServer::ORIENTATION_HORIZONTAL) {
return Size2(TS->shaped_text_get_size(lines_rid[p_line]).x, TS->shaped_text_get_size(lines_rid[p_line]).y);
} else {
return Size2(TS->shaped_text_get_size(lines_rid[p_line]).x, TS->shaped_text_get_size(lines_rid[p_line]).y);
}
return TS->shaped_text_get_size(lines_rid[p_line]);
}
Vector2i TextParagraph::get_line_range(int p_line) const {