4

Using XeLaTeX, how can I use a font that I have downloaded in a folder, but have not installed on my system? I have tried to specify the path in setmainfont{Path = C:/MyFolder/MyFonts/, but I receive the error message fontspec error: "font-not-found"

Based on what I have found googling, I have tried these options, but they all give the same error message:

\setmainfont{Path = C:/MyFolder/MyFonts/}{LinLibertine_Rah.ttf}
\setmainfont{Path = C:/MyFolder/MyFonts/LinLibertine_Rah.ttf}
\setmainfont{Path = C:/MyFolder/MyFonts/}{LinLibertine}
\setmainfont{Path = C:/MyFolder/MyFonts/LinLibertine}
\setmainfont{Path = C:/MyFolder/MyFonts/}{Linux Libertine}
\setmainfont{Path = C:/MyFolder/MyFonts/Linux Libertine}
\setmainfont[Path = C:/MyFolder/MyFonts/]{LinLibertine_Rah.ttf}
\setmainfont[Path = C:/MyFolder/MyFonts/LinLibertine_Rah.ttf]
\setmainfont[Path = C:/MyFolder/MyFonts/]{LinLibertine}
\setmainfont[Path = C:/MyFolder/MyFonts/LinLibertine]
\setmainfont[Path = C:/MyFolder/MyFonts/]{Linux Libertine}
\setmainfont[Path = C:/MyFolder/MyFonts/Linux Libertine]
6
  • Shouldn't path in Windows be using backslashes as directory delimiters? Should it be C:\MyFolder\Myfonts\ ?
    – ArTourter
    Jul 18 '12 at 21:56
  • 2
    I tried (on win xp with miktex 2.9.) \setmainfont[Path = J:/Install/Schriften/]{Inconsolata.otf} and the font was found. Are your folders really called "MyFolder" and "MyFonts" or do the real names contain things like space or unusual chars which could lead to problems? Jul 19 '12 at 9:16
  • 1
    I've stopped using spaces in names of folders and files, and replaced them with underscores. It turns out that was what XeTeX couldn't read. Once I removed the underscores, it worked.
    – Sverre
    Jul 19 '12 at 14:15
  • 1
    @Sverre: Don't edit the answer into the question. Leave the original question and add the answer with the "Your answer" form below. Answering your own questions is explicitly encouraged.
    – Caramdir
    Jul 19 '12 at 15:53
  • 1
    @ArTourter: For many years, Windows accepts paths with /. Jul 19 '12 at 20:00
9

Based on the comments and suggestions I received, I'm providing the solution here.

\setmainfont[   Path              = C:/MyStuff/Fonts/LinLibertineTTF/,
                Extension         = .ttf,
                BoldFont          = LinLibertine_RBah,
                ItalicFont        = LinLibertine_RIah,
                BoldItalicFont    = LinLibertine_RBIah,
                SmallCapsFeatures = {Letters = SmallCaps},
                Numbers           = OldStyle
            ]{LinLibertine_Rah}

Avoid spaces and underscores in your path.

6

Did you try to change the first set of curly brackets to square brackets? That is:

\setmainfont[Path=C:/MyFolder/MyFonts/]{LinLibertine_Rah.ttf}

See Fontspec documentation v2.2b, pp. 7–8.

3
  • I've tried it now - and added the attempts to my question.
    – Sverre
    Jul 18 '12 at 20:51
  • @Sverre It may be that fontspec does not parse windows-like path specifications. The following example works on my linux box. \documentclass{article} \usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text} \setmainfont[ExternalLocation=./randomFolder/]{ZnikomitNo24} \begin{document} Text. \end{document}
    – Ekin
    Jul 18 '12 at 21:12
  • @Sverre I agree with Ekin. Presumably if you have a file at C:/MyFolder/MyFonts/LinLibertine_Rah.ttf then your (currently) 7th example should have worked. Your other attempts are largely gibberish. Jul 19 '12 at 5:42

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.