mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
294 stars 28 forks source link

Baseline incorrect with Chinese characters #253

Closed archcst closed 8 months ago

archcst commented 8 months ago

Reproduce the issue

  1. xelatex -no-pdf -output-directory . math.tex to get the .xdv file
  2. xdvipdfmx math.xdv -o math.pdf to get the .pdf file
  3. dvisvgm math.xdv -e -n -b min -o math.svg to get the .svg file

With comparing the .pdf and the .svg file, you could find the Chinese characters is lower of English ones:

SCR-20231102-pyep

.tex file content

\documentclass{article}  
\usepackage{fontspec}
\setmainfont{华文仿宋}
\begin{document}

$$ \frac{ABC中文}{ABC中文} $$

\end{document}

dvisvgm version

❯  dvisvgm --version
dvisvgm 3.0.3
mgieseki commented 8 months ago

Could you please provide the font 华文仿宋 or post a link where it can be downloaded? Currently, I can't test your example because of the missing font. If possible, also try to convert your file with the latest version 3.1.2 of dvisvgm and check whether the issue occurs there as well.

mgieseki commented 8 months ago

The issue might be the same as #235 which has been fixed in dvisvgm 3.1.

archcst commented 8 months ago

Thanks for your fast response. Is there anyway upgrade dvisvgm via Hombrew?

mgieseki commented 8 months ago

Unfortunately, I don't know since I'm not familiar with Homebrew. Maybe you could ask on their discussion page if they provide a more recent version.

archcst commented 8 months ago

I’ll try to compile the latest version, you may close this one, thanks again

From: "Martin @.> Date: Thu, Nov 2, 2023, 19:08 Subject: Re: [mgieseki/dvisvgm] Baseline incorrect with Chinese characters (Issue #253) To: @.> Cc: @.>, @.> Unfortunately, I don't know since I'm not familiar with Homebrew. Maybe you could ask on their discussion pagehttps://github.com/orgs/Homebrew/discussions if they provide a more recent version. — Reply to this email directly, view it on GitHubhttps://github.com/mgieseki/dvisvgm/issues/253#issuecomment-1790522861, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJ57UL63CEQKNQMBF47NT7TYCN5LJAVCNFSM6AAAAAA62U3BXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJQGUZDEOBWGE. You are receiving this because you authored the thread.[image: https://github.com/notifications/beacon/AJ57UL53S3JGVSYAZFCMWOTYCN5LJA5CNFSM6AAAAAA62U3BXWWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTKXE262.gif]Message ID: @.***>

mgieseki commented 8 months ago

Ok, thanks for the update. Please let me know if the latest version fixes the problem for you. Otherwise, I'll have a look what's actually going on.

archcst commented 8 months ago

Hi, I'm encountering a compile issue with the 3.1.2 release. Could you please help on this?

Undefined symbols for architecture arm64:
  "_main", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [hashcheck] Error 1
make[2]: *** [check-am] Error 2
make[1]: *** [check-recursive] Error 1
make: *** [check-recursive] Error 1
mgieseki commented 8 months ago

Could you please attach the entire build log including the output of configure and make? The single linker error message doesn't provide enough information to determine the cause of the failure.

archcst commented 8 months ago

log.txt Please find log in the attachment, tks

mgieseki commented 8 months ago

The dvisvgm binary seems to be built correctly and should be located in the src directory. However, the test hashcheck can't be built, probably because the corresponding source file hashcheck.cpp wasn't created correctly. Maybe it's empty on your system. The file should be created during the build process by genhashcheck.py which requires Python and the Python package xxhash to be installed. You can try to build it manually by calling make hashcheck inside directory tests. Afterwards have a look at the file and check if the main function is present there. If not, some Python stuff is probably missing on your computer.

archcst commented 8 months ago

You remind me when I compile dvisvgm it hints couldn’t find python command (the built in python command in Mac is python3), therefore I add an shell alias pointing python to python3 for working around. Is it the right way to do so?

From: "Martin @.> Date:  Fri, Nov 3, 2023, 19:13 Subject:  Re: [mgieseki/dvisvgm] Baseline incorrect with Chinese characters (Issue #253) To: @.> Cc: @.>, @.>

The dvisvgm binary seems to be built correctly and should be located in the src directory. However, the test hashcheck can't be built, probably because the corresponding source file hashcheck.cpp wasn't created correctly. Maybe it's empty on your system.  The file should be created during the build process by genhashcheck.pyhttp://genhashcheck.py which requires Python and the Python package xxhash to be installed.  You can try to build it manually by calling make hashcheck inside directory tests. Afterwards have a look at the file and check if the main function is present there. If not, some Python stuff is probably missing on your computer. — Reply to this email directly, view it on GitHubhttps://github.com/mgieseki/dvisvgm/issues/253#issuecomment-1792257096, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJ57ULZHMEIDX24QFWEF2YTYCTGWDAVCNFSM6AAAAAA62U3BXWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJSGI2TOMBZGY. You are receiving this because you authored the thread.[image]Message ID: @.***>

mgieseki commented 8 months ago

Yes, that should work. On Linux, python is usually a symbolic link to the python3 executable:

> ls -la /usr/bin/python
lrwxrwxrwx. 1 root root 9  3. Okt 02:00 /usr/bin/python -> ./python3
archcst commented 8 months ago

I found the dvisvgm file and mv it to /usr/local/bin, now it works fine with 3.12 version, thanks a lot!

SCR-20231105-kfdt

but I get this message,

❯  dvisvgm --version
dvisvgm 3.1.2

❯  dvisvgm math.xdv -e -n -b min -o math.svg
processing of PostScript specials is disabled (Ghostscript not found)
pre-processing DVI file (format version 7)
processing page 1
  graphic size: 43.44931pt x 568.400711pt (15.270686mm x 199.770002mm)
  output written to math.svg
1 of 1 page converted in 0.190968 seconds

It's wired I'm pretty sure I have installed Ghostscript

❯  brew list | grep ghostscript
ghostscript

Any hints?

mgieseki commented 8 months ago

Great to hear that the latest version fixes the issue for you.

It's wired I'm pretty sure I have installed Ghostscript

dvisvgm requires the Ghostscript library, the Ghostscript executable is not sufficient. You need to make sure that the library is accessible through the search path of the dynamic linker or specify the path with option --libgs or environment variable LIBGS. Since I don't know much about MacOs, I can't give more specific hints. Here you'll find some more information:

archcst commented 8 months ago

Thanks a lot, all problem solved!

❯  export LIBGS=/opt/homebrew/Cellar/ghostscript/10.02.0/lib/libgs.10.02.dylib

❯  dvisvgm math.xdv -e -n -b min -o math.svg
pre-processing DVI file (format version 7)
processing page 1
  graphic size: 43.44931pt x 568.400711pt (15.270686mm x 199.770002mm)
  output written to math.svg
1 of 1 page converted in 2.23617 seconds