0

UPDATE

Not sure when it started working, but the steps I did were to 1.) fc-cache -v(r) and then add the path ...../texmf-dist/fonts/, 2.) then luaotfload-tool --update --verbose=. Not sure it was necessary but I then ran texhash and updmap -sys.


I am using Linux Mint, with new TeXLive (installed in special location) to try and compile this template I found. I've tried using the discussion in both, http://mirrors.concertpass.com/tex-archive/macros/latex/contrib/fontspec/fontspec.pdf and `How do I use a particular font for a small section of text in my document?'.

\documentclass{scrartcl}
\usepackage[nochapters]{classicthesis}
\usepackage[LabelsAligned,NoDate]{currvita}
  \renewcommand{\cvheadingfont}{\LARGE\color{Maroon}}
\usepackage{hyperref}
  \hypersetup{colorlinks,breaklinks,urlcolor=Maroon,linkcolor=Maroon}

\reversemarginpar

\newdimen\datebox
\newdimen\tempdima \tempdima0pt
\newdimen\maxdatedimen \maxdatedimen30pt%default value

\newcommand{\NewEntry}[2]{%
  \settowidth\tempdima{#1}%
  \ifdim\tempdima>\maxdatedimen%
   \global\maxdatedimen\the\tempdima\fi%
    \par\addvspace{0.5em}
    \noindent\hspace*{2em}%
    \parbox[t]{\datebox}{\strut\small\itshape #1}%
    \hspace*{1.5em}%
    \parbox[t]{\dimexpr\textwidth-2em-\datebox-1.5em+0em}{\strut #2}%
    \par\addvspace{0.5em}%
}

\newcommand{\MarginText}[1]{\marginpar{\raggedleft\itshape\small#1}}
\newcommand{\Description}[1]{%
  \par\noindent\hangindent=0em\hangafter=0
%  \par\noindent\hangindent=2em\hangafter=0
  {\noindent\ignorespaces\footnotesize #1\par}
%  {\raggedright\footnotesize #1\par}
  \vspace{1em}
  \par}

\usepackage{atveryend}

\makeatletter
\AtBeginDocument{%
  \settowidth{\datebox}{\hbox to \the\maxdatedimen{\hfil}}
  \maxdatedimen0pt}
\AfterLastShipout{%
  \if@filesw
    \immediate\write\@mainaux{%
      \global\string\maxdatedimen=\the\maxdatedimen\relax
    }%
  \fi}
\makeatother

\usepackage{fontspec}

% font file in same directory as .tex file
\newfontfamily\myfontt[]{FoglihtenPCS-068.otf}
\newenvironment{myfont}{\myfontt}{\par}

\usepackage{CormorantGaramond}
\newfontfamily\fMy[]{Cormorant Garamond Light}
\newcommand\fontMy[1]{{\fMy #1}}

\begin{document}

\begin{cv}{My name}\vspace{1.5em}

{\fontMy
Dear Human Resources,
}

\pagestyle{scrheadings}% using scrheadings page style

\section*{Personal Information}

\NewEntry{address}{XXXXX} 

\section*{Education}

\NewEntry{2015-2017}{{\myfontt \textbf{School of Data Analysis, Yandex}}}

\end{cv}

\end{document}

The template works fine but I wanted to use different fonts in various places. So, despite these two links being different ways to implement this (at least with syntax), I still couldn't get them to work - using for example Cormorant Garmond. I did add the extension and had fontspec so I can use the file name.

Perhaps I need to specify a search path explicitly? Or can I include an absolute path name to the file?

Here is the root of my TeXLive installation - /home/user/SW/TeXLive and the file I was looking for was found by;

X@X ~/SW/TeXLive/here/texmf-dist/fonts $ find . -name 'CormorantGaramond*.otf' -exec ls -Alrt {} \;
-rw-r--r-- 1 X X 775548 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-MediumItalic.otf
-rw-r--r-- 1 X X 780596 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-LightItalic.otf
-rw-r--r-- 1 X X 1129176 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-Regular.otf
-rw-r--r-- 1 X X 1135248 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-SemiBold.otf
-rw-r--r-- 1 X X 1119544 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-Bold.otf
-rw-r--r-- 1 X X 782440 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-RegularItalic.otf
-rw-r--r-- 1 X X 782208 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-SemiBoldItalic.otf
-rw-r--r-- 1 X X 1113548 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-Medium.otf
-rw-r--r-- 1 X X 760204 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-BoldItalic.otf
-rw-r--r-- 1 X X 1126740 Nov 25  2016 ./opentype/catharsis/cormorantgaramond/CormorantGaramond-Light.otf

The part of the MWE I'm trying to use is the stuff related to the Garamond font, just before the beginning of the document. I've had no real problems (despite some weird errors) using the other font, FoglihentPCS-068.otf, but that is because it is in the same directory - I'd rather use an absolute path.

I'm fine using either approach - an environment with \begin{myfont} \lipsum[3] \end{myfont} or just a {\fMy lipsum[3]} method, though I'd prefer the latter.

nate
  • 835
  • I don't know how LuaLaTeX handles the fonts, but are you sure it is included in your systems font cache? Can you use that font in another program (e.g., LibreOffice Writer)? – Skillmon Jan 13 '18 at 23:48
  • had to install Libre... it wasn't available... So maybe I have to do something like sym link the fonts to a cache location?... e.g https://community.linuxmint.com/tutorial/view/29 – nate Jan 13 '18 at 23:55
  • Oh, and in general you shouldn't call the fonts by the file name, but by the name as it would show up e.g. in LibreOffice (containing spaces). – Skillmon Jan 13 '18 at 23:56
  • Yes that would be a good first step. Then try again using the font names (not the file names). – Skillmon Jan 13 '18 at 23:58
  • Sure, I don't know how to get the name in linux, which is why I used fontspec.. But TeXLive is in a self-contained tree - I'd think it could find it's own fonts before my system fonts – nate Jan 13 '18 at 23:58
  • For the question of the self-contained installation I don't have enough inside into fontspec (I don't really use XeTeX or LuaTex). But I know, that it works with fonts contained in the font cache. "Cormorant Garmond" should be the name (I guess). – Skillmon Jan 14 '18 at 00:02
  • well during installation it created the symlinks, so where it is at shouldn't matter... - I'll try the link above – nate Jan 14 '18 at 00:06
  • 1
    To get the font name, use the following in your shell: fc-query <otf file name>, this should give you a list of meta data, including the names (look for fullname). – Skillmon Jan 14 '18 at 00:07
  • 1
    To find names, use otfinto -a myfontfilename.otf. Or look under Element → FontInfo in FontForge. Or search through texmf-var/luatex-cache/generic/names/luaotfload-names.lua.gz. Usually it’s straightforward, but if something is buggy, one of these three methods will suggest something useful. – Thérèse Jan 14 '18 at 00:08
  • Thanks - I didn't understand the example in fontspec.pdf example in section 1.1 – nate Jan 14 '18 at 00:17
  • 1
  • Use fontspec not fontenc. 2. `\newfontfamily{filename.otf} picks that one font file for ALL variations, such as italics and bold, but that's not what you want, is it? But \newfontfamily{font name} does the trick. 3. If LibreOffice can find the font, compiling with LuaLaTeX should also find it. Not sure why it hasn't found it. 4. It does not hurt to empty the folder luatex-cache, which will force new cache. Might not help, won't hurt.
  • –  Jan 14 '18 at 00:26
  • Yes, definitely \newfontfamily{font name}.. – nate Jan 14 '18 at 00:32