2

I need to write a whole document with a specific font. My problem is that when I compile it seems to be working, but my pdf result has the original font. Nothing happened.

I have downloaded my .ttf font here, and I have installed it into my fonts folder in Windows 7 using drag and drop.

Then I have been using Xelatex compiler to compile this code :

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[a4paper]{letter}
\usepackage{xltxtra,fontspec,xunicode}
\setsansfont{Roboto-Regular}

\begin{document}

\begin{letter}{Letter}

\address{Address}

\opening{Dear Mr}

Some text here

\closing{\mbox{}}

\end{letter}
\end{document}

Any ideas? Do you think I missed something here?

  • 1
    \setmainfont, not \setsansfont. Avoid xltxtra and xunicode: fontspec is sufficient. – egreg Apr 18 '14 at 14:03
  • Thank you. So now I'll need to make all the compilation by going into "Tools"->"Compilation"->"Xelatex" ? Is there a way to do it faster? – hacks4life Apr 18 '14 at 14:08
  • It depends on what front-end you're using: is it TeXStudio? – egreg Apr 18 '14 at 14:18
  • I notice that with this method I can not use \textbf{} anymore to get my text into bold. Is that normal ? – hacks4life Apr 18 '14 at 14:18
  • 1
    For boldface you have to download also the corresponding bold font. – egreg Apr 18 '14 at 14:20
3

I installed the whole font family in my system folder and then modified your example into

% !TeX program = xelatex
% !TeX encoding = utf8

\documentclass[a4paper]{letter}

\usepackage{fontspec}
\setmainfont{Roboto}

\begin{document}

\begin{letter}{Letter}

\address{Address}

\opening{Dear Mr}

Some text here also \textbf{boldface}

\closing{\mbox{}}

\end{letter}
\end{document}

enter image description here

With the first two lines in the shown format, just pressing the “Build & View” button will choose XeLaTeX as the engine. The two “magic lines” you had are good for TeXShop, a Mac OS X only application.

  • Nice ! This is exactly what I was looking for. Thank you – hacks4life Apr 18 '14 at 14:38
  • Just to add something, I've modify my font into : \setmainfont[BoldFont=Roboto-Bold_0.ttf]{Roboto-Regular.ttf} – hacks4life Apr 18 '14 at 14:40
  • @FlorentP It's always difficult to say when Windows is involved, at least for me, because I know nothing about it. – egreg Apr 18 '14 at 14:43
  • hey, I have some difficulties on another question, du you have any ideas how I can figure out to do that ? tex.stackexchange.com/q/172600/48977 – hacks4life Apr 22 '14 at 8:43

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.