Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Update font preview directly instead of invalidating property list. #93968

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions editor/plugins/font_config_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,12 @@ void FontPreview::_notification(int p_what) {
font->draw_string(get_canvas_item(), Point2(0, font->get_height(font_size) + 2 * EDSCALE), TTR("Unable to preview font"), HORIZONTAL_ALIGNMENT_CENTER, get_size().x, font_size, text_color);
}
} break;

case NOTIFICATION_EXIT_TREE: {
if (prev_font.is_valid()) {
prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
}
} break;
}
}

Expand All @@ -945,7 +951,17 @@ Size2 FontPreview::get_minimum_size() const {
}

void FontPreview::set_data(const Ref<Font> &p_f) {
if (prev_font.is_valid()) {
prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
}
prev_font = p_f;
if (prev_font.is_valid()) {
prev_font->connect_changed(callable_mp(this, &FontPreview::_preview_changed));
}
queue_redraw();
}

void FontPreview::_preview_changed() {
queue_redraw();
}

Expand Down
2 changes: 2 additions & 0 deletions editor/plugins/font_config_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class FontPreview : public Control {

Ref<Font> prev_font;

void _preview_changed();

public:
virtual Size2 get_minimum_size() const override;

Expand Down
1 change: 0 additions & 1 deletion scene/resources/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,6 @@ void SystemFont::_update_base_font() {
}

_invalidate_rids();
notify_property_list_changed();
}

void SystemFont::reset_state() {
Expand Down
Loading