From 88f69fb2a60a02b11c4a53b2bef6accd61190518 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Fri, 18 Apr 2025 14:33:10 +0200 Subject: [PATCH] [godot] Fix handling of CJK in names, see #2788 --- .../spine_godot/SpineSkeletonDataResource.cpp | 28 +++++++++++-------- .../SpineSkeletonAnimationComponent.cpp | 2 +- .../SpinePlugin/Private/SpineWidget.cpp | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp index d65575a4f..a36623961 100644 --- a/spine-godot/spine_godot/SpineSkeletonDataResource.cpp +++ b/spine-godot/spine_godot/SpineSkeletonDataResource.cpp @@ -381,11 +381,9 @@ SpineSkeletonDataResource::get_skeleton_file_res() { } #ifdef SPINE_GODOT_EXTENSION -void SpineSkeletonDataResource::get_animation_names( - PackedStringArray &animation_names) const { +void SpineSkeletonDataResource::get_animation_names(PackedStringArray &animation_names) const { #else -void SpineSkeletonDataResource::get_animation_names( - Vector &animation_names) const { +void SpineSkeletonDataResource::get_animation_names(Vector &animation_names) const { #endif animation_names.clear(); if (!is_skeleton_data_loaded()) @@ -393,16 +391,16 @@ void SpineSkeletonDataResource::get_animation_names( auto animations = skeleton_data->getAnimations(); for (size_t i = 0; i < animations.size(); ++i) { auto animation = animations[i]; - animation_names.push_back(animation->getName().buffer()); + String name; + name.parse_utf8(animation->getName().buffer()); + animation_names.push_back(name); } } #ifdef SPINE_GODOT_EXTENSION -void SpineSkeletonDataResource::get_skin_names( - PackedStringArray &skin_names) const { +void SpineSkeletonDataResource::get_skin_names(PackedStringArray &skin_names) const { #else -void SpineSkeletonDataResource::get_skin_names( - Vector &skin_names) const { +void SpineSkeletonDataResource::get_skin_names(Vector &skin_names) const { #endif skin_names.clear(); if (!is_skeleton_data_loaded()) @@ -410,7 +408,9 @@ void SpineSkeletonDataResource::get_skin_names( auto skins = skeleton_data->getSkins(); for (size_t i = 0; i < skins.size(); ++i) { auto skin = skins[i]; - skin_names.push_back(skin->getName().buffer()); + String name; + name.parse_utf8(skin->getName().buffer()); + skin_names.push_back(name); } } @@ -425,7 +425,9 @@ void SpineSkeletonDataResource::get_slot_names(Vector &slot_names) { auto slots = skeleton_data->getSlots(); for (size_t i = 0; i < slots.size(); ++i) { auto slot = slots[i]; - slot_names.push_back(slot->getName().buffer()); + String name; + name.parse_utf8(slot->getName().buffer()); + slot_names.push_back(name); } } @@ -440,7 +442,9 @@ void SpineSkeletonDataResource::get_bone_names(Vector &bone_names) { auto bones = skeleton_data->getBones(); for (size_t i = 0; i < bones.size(); ++i) { auto bone = bones[i]; - bone_names.push_back(bone->getName().buffer()); + String name; + name.parse_utf8(bone->getName().buffer()); + bone_names.push_back(name); } } diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp index ee868939a..f41c8d5e5 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineSkeletonAnimationComponent.cpp @@ -81,7 +81,7 @@ USpineSkeletonAnimationComponent::USpineSkeletonAnimationComponent() { void USpineSkeletonAnimationComponent::BeginPlay() { Super::BeginPlay(); - for (UTrackEntry* entry : trackEntries) { + for (UTrackEntry *entry : trackEntries) { if (entry && entry->GetTrackEntry()) { entry->GetTrackEntry()->setRendererObject(nullptr); } diff --git a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp index b1c21369b..82e694ba2 100644 --- a/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp +++ b/spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private/SpineWidget.cpp @@ -108,7 +108,7 @@ void USpineWidget::SynchronizeProperties() { } else { slateWidget->SetData(nullptr); } - for (UTrackEntry* entry : trackEntries) { + for (UTrackEntry *entry : trackEntries) { if (entry && entry->GetTrackEntry()) { entry->GetTrackEntry()->setRendererObject(nullptr); }