# How to validate a font to be used with XeLaTeX, fontspec

I have the following minimal document:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{jizura3b}
\begin{document}

\end{document}


The single character in the document should be displayed using the font as indicated; it is a font i have created myself using https://github.com/loveencounterflow/svgttf, which in turn uses https://github.com/fontello/svg2ttf to turn an SVG file into a TTF font.

Indeed, this works as expected on OSX and Tex Live 2013 and 2014; however, on Ubuntu using Tex Live 2015, i get a core dump:

This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex)
...
(/usr/local/texlive/2015/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(./test.aux) (/usr/local/texlive/2015/texmf-dist/tex/latex/tipa/t3cmr.fd)
[1] (./test.aux) )
Segmentation fault (core dumped)
(see the transcript file for additional information)
Error 35584 (driver return code) generating output;
file test.pdf may not be valid.
Transcript written on test.log.


Googling for the error number, 35584, would indeed indicate the error might be font-related, and this is exactly the conclusion i have come to, even though multiple apps on OSX and the Ubuntu Font Viewer all display the font fine without errors.

OTOH, this is not the first font i find that works OK everywhere except in XeLaTeX.

Given a font that XeLaTeX (or fontspec?) has troubles with, what are the recommended steps to test whether the fault is with XeLaTeX/fontspec or with the font?

Related: How to find out exactly what detail in the font makes LaTeX derail?

As an aside, I think that regardless whether the font is valid or not, LaTeX should not segfault but terminate with a helpful error message and an error code. As far as I can see no error code was emitted, so my tool chain ignored that problem at first; the only formal sign of there being a problem was that Segmentation fault (core dumped) was sent to stderr, not stdout.

• You can start determining whether it’s xetex or fontspec by trying to compile your MWE with luatex. If that fails too, you can get some idea whether fontspec is at fault by trying to use the font directly with luaotfload. Also try the fontlint tool that comes with Fontforge. – Thérèse Sep 26 '15 at 22:17
• Possibly you’ll be interested in tug.org/TUGboat/tb27-1/tb86piska.pdf – Thérèse Sep 29 '15 at 0:46

@Thérèse thanks for your tips indeed! I waited a bit too see whether more people would chime in, but since no other input has been made, I'll just report how I managed to resolve the issue.

First, replacing xelatex with luatex does indeed work. The downside of that, however, is that luatex takes quite some while longer for a run than does xelatex, so I looked further and tried fontlint; based on that, i used fontforge to repair the broken font. For comparison, first have a look at fontlint's outputs for the broken and the working font:

$fontlint <path to broken font> Copyright (c) 2000-2012 by George Williams. Executable based on sources from 14:57 GMT 31-Jul-2012-ML. Library based on sources from 14:57 GMT 31-Jul-2012. Missing required table: "post" Validation jizura3b ...Failed Self Intersecting Glyph Wrong Direction Missing Points at Extrema$ fontlint <path to working font>
Copyright (c) 2000-2012 by George Williams.
Executable based on sources from 14:57 GMT 31-Jul-2012-ML.
Library based on sources from 14:57 GMT 31-Jul-2012.
Validation jizura3b ...Failed
Self Intersecting Glyph
Wrong Direction
Missing Points at Extrema


You can see that while more than a single problem was reported, the essential one is really Missing required table: "post" (I'd really like FontForge repair all the defects, but didn't manage to get that).

Now the easiest way to make FontForge repair a font is to prepare a very short script in FontForge's scripting language, like this:

#!/usr/bin/fontforge -lang=ff
Print("Reading "+$1); Open($1);
Generate(\$1:r + ".rewritten-by-fontforge.ttf");


Save that under any name you like, make the file executable, call it with the path to the broken font, and presto.