mgieseki / dvisvgm

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

Problem with Text-Rendering #278

Open klartext opened 1 week ago

klartext commented 1 week ago

This little snippet from a checklist is rendered not correctly:

Lampe\\
Ohrenstöpsel\\
Zahnbürste\\

Results (from dvipdf and dvisvgm):

soll sein

klartext commented 1 week ago

Complete example:

\documentclass[12pt,twoside,DIV=12, twocolumn]{scrbook}
\usepackage[utf8]{inputenc}
\setlength{\parindent}{0em}

\begin{document}
Lampe\\
Ohrenstöpsel\\
Zahnbürste\\
\end{document}
mgieseki commented 1 week ago

I can't reproduce this at the moment. What's your version of dvisvgm? Please also add the command-line statement used to call dvisvgm. It's probably not an issue with dvisvgm but with the SVG renderer. I suggest to call dvisvgm with option --no-fonts or --font-format=woff2. Also see the the corresponding info in the FAQ.

klartext commented 1 week ago

Version: dvisvgm 3.4.2

With --no-fonts the output looks fine.

mgieseki commented 6 days ago

Ok, then it's actually an issue with the SVG viewer/renderer that can't handle embedded (SVG) fonts.

klartext commented 6 days ago

So, you mean sxiv and firefox both do the rendering wrong, and both wrong in the same way, but dvisvgm creates the correct output?

mgieseki commented 6 days ago

Yes. Both sxiv and Firefox don't support SVG fonts as created by default (see here for example). If you replace them with TTF, WOFF or WOFF2 fonts (using option --font-format), the SVG files should be rendered correctly. Alternatively, option --no-fonts replaces all glyphs by paths so that no fonts are used at all. But then text can't be searched or selected either. Apache Squiggle supports SVG fonts but none of the other formats. If you like, you could check your files with it too.

klartext commented 6 days ago

--font-format=woff2 does help for firefox, but not for sxiv. --no-fonts works for both.

klartext commented 6 days ago

From the overview page to the browser-support-table you referenced:

Method of using fonts defined as SVG shapes. Removed from SVG 2.0 and considered as a deprecated feature with support being removed from browsers.

Deprecated feature... ... I guess I will use --no-fonts by default then. The FAQ reads a bit like (my impression) "in the future, when browsers become better, they may support the fonts", but when it is deprecated, I don't think expecting this would make sense.

Regarding the searchability: isn't it possible to embed invisible text below the path that creates the text shape?

mgieseki commented 5 days ago

SVG fonts have been replaced in favor of WOFF in SVG 2.0 but they are still official part of SVG 1.1. Since all major browsers only support SVG 1.1, their implementation is incomplete. Anyway, this probably won't change because WOFF font support is more important in the context of web browsers than SVG fonts.

Regarding the searchability: isn't it possible to embed invisible text below the path that creates the text shape?

You could add transparent text behind the paths but that doesn't work well because it gets visible as soon as it's highlighted, e.g. in a search result or by user selection. Since the letters don't align with the visible glyphs, it looks cluttered. That's nothing I would like to implement.