# How to set expansion and protrusion for TeX Gyre Pagella using LuaLaTeX?

For my documents, I have often used the mathpazo package combined with microtype and have found the result to be really good. Because now I need to create PDFs which contain a variety of diacritics and which should be easy to copy from, I have decided to use LuaTeX with TeX Gyre Pagella.

Initially I had difficulty getting microtype to work, but thanks to Alabay's answer in How to set-up LuaTeX, Microtype, with Minion Pro, Myriad Pro I have made it. Still, I'm struggling with protrusion settings.

Given the following code:

\documentclass[a4paper, 12pt, oneside, article]{memoir}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newfontfeature{Microtype}{protrusion=default;expansion=default;}
\setmainfont[Microtype,Numbers=OldStyle]{TeX Gyre Pagella}
\usepackage{microtype}
\usepackage{blindtext}
\begin{document}
\blindtext
\end{document}


LuaTeX produces this:

I must say I don't quite like the fact that the punctuation marks protrude so far from the margin. Is there a way I can change the default settings? I have tried to do this in various ways (e.g. by changing factor in microtype), but to no success. Ideally, I would like to get a similar result as when I run pdfTeX with mathpazo:

Another (but related) thing is setting expansion for TeX Gyre Pagella. Can I do it, and if so, how?

-

You can change the default factor like this (5 is not a sensible value but shows the effect quite good:

\documentclass[a4paper, 12pt, oneside, article]{memoir}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newfontfeature{Microtype}{protrusion=default;expansion=default;}

\directlua{fonts.protrusions.setups.default.factor=5}
\setmainfont[Microtype,Numbers=OldStyle]{TeX Gyre Pagella}
\usepackage{microtype}
\usepackage{blindtext}
\begin{document}
\blindtext
\end{document}


For a more fine grained change you should copy the default table from otfl-font-dum.lua (fonts.protrusions.setups['default']). Move it to e.g. prottest.lua, change default to test, adapt the values and then use it like this:

\directlua{require("prottest.lua");}
\newfontfeature{Microtype}{protrusion=test;expansion=default;}


(I didn't test this recently so I'm not sure if this still works.)

-
Brilliant! Thank you so much! :) I have written 0.5 as the factor and the document already looks a whole lot better. Thanks to your code, it has also been easy to find a way of manipulating expansion – e.g. by writing \directlua{fonts.expansions.setups.default.stretch=1.5}. Now I'm happy with these basic changes, but might need the fine-tuning in the future, so I'm grateful for the additional information, too. –  jemp Mar 15 '12 at 18:34