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

[TextServer] Pass Dictionary properties by value and check property values instead of references. #81406

Merged
merged 1 commit into from
Sep 8, 2023
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
6 changes: 4 additions & 2 deletions modules/text_server_adv/text_server_adv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2383,8 +2383,10 @@ void TextServerAdvanced::_font_set_variation_coordinates(const RID &p_font_rid,
ERR_FAIL_COND(!fd);

MutexLock lock(fd->mutex);
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates;
if (!fd->variation_coordinates.recursive_equal(p_variation_coordinates, 1)) {
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates.duplicate();
}
}

Dictionary TextServerAdvanced::_font_get_variation_coordinates(const RID &p_font_rid) const {
Expand Down
6 changes: 4 additions & 2 deletions modules/text_server_fb/text_server_fb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1376,8 +1376,10 @@ void TextServerFallback::_font_set_variation_coordinates(const RID &p_font_rid,
ERR_FAIL_COND(!fd);

MutexLock lock(fd->mutex);
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates;
if (!fd->variation_coordinates.recursive_equal(p_variation_coordinates, 1)) {
_font_clear_cache(fd);
fd->variation_coordinates = p_variation_coordinates.duplicate();
}
}

Dictionary TextServerFallback::_font_get_variation_coordinates(const RID &p_font_rid) const {
Expand Down
16 changes: 10 additions & 6 deletions scene/resources/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2833,12 +2833,14 @@ Ref<Font> FontVariation::_get_base_font_or_default() const {
}

void FontVariation::set_variation_opentype(const Dictionary &p_coords) {
variation.opentype = p_coords;
_invalidate_rids();
if (!variation.opentype.recursive_equal(p_coords, 1)) {
variation.opentype = p_coords.duplicate();
_invalidate_rids();
}
}

Dictionary FontVariation::get_variation_opentype() const {
return variation.opentype;
return variation.opentype.duplicate();
}

void FontVariation::set_variation_embolden(float p_strength) {
Expand Down Expand Up @@ -2875,12 +2877,14 @@ int FontVariation::get_variation_face_index() const {
}

void FontVariation::set_opentype_features(const Dictionary &p_features) {
opentype_features = p_features;
_invalidate_rids();
if (!opentype_features.recursive_equal(p_features, 1)) {
opentype_features = p_features.duplicate();
_invalidate_rids();
}
}

Dictionary FontVariation::get_opentype_features() const {
return opentype_features;
return opentype_features.duplicate();
}

void FontVariation::set_spacing(TextServer::SpacingType p_spacing, int p_value) {
Expand Down