vectorgraphics / asymptote

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

texpath() call with Ghostscript 9.56.1 #319

Closed dmitrys99 closed 2 years ago

dmitrys99 commented 2 years ago

Hi, guys! I have working environment, where everything works well: TeXLive 2022, Asymptote 2.79, Ghostscript 9.54.0, FreeBSD or Linux. Once in a while Ghostscript has been updated to 9.56.1 and compilation failed. Bare minimum sample:

pen pn = fontsize(10pt) + basealign;
Label M = Label("M", pn);
path[] mPath      = texpath(M);
real   mWidth     = max(mPath).x - min(mPath).x;

Command line call:

$ asy -tex xelatex t.asy

Error message:

            real y=min(g[i][0]).y;
            ^
/home/user/tools/texlive/2022/texmf-dist/asymptote/plain_Label.asy: 669:11: reading array of length 0 with out-of-bounds index 0

I've tried to rebuild Ghostscript from sources and sync its GS_LIB path with 9.54 but no success. Downgrading back to 9.54 helps, but it is not a solution for a long distance.

How to fix that or understand what is happening to start fixing?

I ready to make issue to Ghostscipt but have no clue what to say.

dmitrys99 commented 2 years ago

Additional notes: When I generate t.asy with -k, there is a file t__.ps, which differs in versions 9.54. and 9.56.:

5c5
< %%Creator: GPL Ghostscript 9540 (ps2write)
---
> %%Creator: GPL Ghostscript 9561 (ps2write)
7c7
< %%CreationDate: D:20220629114508+03'00'
---
> %%CreationDate: D:20220629114156+03'00'
8346a8347,8419
> %%BeginResource: file (PDF CharProc obj_7)
> 7 0 obj
> <</Length 167   >>stream
> 27.7 0 8 -11 20 0 d1
> 12 0 0 11 8 -11 cm
> BI
> /IM true
> /W 12
> /H 11
> /BPC 1
> /D[1
> 0]
> /F[/A85
> /CCF]
> /DP[null
> <</K -1
> /Columns 12
> /EndOfBlock false>>]
> ID
> -Dh.V4a[5+>?G<!~>
> EI
> endstream
> endobj
> %%EndResource
> %%BeginResource: file (PDF CharProc obj_8)
> 8 0 obj
> <</Length 308   >>stream
> 91.4 0 3 -68 89 0 d1
> 86 0 0 68 3 -68 cm
> BI
> /IM true
> /W 86
> /H 68
> /BPC 1
> /D[1
> 0]
> /F[/A85
> /CCF]
> /DP[null
> <</K -1
> /Columns 86
> /EndOfBlock false>>]
> ID
> -FjC!/f=9[nldIHiS_SW_Ur.3^=E4thsa'!li4Hj?iC#>l$r+#?gIa$qHs4$:\t+Yrg3Y7e,I,Z
> J(OPSqu2r]ht?u`qgYIBht6rPrnlsip\t2hs0qrVXoH0#J*m8Cli4Hj?iC"#qZ#s\=6g['%lfCu
> )u%n~>
> EI
> endstream
> endobj
> %%EndResource
> %%BeginResource: procset (PDF Font obj_10)
> 10 0 obj
> <</R9
> 9 0 R>>
> endobj
> %%EndResource
> %%BeginResource: procset (PDF Font obj_9)
> 9 0 obj
> <</Type/Font
> /Encoding 6 0 R/CharProcs <</a1 8 0 R
> /a0 7 0 R
> >>/FontMatrix[1 0 0 1 0 0]/FontBBox[0 0 86 68]/FirstChar 0/LastChar 1/Widths[
> 27.7 91.4]
> /Subtype/Type3>>
> endobj
> %%EndResource
> %%BeginResource: encoding (PDF Encoding obj_6)
> 6 0 obj
> <</Type/Encoding/Differences[0
> /a0/a1
> ] >>
> endobj
> %%EndResource
8358a8432
> /Font 10 0 R
8365c8439
< <</Length 1265>>stream
---
> <</Length 116>>stream
8369,8413c8443,8449
< 0.2 i
< 1307.08 7046.27 m
< 1307.08 7049.14 1304.69 7051.53 1301.81 7051.53 c
< 1298.92 7051.53 1296.55 7049.14 1296.55 7046.27 c
< 1296.55 7043.39 1298.92 7041 1301.81 7041 c
< 1304.69 7041 1307.08 7043.39 1307.08 7046.27 c
< f
< 1403.31 7041 m
< 1403.31 7044.08 l
< 1400.94 7044.08 l
< 1393.28 7044.08 1393.08 7045.17 1393.08 7048.75 c
< 1393.08 7101.09 l
< 1393.08 7104.67 1393.28 7105.77 1400.94 7105.77 c
< 1403.31 7105.77 l
< 1403.31 7108.84 l
< 1386.53 7108.84 l
< 1383.95 7108.84 1383.95 7108.75 1383.25 7106.95 c
< 1361.5 7051.03 l
< 1339.94 7106.66 l
< 1339.05 7108.84 1338.75 7108.84 1336.47 7108.84 c
< 1319.67 7108.84 l
< 1319.67 7105.77 l
< 1322.06 7105.77 l
< 1329.7 7105.77 1329.91 7104.67 1329.91 7101.09 c
< 1329.91 7051.44 l
< 1329.91 7048.75 1329.91 7044.08 1319.67 7044.08 c
< 1319.67 7041 l
< 1331.3 7041.3 l
< 1342.92 7041 l
< 1342.92 7044.08 l
< 1332.69 7044.08 1332.69 7048.75 1332.69 7051.44 c
< 1332.69 7104.97 l
< 1332.78 7104.97 l
< 1356.73 7043.19 l
< 1357.22 7041.89 1357.72 7041 1358.72 7041 c
< 1359.81 7041 1360.11 7041.8 1360.5 7042.89 c
< 1384.94 7105.77 l
< 1385.05 7105.77 l
< 1385.05 7048.75 l
< 1385.05 7045.17 1384.84 7044.08 1377.19 7044.08 c
< 1374.81 7044.08 l
< 1374.81 7041 l
< 1378.48 7041.3 1385.23 7041.3 1389.11 7041.3 c
< 1392.98 7041.3 1399.64 7041.3 1403.31 7041 c
< f
---
> q
> 10 0 0 10 0 0 cm BT
> /R9 1 Tf
> 0.1 0 0 -0.1 128.7 704.1 Tm
> [<00>-300.049<01>]TJ
> ET
> Q
dmitrys99 commented 2 years ago

One more update:

gs -q -dBATCH -P -dSAFER -sDEVICE=ps2write -sOutputFile=/dev/null t_.ps

does not produce output (to console) with 9.56 while 9.54 prints M ... before >>showpage, press <return> to continue<< where ... is a set of numbers.

dmitrys99 commented 2 years ago

Opened an issue #705632 at Ghostscript's bugtracker.

dmitrys99 commented 2 years ago

Opened an issue #705632 at Ghostscript's bugtracker.

GS maintainers answered. To make texpath() work with GS 9.56 one have to set GS_OPTIONS=-dNoOuputFonts. The reasons for that are changes in interpreter, which is written in C, not PS and changed font processing.

I tried this solution, it works for me.