Set section and subsection header to ttf font in KOMA-script

I'd like to set a custom font I acquired for all section and subsection headers in a scratcl paper I'm writing. It's a ttf and installed correctly on my Mac.

I know about \setkomafont and \addtokomafont, and I also have found the fontspec package, but all that seems to do is set the font for the entire document via \setmainfont, or for a section via \fontspec if I understand correctly.

I just can't seem to add one and one here, so to recap: how do I set (sub)section headers to a font installed on my Mac?

-

To use the system fonts you need to use xe(la)tex or lualatex instead of (pdf)latex. And with fontspec you can define a new family with \newfontfamily.

% I'm a UNICODE/UTF-8 encoded file!
\documentclass{scrartcl}

\usepackage{fontspec}
\newfontfamily\atfamily{American Typewriter}

% for testing
\usepackage{lipsum}

\begin{document}
\section{Test}
\subsection{Test}
\lipsum[1]
\end{document}


Save this file as UTF-8 file and compile it with xelatex then you’ll get this.

-
Thanks for answering! Also thanks for using \addtokomafont, I hate having to figure out sizes and stuff :) –  Zsub Mar 26 '12 at 10:44

If you want to use pdf(la)tex you will have to generate the various support files needed: metrics .tfm, encoding files, font definition files, map files, perhaps virtual font files.

With xelatex/lualatex you can use the font directly:

\documentclass{scrreprt}
\usepackage{fontspec,color}
\setkomafont{subsection}{\color{red}\fontspec{Times New Roman}}
\begin{document}
\chapter{Abc}
\section{text}
\subsection{text}
\end{document}

-
Thanks for answering! –  Zsub Mar 26 '12 at 10:42