1

I have a series of lectures using the same font settings and the same commands. One or two of these started not to compile on a certain computer. On two other computers I am using, in a directory environment which is guaranteed to be identical as the relevant locations are all contained in the same synchronised OneDrive folder, the same file compiles beautifully. Furthermore, on the same computer, other files using the same fonts and and the same settings and commands compile without problem.

Certain offending files, however, produce this error:

dvipdfmx:fatal: Invalid font: -1 (22)
No output PDF file written.

I am then advised to consult the xelatex.log file, in which I can find such lines that may contain relevant information:

2021-09-29 10:00:16,680+0200 INFO  xelatex - this process (11704) started by 'texstudio' with command line: xelatex.exe -synctex=1 -interaction=nonstopmode Waves-Optics-hu.tex
2021-09-29 10:00:16,683+0200 INFO  xelatex - this is MiKTeX-XETEX 4.5.0 (0.999993) (MiKTeX 21.8)
2021-09-29 10:00:16,690+0200 INFO  xelatex - allowing known shell commands
2021-09-29 10:00:22,626+0200 INFO  xelatex - executing input pipe: extractbb "--version"
2021-09-29 10:00:22,626+0200 INFO  xelatex.core - starting input pipe: extractbb "--version"
2021-09-29 10:00:22,627+0200 INFO  xelatex.core - start process: C:\Windows\system32\cmd.exe /c "extractbb "--version""
2021-09-29 10:00:25,346+0200 INFO  xelatex.core - start process: miktex-dvipdfmx.exe -q -E -o Waves-Optics-hu.pdf
2021-09-29 10:00:29,736+0200 FATAL xelatex.core - Invalid argument
2021-09-29 10:00:29,737+0200 FATAL xelatex.core - Function: fwrite
2021-09-29 10:00:29,737+0200 FATAL xelatex.core - Result: 22
2021-09-29 10:00:29,737+0200 FATAL xelatex.core - Data: <no data>
2021-09-29 10:00:29,737+0200 FATAL xelatex.core - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h:646
2021-09-29 10:00:29,738+0200 FATAL xelatex - Invalid argument
2021-09-29 10:00:29,738+0200 FATAL xelatex - Info: 
2021-09-29 10:00:29,738+0200 FATAL xelatex - Source: Libraries\MiKTeX\TeXAndFriends\include\miktex/C4P/C4P.h
2021-09-29 10:00:29,739+0200 FATAL xelatex - Line: 646
2021-09-29 10:00:29,742+0200 INFO  xelatex - this process (11704) finishes with exit code 1

I have tried to research the problem, and found two hits that may be relevant:

  • https://tug.org/pipermail/tex-live/2021-April/046700.html Well, I cannot claim I understand what they discuss here. I use MiKTeX, they refer to TexLive in a Linux environment. I could not locate any fontconfig files from which I could delete type1 lines, and to be honest, I dared not cleave round without understanding what I am doing. So even if it does contain the solution to my problem, I cannot proceed without further clarification.
  • XeLaTeX - Invalid Font: -1 This does not seem to align with my case as I do not use Type 1 fonts but OpenType and TrueType ones.

Due to the nature of the problem (compiling on most computers, not compiling on one, so it must be environment-dependent), I cannot produce an MWE, sorry. My font selection commands are the following:

% Fontspec font settings:
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro}[
Path = \FontsFolder/Minion Pro/,
Extension = .otf,
Scale = MatchLowercase,
UprightFont = MinionPro-Regular,
BoldFont = MinionPro-Bold,
ItalicFont = MinionPro-It,
BoldItalicFont = MinionPro-BoldIt,
SmallCapsFont = MinionPro-Regular]
\setsansfont{Open Sans}[
Path = \FontsFolder/open-sans/,
Extension = .ttf,
Scale = MatchLowercase,
UprightFont = OpenSans-Regular,
BoldFont = OpenSans-ExtraBold,
ItalicFont = OpenSans-Italic,
BoldItalicFont = OpenSans-ExtraBoldItalic]

Here \FontsFolder is a path to a folder within OneDrive for business, which has uneliminable space in it (E:\OneDrive - Szegedi Tudományegyetem\Fonts, to be specific). I used to have problems with that path until the latest MiKTeX updates, but since then, it seems to work correctly in all cases (with the probable exception of this one, if this is the problem).

Any help or suggestions are appreciated.

6
  • 1
    are you sure you are not using type1 fonts, do you have any type1 font directories in your fontconfig path Sep 29, 2021 at 9:07
  • Dear @David Carlisle , I am humiliated to admit that I do not know where to look. Can you advise me? Thank you. Sep 29, 2021 at 9:16
  • 1
    I don't know either (I don't use miktex and I don't know how it packages its version of fontspec, but a miktex user will be along soon I am sure:-) But that -1 error I have only seen when xetex access a font by name then xdvipdfmx finds a type1 version instead of the opentype. Sep 29, 2021 at 9:18
  • I have found it, I think. It is located in my personal config folder (C:\Users\tethe\AppData\Roaming\MiKTeX\fontconfig\config). There is a file called localfonts.conf. If I delete the line <dir>C:\Programs\MiKTeX\fonts\type1</dir> from it, the offending file seems to compile. I just need to take care NOT to refresh font map files in MiKTeX console, as it seems to write back the deleted type 1 line. Sep 29, 2021 at 9:32
  • 1
    can you post a self answer? Sep 29, 2021 at 9:54

1 Answer 1

2

Following David Carlisle's suggestion in the comments, I could make the file compile. As he said, the problem arises when XeTeX tries to access a font by name then xdvipdfmx finds a Type 1 version instead of the OpenType. I consulted his advice found at https://tug.org/pipermail/tex-live/2021-April/046700.html and I tried to localise the fontconfig path and in a Windows 10 environment in MiKTeX, I found it at C:\Users\<user name>\AppData\Roaming\MiKTeX\fontconfig\config (AppData is a hidden folder). There is a file called localfonts.conf, which needs to be edited. For me, the file looked like this:

<?xml version="1.0" encoding="UTF-8"?>

<!--
  DO NOT EDIT THIS FILE! It will be replaced when MiKTeX is updated.
  Instead, edit the configuration file localfonts2.conf.
-->

<fontconfig>
<include>localfonts2.conf</include>
<dir>C:\Users\tethe\AppData\Local\Microsoft\Windows\Fonts</dir>
<dir>C:\Windows\Fonts</dir>
<dir>C:\Program Files (x86)\Adobe\Acrobat Reader DC\Resource\Font</dir>
<dir>C:\Programs\MiKTeX\fonts\type1</dir>
<dir>C:\Programs\MiKTeX\fonts\opentype</dir>
<dir>C:\Programs\MiKTeX\fonts\truetype</dir>
</fontconfig>

There is the line that David Carlisle mentioned: <dir>C:\Programs\MiKTeX\fonts\type1</dir>.

This line needs to be deleted. Warning: do not run the Refresh font map function of MiKTeX console, as it rewrites the deleted line.

After this modification, the offending file compiles.

Update: Only after posting have I realised how stupid this looks, as the comment in localfonts.conf instructs me to edit localfonts2.conf. Editing that file whilst leaving localfonts.conf intact did not work for me, however. What worked was what I wrote above.

1
  • 1
    yes you can add new local directories with a localfonts config but I suspect that you can not remove directories that way. Sep 29, 2021 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.