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

Occasionally definitions are missing although still referenced via use, from same DVI file #129

Closed
noahnu opened this issue Mar 1, 2020 · 5 comments
Assignees
Labels
bug
Milestone

Comments

@noahnu
Copy link

@noahnu noahnu commented Mar 1, 2020

Occasionally definitions are missing from the SVG file, although still referenced via use. Anywhere from 1 definition to all the definitions will go missing. Below is a case where all definitions are gone.

This issue is not present in dvisvgm 1.15.1, however is present in 2.8.2.

Steps to reproduce from DVI

Download this DVI file: output.txt (rename from .txt to .dvi).

Then execute:

dvisvgm --exact-bbox --no-fonts --optimize=none --precision=6 --verbosity=2 --cache=none -o texput.svg output.dvi && cat texput.svg

If you run this enough times, you'll get some occurrences where the SVG is not correct, i.e. it refers to missing paths.

When it works correctly, it produces an SVG with the word "Hello" in red. When it is incorrect, we get a correct bounding box, transparent background, but no "Hello".

Generated SVGs

Failed SVG
<?xml version='1.0' encoding='UTF-8'?>
<!-- This file was generated by dvisvgm 2.8.2 -->
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='20.476539pt' height='0pt' viewBox='219.961704 92.154421 20.476539 0'>
<defs/>
<g id='page1'>
<g fill='#f00'>
<use x='219.961704' y='92.154421' xlink:href='#g0-72'/>
<use x='228.734987' y='92.154421' xlink:href='#g0-101'/>
<use x='233.936448' y='92.154421' xlink:href='#g0-108'/>
<use x='237.187345' y='92.154421' xlink:href='#g0-108'/>
<use x='240.438242' y='92.154421' xlink:href='#g0-111'/>
</g>
</g>
</svg>
Valid SVG
<?xml version='1.0' encoding='UTF-8'?>
<!-- This file was generated by dvisvgm 2.8.2 -->
<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='26.023737pt' height='8.571856pt' viewBox='219.961704 83.845579 26.023737 8.571856'>
<defs>
<path id='g0-72' d='M.442341-7.974097V-7.806725L.860772-7.782814C1.123786-7.770859 1.315068-7.758904 1.374844-7.723039C1.601993-7.639352 1.578082-7.878456 1.578082-4.076712C1.578082-.263014 1.601993-.514072 1.374844-.418431C1.315068-.394521 1.123786-.37061 .860772-.358655L.442341-.3467V-.179328V-.011955H2.080199H3.718057V-.179328V-.3467L3.299626-.358655C3.036613-.37061 2.84533-.394521 2.773599-.418431C2.570361-.514072 2.570361-.454296 2.570361-2.343213V-4.040847H4.363636H6.144956V-2.343213C6.144956-.454296 6.144956-.514072 5.941719-.418431C5.869988-.394521 5.69066-.37061 5.415691-.358655L5.009215-.3467V-.179328V-.011955H6.635118H8.272976V-.179328V-.3467L7.854545-.358655C7.591532-.37061 7.412204-.394521 7.340473-.418431C7.12528-.514072 7.137235-.263014 7.137235-4.076712C7.137235-7.878456 7.12528-7.639352 7.340473-7.723039C7.412204-7.758904 7.591532-7.770859 7.854545-7.782814L8.272976-7.806725V-7.974097V-8.141469H6.635118H5.009215V-7.974097V-7.806725L5.415691-7.782814C5.69066-7.770859 5.869988-7.758904 5.941719-7.723039C6.144956-7.639352 6.144956-7.675218 6.144956-5.953674V-4.399502H4.363636H2.570361V-5.953674C2.570361-7.675218 2.570361-7.639352 2.773599-7.723039C2.84533-7.758904 3.036613-7.770859 3.299626-7.782814L3.718057-7.806725V-7.974097V-8.141469H2.080199H.442341Z'/>
<path id='g0-101' d='M2.307347-5.284184C1.542217-5.116812 .956413-4.62665 .597758-3.849564C.203238-3.012702 .251059-1.936737 .705355-1.171606C1.171606-.394521 1.912827 .059776 2.773599 .107597C3.371357 .131507 3.849564-.035866 4.267995-.454296C4.531009-.71731 4.674471-.932503 4.770112-1.207472C4.841843-1.43462 4.829888-1.518306 4.686426-1.518306C4.578829-1.518306 4.590785-1.542217 4.471233-1.207472C4.291905-.6934 3.765878-.263014 3.21594-.167372C2.391034-.035866 1.613948-.609714 1.374844-1.530262C1.303113-1.817186 1.255293-2.223661 1.255293-2.534496V-2.785554H3.024658C4.60274-2.785554 4.794022-2.785554 4.805978-2.833375C4.829888-2.905106 4.829888-3.19203 4.794022-3.431133C4.746202-3.777833 4.686426-3.981071 4.531009-4.27995C4.291905-4.782067 3.88543-5.104857 3.335492-5.260274C3.084433-5.332005 2.546451-5.34396 2.307347-5.284184ZM3.19203-4.985305C3.682192-4.758157 3.981071-4.160399 4.028892-3.335492L4.052802-3.024658H2.654047H1.255293L1.267248-3.096389C1.279203-3.132254 1.291158-3.251806 1.303113-3.359402C1.374844-4.184309 1.841096-4.877709 2.450809-5.057036C2.666002-5.116812 2.976837-5.080946 3.19203-4.985305Z'/>
<path id='g0-108' d='M1.183562-8.237111C.812951-8.2132 .490162-8.18929 .454296-8.18929C.394521-8.18929 .382565-8.16538 .382565-8.009963V-7.830635L.669489-7.81868C1.004234-7.79477 1.159651-7.734994 1.219427-7.603487C1.267248-7.519801 1.267248-7.053549 1.279203-4.100623C1.279203-1.721544 1.279203-.669489 1.255293-.585803C1.207472-.418431 1.099875-.382565 .705355-.358655L.382565-.3467V-.179328V-.011955H1.661768H2.929016V-.179328V-.3467L2.606227-.358655C2.235616-.382565 2.116065-.418431 2.068244-.561893C2.044334-.633624 2.032379-1.769365 2.032379-4.483188V-8.308842L1.936737-8.296887C1.876961-8.296887 1.542217-8.272976 1.183562-8.237111Z'/>
<path id='g0-111' d='M2.450809-5.284184C1.458531-5.092902 .669489-4.303861 .418431-3.263761C.334745-2.940971 .310834-2.438854 .3467-2.15193C.514072-1.099875 1.255293-.239103 2.247572 .02391C2.606227 .131507 3.203985 .131507 3.550685 .02391C4.746202-.298879 5.547198-1.43462 5.475467-2.689913C5.427646-3.466999 5.128767-4.148443 4.590785-4.638605C3.993026-5.200498 3.203985-5.439601 2.450809-5.284184ZM3.21594-5.057036C3.658281-4.97335 4.076712-4.62665 4.27995-4.208219C4.483188-3.801743 4.554919-3.419178 4.554919-2.654047C4.554919-1.590037 4.387547-1.016189 3.957161-.597758C3.084433 .263014 1.721544-.167372 1.374844-1.43462C1.219427-2.020423 1.207472-3.203985 1.362889-3.789788C1.590037-4.686426 2.391034-5.236364 3.21594-5.057036Z'/>
</defs>
<g id='page1'>
<g fill='#f00'>
<use x='219.961704' y='92.154421' xlink:href='#g0-72'/>
<use x='228.734987' y='92.154421' xlink:href='#g0-101'/>
<use x='233.936448' y='92.154421' xlink:href='#g0-108'/>
<use x='237.187345' y='92.154421' xlink:href='#g0-108'/>
<use x='240.438242' y='92.154421' xlink:href='#g0-111'/>
</g>
</g>
</svg>

Generating the DVI File

The DVI is generated by texlive using output_tex.txt (rename to output.tex).

latex -halt-on-error -interaction=nonstopmode output.tex

Running latex --version:

pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian)
kpathsea version 6.3.1/dev
Copyright 2018 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.34; using libpng 1.6.36
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.00

Environment

Using dvisvgm 2.8.2 compiled from source on python:3.8.1-buster docker image installed via:

RUN apt-get update && apt-get install -y \
    libkpathsea-dev \
    libbrotli-dev \
    libwoff-dev

RUN wget https://github.com/mgieseki/dvisvgm/archive/2.8.2.tar.gz -O /tmp/dvisvgm.tar.gz \
    && tar -xzf /tmp/dvisvgm.tar.gz -C /tmp \
    && cd /tmp/dvisvgm-2.8.2 \
    && ./autogen.sh \
    && ./configure \
    && make \
    && sudo make install

Additional Comments

Also tried building from master in the hopes this was fixed, however ran into segfault issues.

Running 2.8.2 with increases verbosity, I see:

running Metafont for ecrm1200
WARNING: failed to create ecrm1200.gf

Passing in --keep --tmpdir=. I can see a file ecrm1200.2400.gf is generated in cases where the above warning is printed.

@mgieseki

This comment has been minimized.

Copy link
Owner

@mgieseki mgieseki commented Mar 2, 2020

I can't reproduce the issue on my machines at the moment. There is probably a write delay in your environment that prevents the GF file from being available immediately after the Metafont process has terminated. I'll try to reproduce it with docker later.
As a workaround, you could install the cm-super package from CTAN. It provides Type1 versions of the EC fonts which dvisvgm would use instead of the MF sources, if present.

@mgieseki mgieseki self-assigned this Mar 2, 2020
@noahnu

This comment has been minimized.

Copy link
Author

@noahnu noahnu commented Mar 2, 2020

I'll give that a try, thanks! What is the expected behaviour if the font fails to load? Should dvisvgm fail with an error exit code?

@mgieseki

This comment has been minimized.

Copy link
Owner

@mgieseki mgieseki commented Mar 2, 2020

It should probably exit with an error code but it does not yet. dvisvgm only emits a warning message about the missing font and continues normally. As a result, the affected font data is (partially) missing in the SVG.
BTW, the segfault you mentioned should be fixed in master. I forgot to push the changes committed two days ago.

@mgieseki mgieseki added the bug label Mar 2, 2020
@mgieseki

This comment has been minimized.

Copy link
Owner

@mgieseki mgieseki commented Mar 2, 2020

I'm not really sure if I understand the origin of this issue. However, I've added a fallback method to query the GF resolution value which is required to determine the correct name of the GF file. The changes are in the master branch. If possible, please check whether they fix the Metafont problem.

@mgieseki

This comment has been minimized.

Copy link
Owner

@mgieseki mgieseki commented Mar 5, 2020

Since commit 3489a4b should fix the issue, I close the ticket here. Feel free to open it again if the problem still persists.

@mgieseki mgieseki closed this Mar 5, 2020
@mgieseki mgieseki added this to the 2.9 milestone Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.