5

I found several answers regarding windows, but nothing on Linux. I'm using Ubuntu and for right now, I simply want to use the fonts already installed on my computer for my PDF getting generated from a Tex document.

I found: Using multiple system fonts which shows me the TeX, but how do I get from the Ubuntu font to the font family?

Let's say that I want to use FreeOs font Sans Serif for my test.

Later I will want to install my own font and use that.

5

You can use otfinfo to get the proper name of fonts installed on your system.

For example,

otfinfo -i /usr/share/fonts/TTF/FreeSans.ttf 

provides the following information:

Family:              FreeSans
Subfamily:           Regular
Full name:           FreeSans
PostScript name:     FreeSans
Version:             Version 0412.2268 
Unique ID:           GNU: FreeSans Normal: 2012
Manufacturer:        GNU
Vendor URL:          https://savannah.gnu.org/projects/freefont/
Copyright:           Copyright 2002, 2003, 2005, 2008, 2009, 2010, 2012 GNU Freefont contributors.
License URL:         http://www.gnu.org/copyleft/gpl.html
License Description: This computer font is part of GNU FreeFont.  It is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this font.  If not, see 
    http://www.gnu.org/licenses/

As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
Vendor ID:           GNU

The full name, FreeSans, can then be used to set the document font:

\documentclass{article}
\usepackage{fontspec,kantlipsum}
\setmainfont{FreeSans}
\begin{document}
\kant[1]
\end{document}

Of course, this particular choice would obviously be a poor one since you should not set the body of your document in sans-serif. (Unless you are producing slides or something like that.) But it works for purposes of demonstration:

demo

You need to use either LuaLaTeX or XeLaTeX. The output above was compiled with LuaLaTeX which works much better for me than XeLaTeX.

I'm using TeX on GNU/Linux, so perhaps it is worth a word of warning about XeTeX.

If you try XeLaTeX, do not leave your computer during compilation just in case - XeLaTeX tends to hang and, at least for me, spins up the CPU in ways which quickly spiral out of control. While your OS should kill the process before your computer overheats, I personally prefer not to depend on this. Make sure that you know how to kill the process and have a terminal ready. If you are compiling from the command line, have a second terminal open as you cannot use the usual control characters to interrupt the process.

2

You must compile with XeLaTeX or LuaLaTeX. You should load fontspec, and write in your preamble

\setmainfont{FreeOs font Sans Serif}

or

\setsansfont{FreeOs font Sans Serif}

if you want to use it only as the default sans font.

Of course, this supposes you provide the exact name of the font, which is not the name of the .otf file in general.

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.