diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-22 11:31:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-22 11:31:35 +0200 |
commit | 211cb401db71021beef5b475e52fd6ea8a161777 (patch) | |
tree | 40f1e81ee4cbc175834e21b6c12de1b9fb57526e /scene/resources | |
parent | c63d1c3e4a82167d737fef10a275db17918ab685 (diff) | |
parent | 9a36d8f26f0eae36501c1315366e30d3964e0712 (diff) |
Merge pull request #52928 from bruvzg/var_coord_prefill
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/font.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 29bd56eebd..9b403a18f0 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1214,6 +1214,14 @@ void Font::add_data(const Ref<FontData> &p_data) { if (data[data.size() - 1].is_valid()) { data.write[data.size() - 1]->connect(SNAME("changed"), callable_mp(this, &Font::_data_changed), varray(), CONNECT_REFERENCE_COUNTED); + Dictionary data_var_list = p_data->get_supported_variation_list(); + for (int j = 0; j < data_var_list.size(); j++) { + int32_t tag = data_var_list.get_key_at_index(j); + Vector3i value = data_var_list.get_value_at_index(j); + if (!variation_coordinates.has(tag) && !variation_coordinates.has(TS->tag_to_name(tag))) { + variation_coordinates[TS->tag_to_name(tag)] = value.z; + } + } } cache.clear(); @@ -1233,6 +1241,14 @@ void Font::set_data(int p_idx, const Ref<FontData> &p_data) { data.write[p_idx] = p_data; rids.write[p_idx] = RID(); + Dictionary data_var_list = p_data->get_supported_variation_list(); + for (int j = 0; j < data_var_list.size(); j++) { + int32_t tag = data_var_list.get_key_at_index(j); + Vector3i value = data_var_list.get_value_at_index(j); + if (!variation_coordinates.has(tag) && !variation_coordinates.has(TS->tag_to_name(tag))) { + variation_coordinates[TS->tag_to_name(tag)] = value.z; + } + } if (data[p_idx].is_valid()) { data.write[p_idx]->connect(SNAME("changed"), callable_mp(this, &Font::_data_changed), varray(), CONNECT_REFERENCE_COUNTED); |