# Use TeX Gyre fonts with latex+dvips+ps2pdf

I want to use the TeX Gyre fonts (especially the Pagella and Pagella Math) with LaTeX+dvips+ps2pdf. In the future I want to use this for PSTricks but first I've to solve my font problems.

I use this code for LaTeX+dvips+ps2pdf

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\begin{document}
Test in Pagella

$\sum_{k=1}^n k=\frac{n(n+1)}{2}$
\end{document}


It produces a PDF file with the text in TeX Gyre Pagella but the mathematics in Computer Modern (see screenshot)

When changing the code to the following

\documentclass{article}
\usepackage{fontenc,unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\setmathfont[Ligatures=TeX]{TeX Gyre Pagella Math}
\begin{document}
Test in Pagella

$\sum_{k=1}^n k=\frac{n(n+1)}{2}$
\end{document}


and processing it with LuaLaTeX in DVI-mode works well. But running dvips afterwards produces the following errors

This is dvips(k) 5.992 Copyright 2012 Radical Eye Software (www.radicaleye.com)
' LuaTeX output 2013.04.01:1811' -> template-pstricks.ps
kpathsea: Invalid fontname name:TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep;', contains ':'
dvips: Font name:TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep; not found; using cmr10

</usr/local/texlive/2012/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk>kpathsea: Invalid fontname name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1;', contains ':'

dvips: Font name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1; not found; using cmr10

</usr/local/texlive/2012/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk>
dvips: ! invalid char 119899 from font name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1;


I understand that dvips can't handle OpenType fonts, but how can I use the TeX Gyre Pagella and especially TeX Gyre Pagella Math together with PSTricks? Either LaTeX or LuaLaTeX solutions would be a great help.

-
Isn't XeLaTeX an option? It can run PSTricks directly. –  egreg Apr 1 '13 at 16:20
XeLaTeX would be my "worst case solution". But if there's a solution with LaTeX or LuaLaTeX, I'd enjoy much more. –  Stephan Lukasczyk Apr 1 '13 at 16:22
auto-pst-pdf? –  egreg Apr 1 '13 at 16:30

I've now solved the problem with adding auto-pst-pdf to the code

\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{fontenc,unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\setmathfont[Ligatures=TeX]{TeX Gyre Pagella Math}
\begin{document}
Test in Pagella

$\sum_{k=1}^n k=\frac{n(n+1)}{2}$
\end{document}


And compiling it with lualatex -shell-escape file.tex produces the following out put containing just TeX Gyre Pagella and TeX Gyre Pagella Math.

Great thanks to @egreg for providing this hint.

Improved due to @Ulrike Fischer's comment

There is obiously no way to solve the problem as I wanted, so I edited my code once again

\documentclass{article}
\usepackage{pstricks}
\usepackage{xltxtra}
\usepackage{xunicode}
\usepackage{fontenc}
\usepackage{unicode-math}
\setromanfont[Ligatures=TeX]{texgyrepagella-regular.otf}
\setmathfont[Ligatures=TeX]{texgyrepagella-math.otf}
\begin{document}
Test in Pagella

$\sum_{k=1}^n k=\frac{n(n+1)}{2}$

\begin{pspicture}(3,3)
\psline{->}(1,1)(3,2)
\psline{->}(1,1)(3,1)
\rput(2,2){$x$}
\end{pspicture}
\end{document}


Processing it with xelatex file.tex produces the wanted PDF-file, containing the TeX Gyre Pagella and Pagella Math

Thanks to @egreg and @Ulrike Fischer for their hints. More improvement is welcome, I think there's a lot to learn for me.

-
Well you are actually not making use of auto-pst-pdf in this example: It doesn't contain any pstricks pictures which try to use your fonts. As soon as you add them you will run in the same problem: auto-pst-pdf uses dvips+ps2pdf to convert the pictures, and dvips can't handle open type fonts. The only way to handle pstricks pictures which use open type fonts is to use xelatex. –  Ulrike Fischer Apr 1 '13 at 17:21
Thank you @UlrikeFischer. So my answer is not a real answer to my question, when using PSTricks. I'll try to get it work with XeLaTeX and improve to answer afterwards. –  Stephan Lukasczyk Apr 1 '13 at 17:52
Btw, is TikZ working with LuaLaTeX? –  Stephan Lukasczyk Apr 2 '13 at 15:08
Yes, TikZ works fine with lualatex. –  Ulrike Fischer Apr 2 '13 at 15:49