[Tex/LaTex] Custom font not loaded

xetex

I have an .otf font in same dir with .tex files. I'm using XeLaTex to work with this font, consider following code

 \documentclass[a4paper,12pt]{article}
 \usepackage[xetex]{graphicx}
 \usepackage{fontspec}
 \usepackage{xunicode}
 \usepackage{xltxtra}
 \usepackage[utf8]{inputenc}
 \usepackage[usenames,dvipsnames]{xcolor}
 \usepackage[T1]{fontenc}
 \usepackage{fullpage}
 \usepackage{csvtools}
 \usepackage{graphicx} 
  ...
  \begin{document}
   ...
     \begin{minipage}{84mm}
       \fontspec {Collator.otf}
       \sffamily 
       \centering
       \fontsize{32}{32} \textbf{\strut \insertName}
     \end{minipage}
   ...
   \end{document}

yields error

Font EU1/Collator.otf(0)/m/n/12=[Collator.otf]/ICU: at 12.0pt not loadable: Metric (TFM) file or installed font not found.

On \fontspec {Collator.otf} line, but it should find this font in project directory.

Is there any other options or I'm doing something wrong?

Best Answer

There are many problems with your document. See the following question for some basics about using XeLaTeX.

It is possible to use local fonts with XeLaTeX but you have to specify the path explicitly. See the following question for details.

Instead of using \fontspec directly, you should always define a new font family to load a font.

Here's a fixed version of your document.

% !TEX TS-program = XeLaTeX

\documentclass[a4paper,12pt]{article}

\usepackage{fontspec}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{fullpage}
\usepackage{csvtools} 
% This is obsolete and has been replaced by datatool
\usepackage{graphicx} 
\newfontfamily\collfont[Path=./]{Collator.otf}
\begin{document}
    \begin{minipage}{84mm}
      \collfont
      \sffamily 
      \centering
      \fontsize{32}{32} \textbf{\strut INSERT NAME}
    \end{minipage}
  \end{document}

output of code

Related Question