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

unicode in labeled combo box for string #4431

Closed
sugizo opened this issue Nov 30, 2022 · 9 comments
Closed

unicode in labeled combo box for string #4431

sugizo opened this issue Nov 30, 2022 · 9 comments

Comments

@sugizo
Copy link

sugizo commented Nov 30, 2022

text = "\u2654"; // ["\u2654":white king, "\u2655":white queen]
text = "\u2654"; // ["\\u2654":white king, "\\u2655":white queen]
text = "\u2654"; // [\u2654:white king, \u2655:white queen]
text = "\u2654"; // [\\u2654:white king, \\u2655:white queen]

result

u2655
\u2655
\u2655
\\u2655

objective
show unicode in labeled combo box for string
for example on code above shown the white king (♔) and queen (♕) when combo box is selected

question
how to achieve it in openscad way ?

thanks and best regards

@MichaelAtOz
Copy link
Member

MichaelAtOz commented Nov 30, 2022 via email

@MichaelAtOz
Copy link
Member

MichaelAtOz commented Nov 30, 2022 via email

@sugizo
Copy link
Author

sugizo commented Nov 30, 2022

perhaps not getting what my objective is

objective is to create the drop down combo list
when user change it, let say 'white king'
then it will change the variable text, that will show the unicode white king in openscad

this work but when turn it into variable is not work
text("\u2654", size = 10, font = "Caslon");

not work

chess_text = "\u2654"; // ["\u2654":white king, "\u2655":white queen]

text(chess_text, size = 10, font = "Caslon");

perhaps openscad repo can activated the github discussion feature

@UBaer21
Copy link
Contributor

UBaer21 commented Nov 30, 2022

Seems escaping doesn't work either .. it is not converted in a symbol anymore.

chess_text = "\u2654"; // ["\u2654", "\\u2655"]


echo("\u2654",chess_text);
text(chess_text, size = 10, font = "Caslon");
text("\u2654", size = 10, font = "Caslon");

@MichaelAtOz
Copy link
Member

perhaps openscad repo can activated the github discussion feature

NO. GitHub is for Development purposes including bug reports, and only for matters which cannot be solved by the Mailing-list.
It is not to teach people how to code in OpenSCAD.

There are people on the Mailing-list, including many Developers, who can help you there.

Escaping is a property of STRINGS, ie part of statements or expressions.
Anything after // is UTF text, it is ignored by the main parser, and only text is used by customizer, not strings.
So anything special-UTF in comments just need to be pasted in as UTF characters/symbols/glyphs.

//suite
a=1;// [0:♔king,1:♕queen]
chesstext = (a==0) ? "\u2654" : "\u2655";
echo(a,chesstext);

ECHO: 0, "♔"

@MichaelAtOz
Copy link
Member

BTW, Customizer has external syntax dependencies with Thingiverse.
Any changes would need to be carefully considered, so using techniques like above is currently best practice.

@UBaer21
Copy link
Contributor

UBaer21 commented Nov 30, 2022

textFix = 9812; // [9812:"♔", "♕"]
echo(chr(textFix),ord(chr(textFix)));

text(is_num(textFix)?chr(textFix):textFix, size = 10, font = "Caslon");

@UBaer21
Copy link
Contributor

UBaer21 commented Nov 30, 2022

Anything after // is UTF text, it is ignored by the main parser, and only text is used by customizer, not strings.

@MichaelAtOz But there is some parsing done by the customizer as some are converted to strings and as the escaping does produce the same echo. Or why is the "\" removed also "" are added for text if if not there but not for numbers. I can understand that this is bit confusing. But text is also not displayed with »"« which makes [1,"1"] look equal in the dropdown box , And as far as i can see it is not documented.

cust=1;//[a,1,"1",""1""]
echo(cust);

@sugizo
Copy link
Author

sugizo commented Dec 1, 2022

code work

text = "♔"; // [♔:King, ♕:Queen, ♖:Rook, ♗:Bishop, ♘:Knight, ♙:Pawn, ♚:king, ♛:queen, ♜:rook, ♝:bishop, ♞:knight, ♟:pawn]
font_family = "Caslon"; // [Caslon, Chrysanthi Unicode, DejaVu Sans, DejaVu Sans Mono, FreeSerif, MV Latin, Pecita, Quivira, Scid Chess Traveller, Symbola]

problem
it's just the font family, if already read the unicode, don't bother using 'code point' just copas the 'symbol' will solve the problem

@sugizo sugizo closed this as completed Dec 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants