1

How and where to install .ttf fonts which I've already downloaded from web. I've created latex file using online overleaf. Inside same directory I put all my .ttf fonts and LuaLaTeX engine and everything works fine.

But, I have problem when I am using python to render same latex template. This is cmd which define where lualatex is installed on Ubuntu server, where to place latex file and third where latex template is situated. The aim of this is to create pdf from latex template.

cmd = "/usr/bin/lualatex -output-directory=/home/somepath/app/static/users_documents/" + str(
            user_id) + " /home/somepath/" + tex_file
        ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        output, err = ps.communicate()
        print(output, err, ps.returncode)

This is part of latex document where I define fonts

\documentclass[a4paper,10]{article}
\usepackage[zw32010,crossmark]{ticket}
\usepackage{graphicx}

\usepackage{fontspec}
\setsansfont{[Segoe_UI_Bold.ttf]}

\newfontfamily{\segoeui}{segoeui}[
    Extension=.ttf
]

\newfontfamily{\centuryItalic}{Century_Gothic_Italic}[
    Extension=.ttf
]

\newfontfamily{\segoeuiItalic}{Segoe_UI_Italic}[
    Extension=.ttf
]

\newfontfamily{\segoeuibold}{Segoe_UI_Bold}[
    Extension=.ttf
]

So, the question is how to enable lualatex from Ubuntu directory:

/usr/bin/lualtex

to see and use .ttf fonts?

I have to mention that I have only access to Ubuntu (16.04.3) command line.

This is part of the error:

luaotfload | load : unsupported font option: nil
luaotfload | cache : Lookup cache loaded from /home/milanp/.texmf-var/luatex-cac
he/generic/names/luaotfload-lookup-cache.luc.
luaotfload | db : Reload initiated (formats: otf,ttf,ttc,dfont); reason: "Font [
 not found.".
! LuaTeX error ...xmf-dist/tex/luatex/luaotfload/fontloader-basics-gen.lua:101: 
bad argument #1 to 'gsub' (string expected, got nil).
<to be read again> 
\scan_stop: 
l.7 \setsansfont
              {[Segoe_UI_Bold.ttf]}
? 
! Emergency stop.
  • I've used overleaf answer from frequently questions overleaf.com/learn/latex/Questions/… and as I can see we can use font in this form \setmainfont{[CrimsonText-Regular.ttf]} or \setmainfont{CrimsonText}[ Extension = .ttf, UprightFont = *-Regular, ...] – Matija Lukic Nov 7 '18 at 9:49
  • You could use the cwd= option for Popen(). Set it to the directory with your document and fonts. – Sergei Golovan Nov 7 '18 at 13:33
  • Thanks Sergei, but I've already resolved problem using Path in latex. – Matija Lukic Nov 7 '18 at 15:26
1

You should load the fonts like this:

\documentclass[a4paper,10]{article}

\usepackage{fontspec}
\setsansfont{Segoe_UI_Bold}[
  Extension   = .ttf,
  Path        = /path/to/fonts/
]

\newfontfamily{\segoeui}{segoeui}[
  Extension   = .ttf,
  Path        = /path/to/fonts/
]

\begin{document}

Something

\end{document}

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.