OrcaSlicer icon indicating copy to clipboard operation
OrcaSlicer copied to clipboard

Color gradients do not work in certain languages

Open villamany opened this issue 2 months ago • 2 comments

Is there an existing issue for this problem?

  • [x] I have searched the existing issues

Snapmaker_Orca Version

2.4.0

Operating System (OS)

Windows

OS Version

W11

Additional system information

No response

Printer

Snapmaker U1

How to reproduce

When using SOrca in Spanish, creating a color gradient automatically converts it to a solid 50%-50% mix icon in the color mixing tab, resulting in a solid print instead of a gradient. However, if I switch SOrca to English and create a new gradient, it works as expected—showing a gradient icon and printing correctly.

Could this be due to the local decimal separator?

Actual results

It seems that gradients do not work when using a language with a local decimal separator other than the dot.

Expected results

Gradient colors work when using a different locale separator than "."

Project file & Debug log uploads

gradientTest.3mf.txt

Checklist of files to include

  • [ ] Log file
  • [x] Project file

Anything else?

No response

villamany avatar Sep 24 '26 22:09 villamany

I think this is the decimal separator, as you guessed, and it should already be fixed in 2.4.1. I read the source and your attached project; I have not run 2.4.0 in Spanish.

Your 3MF. In mixed_filament_definitions, the gradient you made in English (stable id u60) ends with cm3,r1/0.8000/0.2000. The ones made in Spanish (u57, u58, u59) end with cm3 only: the mix was saved in gradient mode, but the gradient values (r1/...) are missing, so the slicer treats it as a plain 50/50 mix. That is the solid icon you saw.

Why, in 2.4.0. MixedFilament.cpp (tag v2.4.0, around line 2353) wrote the gradient with std::snprintf(buf, sizeof(buf), "%.4f/%.4f", ...), which follows the system locale. With a Spanish locale that produces r1/0,8000/0,2000. The definitions are comma separated, so the token splits into r1/0, 8000/0 and 2000; the parser needs two / in the r token, ignores it, and the gradient is turned off on the next read. I checked the snprintf part with a small C++ program under es_ES.UTF-8: it prints 0,8000/0,2000 and the r1/0 token is rejected.

Fix. Since b626b4be6 (#937, in v2.4.1) the same line uses float_to_string_decimal_point(mf.gradient_start, 4), which always writes a dot. So on 2.4.1 or 2.4.2-alpha, creating the gradient again in Spanish should keep it. Mixes already saved without r1 will not come back by themselves; they need to be set to gradient again once.

If it still turns solid on 2.4.1 in Spanish, a 3MF saved from 2.4.1 would show whether r1/ is written, and I can look again.

alandebortolo avatar Nov 21 '26 13:11 alandebortolo

Confirmed — a locale bug: under decimal-comma locales (e.g. Spanish), gradient ratios were serialized with a comma decimal separator, so the parser dropped the r1/… gradient data and the gradient fell back to a 50/50 mix. Thanks @alandebortoli for the correct analysis.

Fixed in v2.4.1 (PR #937, b626b4b: gradient values now go through float_to_string_decimal_point, locale-independent).

Note: 3MF files saved with 2.4.0 in a non-English locale keep the already-stripped gradient data — they won't heal on upgrade. Please re-create the gradient once on 2.4.1+. If a newly-created gradient still misbehaves on 2.4.1+, comment with your version and steps (or attach the 3MF) and we'll reopen.

gushanji avatar Nov 26 '26 09:11 gushanji