From 268381459e01c15606988087a8ca6e8d2d39cd67 Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:18:44 +0200 Subject: [PATCH 1/7] bump head of simdutf to v5.3.0 --- thirdparty/simdutf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty/simdutf b/thirdparty/simdutf index 1c3c8096..c00580bd 160000 --- a/thirdparty/simdutf +++ b/thirdparty/simdutf @@ -1 +1 @@ -Subproject commit 1c3c809681c86d6d59cb05d0fc61400484624b6e +Subproject commit c00580bde0bcc5a8299281910f42f83b7c8ff64c From 39a9fd321c42e14cfe560f64d90718f3c829d2bf Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:19:57 +0200 Subject: [PATCH 2/7] run CI on push to 82-add-unicode-layer-name-support --- .github/workflows/build-wheels.yml | 1 + .github/workflows/cmake-build.yml | 1 + .github/workflows/cmake-test.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index ed418bc0..1a17c405 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -6,6 +6,7 @@ on: push: branches: - dev + - 82-add-unicode-layer-name-support pull_request: branches: - master diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 048d116c..620391dd 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -5,6 +5,7 @@ on: push: branches: - dev + - 82-add-unicode-layer-name-support pull_request: branches: - master diff --git a/.github/workflows/cmake-test.yml b/.github/workflows/cmake-test.yml index ca30cc1e..e2916e0f 100644 --- a/.github/workflows/cmake-test.yml +++ b/.github/workflows/cmake-test.yml @@ -5,6 +5,7 @@ on: push: branches: - dev + - 82-add-unicode-layer-name-support pull_request: branches: - master From ec4f0cb325b0ff867e0113b233e1732f97038bbf Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:28:56 +0200 Subject: [PATCH 3/7] Dont build simdutf tools as part of our cmake build process --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e80cd52f..a079f966 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 From ad9abbc0bdc6cac23e20bf99fd007fde57593404 Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:34:10 +0200 Subject: [PATCH 4/7] fix bug where we compare char instead of unsigned char --- PhotoshopAPI/src/Core/Struct/PascalString.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PhotoshopAPI/src/Core/Struct/PascalString.h b/PhotoshopAPI/src/Core/Struct/PascalString.h index 50ebb5e8..86fc68fc 100644 --- a/PhotoshopAPI/src/Core/Struct/PascalString.h +++ b/PhotoshopAPI/src/Core/Struct/PascalString.h @@ -348,7 +348,7 @@ inline static std::string ConvertUTF8ToStr(EncodingType encoding, const std::str std::string res = ""; for (const auto& character : str) { - if (character < 0x80) + if (static_cast(character) < 0x80) { res += character; } From 58f8491b2abf0264ee61ebdc16ad2b3d75c0945e Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:38:23 +0200 Subject: [PATCH 5/7] compile simdutf with fPIC in our python bindings --- python/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 60b4d7eb..f8666f96 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,7 +2,11 @@ # -------------------------------------------------------------------------- project(PhotoshopAPIPython) -file(GLOB_RECURSE MY_SOURCES CONFIGURE_DEPENDS "src/*.cpp") +file(GLOB_RE +CURSE 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) \ No newline at end of file From 5f59c8ba64666125b70dc118aa698b60f81fef3a Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 17:51:11 +0200 Subject: [PATCH 6/7] modify UTF8toStr function to simply parse through the data as is --- PhotoshopAPI/src/Core/Struct/PascalString.h | 14 ++------------ python/CMakeLists.txt | 3 +-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/PhotoshopAPI/src/Core/Struct/PascalString.h b/PhotoshopAPI/src/Core/Struct/PascalString.h index 86fc68fc..97c7401d 100644 --- a/PhotoshopAPI/src/Core/Struct/PascalString.h +++ b/PhotoshopAPI/src/Core/Struct/PascalString.h @@ -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 (static_cast(character) < 0x80) - { - res += character; - } - } - return res; + return str; } diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index f8666f96..de6ef942 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -2,8 +2,7 @@ # -------------------------------------------------------------------------- project(PhotoshopAPIPython) -file(GLOB_RE -CURSE MY_SOURCES CONFIGURE_DEPENDS "src/*.cpp") +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) From 9551e5b246db507f7c7bddaf8297f871d5a36564 Mon Sep 17 00:00:00 2001 From: emild Date: Thu, 11 Jul 2024 18:03:52 +0200 Subject: [PATCH 7/7] add chinese simplified layers to properly test unicode support as well as removing ci runs on branch --- .github/workflows/build-wheels.yml | 1 - .github/workflows/cmake-build.yml | 1 - .github/workflows/cmake-test.yml | 1 - .../UnicodeNames/UnicodeLayerNames.psb | Bin 24248 -> 25496 bytes .../UnicodeNames/UnicodeLayerNames.psd | Bin 23752 -> 24944 bytes .../TestUnicodeLayerNames.cpp | 28 +++++++++++++++--- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-wheels.yml b/.github/workflows/build-wheels.yml index 1a17c405..ed418bc0 100644 --- a/.github/workflows/build-wheels.yml +++ b/.github/workflows/build-wheels.yml @@ -6,7 +6,6 @@ on: push: branches: - dev - - 82-add-unicode-layer-name-support pull_request: branches: - master diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 620391dd..048d116c 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -5,7 +5,6 @@ on: push: branches: - dev - - 82-add-unicode-layer-name-support pull_request: branches: - master diff --git a/.github/workflows/cmake-test.yml b/.github/workflows/cmake-test.yml index e2916e0f..ca30cc1e 100644 --- a/.github/workflows/cmake-test.yml +++ b/.github/workflows/cmake-test.yml @@ -5,7 +5,6 @@ on: push: branches: - dev - - 82-add-unicode-layer-name-support pull_request: branches: - master diff --git a/PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psb b/PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psb index 059072655fe3217ec9e5a624c9b0dfc2cfb5fb8a..8f770c3267b56f0e4316907f08ed84e96c667bdf 100644 GIT binary patch delta 832 zcma)2&ui0g6n|;b>YSTl;16&}4joJ+E@_)4>1G9|>A>4Hf3Fq|G;7AnQW24vLgA z@a91wiaU5v*uj%Sa`B=U4?Bte6W+!IFN(|`FW<~xJ^9G{e!rjhUf%n>&&yZL#x`?b zD3mzu!t`~HgUF5yGYi0;9GMzU0N@8SH$rp#+jn0(&$eIpCB3!hTgf-GFN)t21F9&? zhO8D8y`bcSX;$xv++%O2buF8(<};Rrmm1oR#U609h~JZrR{7@ zuVr;jRAh~aN;M~mrfy22W@SuM&sQa-riPEW4)=d8*AHm_vI#qVr*k~}iSBa<;0Lwv z$+*O}BNR5q?Y4jp4N5x;i=$1qbTu#S;}_lDFRoEV!i+oUPfn=37^NQb(u zhJzIX`XEfe7|ehPZ6MIZSRKz5Xn_aCh_c)8n^?!WK3S!>?N|{;Pf_gGR`)So-1R+s zA4ju-t@16(?AjBui*dY%4HvlOr}3!r9}zSv!qDWB(;z;nl$>SHb!>-Ne~*h~9fC<%0tXr> zgO6T;5~5`s?BZ>s6R>(lCMk{u;IRi2VbAn^e8>G`F@kR;J7%_y%ua>!jiYSPy?89V IywK!+0)KGN6951J delta 357 zcmbPnoN>oq#t8~?K_@JnJbhVI89+b)Od=5*qy91Rn&}#vgcz7x8CzJHm`+Y*wnP(I z&0MWwVQ!F`YLaBBYnE)Dq-$toVySCkm};n-XlZDYYGGoYmTa6n*^9+h#mqc0$uP|{ zRW~s?HAOcm1*9;=!UU+rAjKdt#mFo*DQ)v+mRc6#jGW8vzyfmD8gIT~ ztIBA|2=){c*e5I?63jOM^O+bSvbta%8v`SdX5MUJ&n>{nyxGOyotf9n%Fsjs?%^3h zQ+POAz=|2zJs6laTLh;wvd#K>bAj!T$^PMqo7qC0nZSHIcOYMG^Y3U;=FMvHMJxcL CR99aB diff --git a/PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psd b/PhotoshopTest/documents/UnicodeNames/UnicodeLayerNames.psd index 597bfbc40fd9c3a69048b2e068911e02aeb78a2a..253a30099884cd40947176922cb9a2a429e2a799 100644 GIT binary patch delta 819 zcma)2&ui0g6n|;bZc`^=pza_eLIp*#=G!)H(#;A^(ZO_dsSdF+(&d{j(6ymig)&AF zym@dC#fyRyPXiAUFM3lDM7;VZ2%hG2f;$ZL<(v7dCm-LJ@B6&G@B4h-d-I&ze8sIE zAv@aX$qRx2q4gb(0pJ0aJIZq6$Iq3m)XU+uN6WP*udVklo)*8y2JmQ9*hWSX^dG?P)Y3d#AS!r7#ftLl21P+2FcD$`6> zlQq+{WIbnFc3Q2f>AV`;6IO)(Yk8wj`&Uh{GH^UA@?Y3IdjNhg3m%?4!Ho%Q)Np11 z{PoLNR$(a4g%+(uW|;(Vc*ldC;$D$U1pU+J_`!UE5b5_qDl@D7``%&4`&jmMW|m7l zhUT+vDJYfi#G<(7m&&EYFgD^8f7Bq|@zj*rp)IM_YPQ`Xv-Gf x6s#V~cr-EFfQUV~5WA-5VI1}M*f#v`Wjj)~g~~>Pf!PBwzkB9jFmh#`{|P~v(i#8& delta 349 zcmexxi1EZu#tDkDCoG&ieOXi)KtKRYA`u&d{xR{I=^C1Z7?@ibTUePIO^#)@L=#!e zT&-emnP!q`YLKdHX=r4uYmsDPsGFE-WT|VAVquzOVr-IRnwC1*iN#gL%*4dh!oo0B zH_0-^QrA4$BvCghHOW{vCDGKx)YRO-)GRS&^J~cVgh@E1w?}R24FrDBScmg%wuC<1k%i#4eYrE7@0TQ_`5Unnpqi|D8PL?A!q^z yM+5@{n+5~ZW{u!*Mz&dBZ#U;DPnHi4+nF+#A1@h%K&yE&l+I%c_6*B->-&0ip diff --git a/PhotoshopTest/src/TestUnicodeLayerNames/TestUnicodeLayerNames.cpp b/PhotoshopTest/src/TestUnicodeLayerNames/TestUnicodeLayerNames.cpp index 63531da6..ba6eddd1 100644 --- a/PhotoshopTest/src/TestUnicodeLayerNames/TestUnicodeLayerNames.cpp +++ b/PhotoshopTest/src/TestUnicodeLayerNames/TestUnicodeLayerNames.cpp @@ -19,7 +19,12 @@ TEST_CASE("Read Unicode layer name from psd file") LayeredFile layeredFile = LayeredFile::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--------------------------------------------------------------------------------------------------------------------"); @@ -44,7 +49,12 @@ TEST_CASE("Read Unicode layer name from psb file") LayeredFile layeredFile = LayeredFile::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--------------------------------------------------------------------------------------------------------------------"); @@ -74,7 +84,12 @@ TEST_CASE("Read write unicode layer name from psd file") LayeredFile layeredFile = LayeredFile::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--------------------------------------------------------------------------------------------------------------------"); @@ -104,7 +119,12 @@ TEST_CASE("Read write unicode layer name from psb file") LayeredFile layeredFile = LayeredFile::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--------------------------------------------------------------------------------------------------------------------");