# Custom icon font not working with XeTeX/fontspec

I made a custom icon font using Fontself maker, that contains only few icons in the slots of latin characters. For this MWE I made a font Duck Face (download form my server) containg only a space char and the letter D which is a duck*.

% !TeX program = xelatex
\documentclass{scrartcl}

\usepackage{fontspec}
\newfontfamily\iconfont{Duck Face}

\begin{document}
\Huge
D
\par
\iconfont
D
\par
\end{document}


However the compilation fails with

Error 11 (driver return code) generating output;
file bfs-test.pdf may not be valid.
SyncTeX written on bfs-test.synctex.gz.
Transcript written on bfs-test.log.


But without further (understandable) error messages in the LOG. What is wrong with the the custom font? Or is XeTeX only capable of loading fonts containing a certain range of characters?

* The duck is taken from https://openclipart.org/detail/170850/cartoon-duck

– Tobi
Jul 5 '18 at 17:51
• Interesting! For me, it compiles without error but the PDF is empty (ie I am not able to open the file). I opened your font with FontForge and generated a TrueType font. Using this, everything works fine. So, I guess, there is something wrong with your font file. XeLaTeX is definitely fine with any range of characters. I already used my own icon fonts without any problems. Jul 5 '18 at 18:03
• if I use xelatex --no-pdf  it runs without error but xdvipdfmx on the resulting xdv file produces no output and reports [1]Segmentation fault (core dumped) which isn't good.... Jul 5 '18 at 18:04

FontForge’s fontlint reports:

A point in D is outside the font bounding box data.
ERROR      2 Self-intersecting glyph
ERROR      5 Missing points at extrema
ERROR     34 Bad 'CFF ' table
ERROR     80 Missing BlueValues entry in PostScript Private dictionary
FAIL         DuckFace.otf


Fortunately, FontForge can fix as well as report many errors. I’ve often fixed fonts by simply clicking File and Generate Fonts, thereby making a (repaired) copy under a different name. In this case, FontForge suggests the name DuckFaceRegular.otf, and the newly generated font works with both xetex and luatex:

\documentclass{scrartcl}
\usepackage{fontspec}
\newfontface\iconfont{DuckFaceRegular.otf}
\begin{document}
\Huge
D

\iconfont
D
\end{document}


Curiously, fontlint reports most of the same errors and some new ones in the newly generated font, but for reasons I don’t understand, they’re no longer fatal for compilation of a .tex file:

The advance width of space (290) does not match the font's advanceWidthMax (579) and this is a fixed pitch font
A point in D is outside the font bounding box data.
The advance width of uni00A0 (290) does not match the font's advanceWidthMax (579) and this is a fixed pitch font
ERROR      2 Self-intersecting glyph
ERROR      5 Missing points at extrema
ERROR     34 Bad 'CFF ' table
FAIL         DuckFaceRegular.otf

• Thanks this solved the issue. I contacted the developers of the Illustrator Extension I used to create the fonts, maybe it is a bug in their software or they can tell me what I did wrong … (see link to the Tweet in the comment below my question to stay tuned)
– Tobi
Jul 5 '18 at 21:59
xelatex --no-pdf file


runs without problems but when use

xdvipdfmx -vvv


to convert the resulting xdv file you get a segmentation fault and a log as below which gives several warnings about things wrong in the font file before it gives up:

<FONTMAP:/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/usr/local/texlive/2018/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/local/texlive/2018/texmf-dist/fonts/map/dvipdfmx/ckx.map>aa739 -> aa739.pdf
DVI File Info
Unit: 25400000 / 473628672
Magnification: 1000
Media Height: 42967693
Media Width: 28548252
Stack Depth: 5
Page count:     1
DVI Comment:  XeTeX output 2018.07.05:1902

DVI file font info
TeX Font: ./DuckFace.otf loaded at ID=   29, size=24.79pt (scaled 248.8%)
TeX Font: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf loaded at ID=   28, size=24.79pt (scaled 248.8%)
TeX Font: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf loaded at ID=   14, size=10.91pt (scaled 109.5%)
<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1</usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf@24.79pt<NATIVE-FONTMAP:/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf/0/H/65536/0/0>
fontmap: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf/0/H/65536/0/0 -> /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf(Identity-H)

pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf".
(CID:LMRoman17-Regular)
pdf_font>> Type0 font "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf/0/H/65536/0/0,0>.
><./DuckFace.otf@24.79pt<NATIVE-FONTMAP:./DuckFace.otf/0/H/65536/0/0>
fontmap: ./DuckFace.otf/0/H/65536/0/0 -> ./DuckFace.otf(Identity-H)

pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "./DuckFace.otf".
(CID:DuckFaceRegular)
pdf_font>> Type0 font "./DuckFace.otf" cmap_id=<Identity-H,0> opened at font_id=<./DuckFace.otf/0/H/65536/0/0,1>.
></usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf@10.91pt<NATIVE-FONTMAP:/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0>
fontmap: /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0 -> /usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf(Identity-H)

pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf".
(CID:LMRoman10-Regular)
pdf_font>> Type0 font "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf/0/H/65536/0/0,2>.
>]
otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf"...

otf_cmap>> Creating ToUnicode CMap for "./DuckFace.otf"...

otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf"...
(CID:/usr/local/texlive/2018/texmf-dist/fonts/opentype/public/lm/lmroman17-regular.otf[NRPACS+LMRoman17-Regular][CIDFontType0][2 glyphs][578 bytes])(CID:./DuckFace.otf[ARUFOD+DuckFaceRegular][CIDFontType0]