Fonts & Character Setsuse package if font exists

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
AliceWonder
Posts: 28
Joined: Wed Oct 31, 2012 12:04 am

use package if font exists

Post by AliceWonder »

I have the Lucida Bright fonts.
I also have a custom package for the Lucida Mono font (different than typewriter, very much like the classic apple font Monaco)

Right now my LaTeX looks like this:

Code: Select all

\usepackage{lucidabr} %commercial Lucida Bright fonts
\usepackage{lucimono} %custom package for EF Lucida Mono
I would prefer it if LaTeX only loaded those packages if the actual fonts were available, so that people without them can still compile the document but using the default fonts.

How do I do that? I've seen it done before but my google skills are not finding it.

EDIT: using TL2012 if it matters

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

use package if font exists

Post by cgnieder »

Hi,

you could test for the existence of one of the basic font files needed with

Code: Select all

\IfFileExists{<filename>}{<then>}{<else>}
Regards
site moderator & package author
CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

use package if font exists

Post by CrazyHorse »

AliceWonder wrote: I also have a custom package for the Lucida Mono font (different than typewriter, very much like the classic apple font Monaco)

Right now my LaTeX looks like this:

Code: Select all

\usepackage{lucidabr} %commercial Lucida Bright fonts
I would prefer it if LaTeX only loaded those packages if the actual fonts were available, so that people without them can still compile the document but using the default fonts.
Your lucimono should test for the font definition file

Code: Select all

\IfFileExists{t1hlst.fd}{\def\ttdefault{hlst}}{}
Post Reply