From 7ade24fc77a7150f50304a08bfa43496d0e352ed Mon Sep 17 00:00:00 2001 From: TheLastRar Date: Tue, 26 May 2026 10:34:52 +0100 Subject: [PATCH] Deps: Workaround MSVC ICE with PlutoVG --- .../scripts/windows/build-dependencies.bat | 1 + .../windows/plutovg-workaround-msvc-ice.patch | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 .github/workflows/scripts/windows/plutovg-workaround-msvc-ice.patch diff --git a/.github/workflows/scripts/windows/build-dependencies.bat b/.github/workflows/scripts/windows/build-dependencies.bat index 32de578f8f..235078530f 100644 --- a/.github/workflows/scripts/windows/build-dependencies.bat +++ b/.github/workflows/scripts/windows/build-dependencies.bat @@ -469,6 +469,7 @@ echo "Building PlutoVG..." rmdir /S /Q "plutovg-%PLUTOVG%" %SEVENZIP% x "plutovg-%PLUTOVG%.zip" || goto error cd "plutovg-%PLUTOVG%" || goto error +%PATCH% -p1 < "%SCRIPTDIR%\plutovg-workaround-msvc-ice.patch" || goto error cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DPLUTOVG_BUILD_EXAMPLES=OFF -B build -G Ninja || goto error cmake --build build --parallel || goto error ninja -C build install || goto error diff --git a/.github/workflows/scripts/windows/plutovg-workaround-msvc-ice.patch b/.github/workflows/scripts/windows/plutovg-workaround-msvc-ice.patch new file mode 100644 index 0000000000..69da4fae4f --- /dev/null +++ b/.github/workflows/scripts/windows/plutovg-workaround-msvc-ice.patch @@ -0,0 +1,52 @@ +diff --git a/source/plutovg-font.c b/source/plutovg-font.c +index 0ad89b1..110de7f 100644 +--- a/source/plutovg-font.c ++++ b/source/plutovg-font.c +@@ -836,7 +836,8 @@ int plutovg_font_face_cache_load_file(plutovg_font_face_cache_t* cache, const ch + size_t family_index = 0; + if(unicode_family_name) { + const stbtt_uint8* family_name = unicode_family_name; +- while(family_length) { ++ //while(family_length) { ++ for (int i = family_length; i > 0; i -= 2) { + stbtt_uint16 ch = family_name[0] * 256 + family_name[1]; + if(ch < 0x80) { + entry->family[family_index++] = ch; +@@ -853,7 +854,8 @@ int plutovg_font_face_cache_load_file(plutovg_font_face_cache_t* cache, const ch + entry->family[family_index++] = (0x80 + ((c) & 0x3f)); + + family_name += 2; +- family_length -= 2; ++ //family_length -= 2; ++ i -= 2; + } else { + entry->family[family_index++] = (0xe0 + (ch >> 12)); + entry->family[family_index++] = (0x80 + ((ch >> 6) & 0x3f)); +@@ -861,7 +863,7 @@ int plutovg_font_face_cache_load_file(plutovg_font_face_cache_t* cache, const ch + } + + family_name += 2; +- family_length -= 2; ++ //family_length -= 2; + } + + entry->family[family_index] = '\0'; +@@ -902,7 +904,8 @@ int plutovg_font_face_cache_load_file(plutovg_font_face_cache_t* cache, const ch + }; + + const stbtt_uint8* family_name = roman_family_name; +- while(family_length) { ++ //while(family_length) { ++ for (int i2 = family_length; i2 > 0; i2--) { + stbtt_uint16 ch = MAC_ROMAN_TABLE[family_name[0]]; + if(ch < 0x80) { + entry->family[family_index++] = ch; +@@ -916,7 +919,7 @@ int plutovg_font_face_cache_load_file(plutovg_font_face_cache_t* cache, const ch + } + + family_name += 1; +- family_length -= 1; ++ //family_length -= 1; + } + + entry->family[family_index] = '\0';