vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
545 stars 90 forks source link

Unicode module #142

Closed ivankokan closed 4 years ago

ivankokan commented 4 years ago

The implementation of unicode module is out-of-date for some time. Although ucs package served its purpose years ago (along with utf8x option for inputenc), it has been always suggested to avoid using it: https://tex.stackexchange.com/a/13070/115879.

Nowadays, such implementation is not needed at all: https://tex.stackexchange.com/a/184628/115879 https://tex.stackexchange.com/a/203804/115879.

In other words, both ucs package and utf8x option for inputenc should not be used anymore (nevertheless, utf8 has been the default one since 2018: https://tex.stackexchange.com/questions/446650/please-use-latin2-or-utf8-inputenc-with-magyar-babel-warning/446653#446653).

Proposal: let's completely remove this module, I can prepare the PR.

jorgepiloto commented 4 years ago

Hi @ivankokan,

I recently started using asymptote and wanted to generate a label with zodiac unicode characters, i.e.: pisces symbol. After #144 was merged, the unicode module is no longer available (and thus required) and thought this should be as simple as running:

# Generate a label showing pisces symbol
label("\u2648", (0,0));

However, I am not getting desired output and just the numbers are printed. This is probable simple to solve but even after reading documentation, I wasn't able to achieve desired output. May you please guide or notice me if is a local problem or am I doing something wrong? Thank you for this amazing tool!

ivankokan commented 4 years ago

Please check this FAQ: https://asymptote.sourceforge.io/FAQ/section4.html#internatfonts

I am in a hurry, will try to test and answer properly later today.

charlesstaats commented 4 years ago

This may or may not work, but try changing your double-quotes " to single quotes '. That way your backslash will be processed as an escape character rather than forwarded to TeX as a backslash.

On Tue, Aug 11, 2020 at 4:19 AM Ivan Kokan notifications@github.com wrote:

Please check this FAQ: https://asymptote.sourceforge.io/FAQ/section4.html#internatfonts

I am in a hurry, will try to test and answer properly later today.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vectorgraphics/asymptote/issues/142#issuecomment-671802714, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBQISY67YOB35UWUENX4RTSAD5IRANCNFSM4KQ26BBQ .

jorgepiloto commented 4 years ago

Thank you both @ivankokan and @charlesstaats for your quick answers on this. Although I was not lucky with those suggestions, I ended up using the following LaTeX packages for writing down symbols in labels: wasysym and marvosym. However, I would still like to know how to face this problem without importing LaTeX packages, although now this issue is not critical for me. Best regards :rocket:

ivankokan commented 3 years ago

@jorgepiloto Can you please provide the original example you had troubles with (if you know that one worked with the old unicode module, even better)?

jorgepiloto commented 3 years ago

Thanks for your help @ivankokan, let me paste a reproducible script which contains also additional information regarding my Asymptote version and Latex one:

/*
 * Reproducible bug when using LaTeX labels

 * Asymptote version 2.67 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]
 * ------------------------------------------------------------------------------

 * ENABLED OPTIONS:
 * GSL      GNU Scientific Library (special functions)
 * FFTW3    Fast Fourier transforms
 * XDR      external data representation (portable binary file format)
 * CURL     URL support
 * Readline interactive history and editing
 * Sigsegv  distinguish stack overflows from segmentation faults
 * GC       Boehm garbage collector
 * 
 * DISABLED OPTIONS:
 * WebGL    3D HTML rendering
 * OpenGL   3D OpenGL rendering

 * LaTeX version
 * -------------

 * pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020/Arch Linux)
 * kpathsea version 6.3.2
 * Copyright 2020 Han The Thanh (pdfTeX) et al.
 * There is NO warranty.  Redistribution of this software is
 * covered by the terms of both the pdfTeX copyright and
 * the Lesser GNU General Public License.
 * For more information about these matters, see the file
 * named COPYING and the pdfTeX source.
 * Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
 * Compiled with libpng 1.6.37; using libpng 1.6.37
 * Compiled with zlib 1.2.11; using zlib 1.2.11
 * Compiled with poppler version 0.90.0

 */

/* Packages and modules to be used */
import geometry;

/* Settings, configuration and packages */
settings.outformat="png";
unitsize(1cm);

/* Macros and constants */
pair OO = (0,0);
real R_circle = 2.50;

/* Draw a simple circle with pisces unicode symbol inside of it */
draw(circle(OO, R_circle), linewidth(2pt));
label("\u2648", OO);
jorgepiloto commented 3 years ago

Previous script generates the following figure without properly rendering unicode label. Not sure if this is the proper way to define these kind of characters...

ivankokan commented 3 years ago

Has such code ever worked within Asymptote (before removing the unicode module)?

Manually adding the equivalent of unicode does not bring any difference:

usepackage("ucs");
usepackage("inputenc","utf8x");

Also, I am not familiar with the \u####-syntax for explicit character codes. Do you have any references for such? (From my current point of view, \u expectedly produces the breve over the following token - 2 in your case.)

jorgepiloto commented 3 years ago

Most of my work makes use of Python language, which provides the syntax `"\uXXXX" in case you want to print unicode characters. I am a little bit familiar with C/C++ syntax and, since Asymptote shows a similar one, thought it might be also possible to generate unicode strings this way.

I recently started to use the Asymptote vector drawing language and never check if importing unicode module made a difference in the behavior of the script. Also, I tried the following with both ucs and inputenc modules without success:

label("♓︎", OO)
jorgepiloto commented 3 years ago

By the way, this is the image I was able to generate with the usage of wasysym and marvosym packages:


Your software is amazing, thanks for all responses and helping me with this issue :rocket:

ivankokan commented 3 years ago

Most of my work makes use of Python language, which provides the syntax `"\uXXXX" in case you want to print unicode characters. I am a little bit familiar with C/C++ syntax and, since Asymptote shows a similar one, thought it might be also possible to generate unicode strings this way.

I recently started to use the Asymptote vector drawing language and never check if importing unicode module made a difference in the behavior of the script. Also, I tried the following with both ucs and inputenc modules without success:

label("♓︎", OO)

Let us first conclude:

Later today I will provide examples on how to create Unicode labels depending on some TeX engines I am familiar with.