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

82 add unicode layer name support #93

Merged
merged 8 commits into from
Jul 11, 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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ target_include_directories(doctest INTERFACE thirdparty/doctest/doctest)

# Add simdutf for UTF conversion operations
set (SIMDUTF_TESTS OFF)
set (SIMDUTF_TOOLS OFF)
set (SIMDUTF_ICONV OFF)
add_subdirectory (thirdparty/simdutf)

# Add span from tcb for compatibility with older compilers for python bindings
Expand Down
14 changes: 2 additions & 12 deletions PhotoshopAPI/src/Core/Struct/PascalString.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,22 +338,12 @@ inline static std::string convertStrToUTF8(EncodingType encoding, const std::str
}


/// Convert a utf-8 encoded string to another encoding. For the moment we simply map the ascii
/// characters and ignore any special character
/// Convert a utf-8 encoded string to another encoding. For the moment we simply parse the data through as is
// ---------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------
inline static std::string ConvertUTF8ToStr(EncodingType encoding, const std::string str)
{
PROFILE_FUNCTION();
std::string res = "";
for (const auto& character : str)
{
if (character < 0x80)
{
res += character;
}
}
return res;
return str;
}


Expand Down
Binary file modified PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psb
Binary file not shown.
Binary file modified PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psd
Binary file not shown.
28 changes: 24 additions & 4 deletions PhotoshopTest/src/TestUnicodeLayerNames/TestUnicodeLayerNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ TEST_CASE("Read Unicode layer name from psd file")

LayeredFile<bpp8_t> layeredFile = LayeredFile<bpp8_t>::read(psd_path);

// Find the two layers by their names and check if the result is not null
// Find the three layers by their names and check if the result is not null
SUBCASE("Find chinese simplified layer")
{
auto ptr = layeredFile.findLayer("Chinese_Simplified/请问可以修改psd 的画板尺寸吗");
CHECK(ptr);
}
SUBCASE("Find overflow layer")
{
auto ptr = layeredFile.findLayer("äüöUnicodeNameOverflowPascalString--------------------------------------------------------------------------------------------------------------------");
Expand All @@ -44,7 +49,12 @@ TEST_CASE("Read Unicode layer name from psb file")

LayeredFile<bpp8_t> layeredFile = LayeredFile<bpp8_t>::read(psb_path);

// Find the two layers by their names and check if the result is not null
// Find the three layers by their names and check if the result is not null
SUBCASE("Find chinese simplified layer")
{
auto ptr = layeredFile.findLayer("Chinese_Simplified/请问可以修改psd 的画板尺寸吗");
CHECK(ptr);
}
SUBCASE("Find overflow layer")
{
auto ptr = layeredFile.findLayer("äüöUnicodeNameOverflowPascalString--------------------------------------------------------------------------------------------------------------------");
Expand Down Expand Up @@ -74,7 +84,12 @@ TEST_CASE("Read write unicode layer name from psd file")
LayeredFile<bpp8_t> layeredFile = LayeredFile<bpp8_t>::read(psd_path);


// Find the two layers by their names and check if the result is not null
// Find the three layers by their names and check if the result is not null
SUBCASE("Find chinese simplified layer")
{
auto ptr = layeredFile.findLayer("Chinese_Simplified/请问可以修改psd 的画板尺寸吗");
CHECK(ptr);
}
SUBCASE("Find overflow layer")
{
auto ptr = layeredFile.findLayer("äüöUnicodeNameOverflowPascalString--------------------------------------------------------------------------------------------------------------------");
Expand Down Expand Up @@ -104,7 +119,12 @@ TEST_CASE("Read write unicode layer name from psb file")
LayeredFile<bpp8_t> layeredFile = LayeredFile<bpp8_t>::read(psb_path);


// Find the two layers by their names and check if the result is not null
// Find the three layers by their names and check if the result is not null
SUBCASE("Find chinese simplified layer")
{
auto ptr = layeredFile.findLayer("Chinese_Simplified/请问可以修改psd 的画板尺寸吗");
CHECK(ptr);
}
SUBCASE("Find overflow layer")
{
auto ptr = layeredFile.findLayer("äüöUnicodeNameOverflowPascalString--------------------------------------------------------------------------------------------------------------------");
Expand Down
3 changes: 3 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ project(PhotoshopAPIPython)

file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "src/*.cpp")

# Compile simdutf with position independent code as it otherwise wont compile on gcc ubuntu
set_property(TARGET simdutf PROPERTY POSITION_INDEPENDENT_CODE ON)

pybind11_add_module(psapi src/main.cpp)
target_link_libraries(psapi PUBLIC PhotoshopAPI)
Loading