| 1 |
%%^^A%% fontspec-doc-luatex.tex -- part of FONTSPEC <latex3.github.io/fontspec> |
| 2 |
|
| 3 |
\documentclass[a4paper]{l3doc} |
| 4 |
\usepackage{fontspec-doc-style} |
| 5 |
\showexamplesfalse |
| 6 |
\begin{document} |
| 7 |
|
| 8 |
\part{\LuaTeX-only font features} |
| 9 |
\label{sec:luatex-features} |
| 10 |
|
| 11 |
\section{Different font technologies and shapers} |
| 12 |
\label{sec:renderer-luatex} |
| 13 |
|
| 14 |
\LuaTeX\ does not directly support any font rendering technologies out of the box, it |
| 15 |
requires additional functionality to be added to properly support and control technologies such as OpenType. |
| 16 |
|
| 17 |
Using the \feat{Renderer} feature, there are a number of options that \pkg{fontspec} can pass to the engine to control which font technology is being used. |
| 18 |
Pre-2019, there were two options provided by \pkg{luaotfload} that generally did not require user intervention. |
| 19 |
|
| 20 |
\begin{itemize} |
| 21 |
\item \feat{Renderer} = \opt{Node} : the default `mode' for typesetting OpenType fonts. |
| 22 |
\item \feat{Renderer} = \opt{Base} : a simplified mode useful only in a limited number of situations such as mathematics typesetting. |
| 23 |
\end{itemize} |
| 24 |
|
| 25 |
From 2019 the possibility of using the Harfbuzz text shaping engine within \LuaTeX\ has |
| 26 |
been developed by Khaled Hosny. When running a suitable \LuaTeX\ engine with Harfbuzz support, \pkg{fontspec} provides the following options: |
| 27 |
|
| 28 |
\begin{itemize} |
| 29 |
\item \feat{Renderer} = \opt{HarfBuzz} : use the Harfbuzz engine without an explicit `shaper' (the old \opt{Harfbuzz} name is kept for compatibility). |
| 30 |
\item \feat{Renderer} = \opt{OpenType} : use the Harfbuzz engine with the OpenType shaper. |
| 31 |
\item \feat{Renderer} = \opt{AAT} : use the Harfbuzz engine with the AAT shaper. |
| 32 |
\item \feat{Renderer} = \opt{Graphite} : use the Harfbuzz engine with the Graphite shaper. |
| 33 |
\item \feat{Renderer} = \meta{foo} : use the Harfbuzz engine with the \meta{foo} shaper. |
| 34 |
\end{itemize} |
| 35 |
|
| 36 |
Support for the Harfbuzz renderer is preliminary and may be improved over time. |
| 37 |
Please treat the interface for Harfbuzz fonts as subject to change. |
| 38 |
|
| 39 |
|
| 40 |
\section{Custom font features} |
| 41 |
|
| 42 |
\LuaTeX, via the \pkg{luaotfload} package, allows the definition and re-definition of custom OpenType features for a selected font. This facility is particularly useful to implement custom substitutions or to disable unwanted but not all ligatures. |
| 43 |
|
| 44 |
Figure~\ref{fig:featurefile} shows an minimal example of this type of functionality. |
| 45 |
This example creates a new OpenType feature, \texttt{oneb}, which substitutes the glyph |
| 46 |
when typesetting `\texttt{1}' for the named glyph \texttt{one.ss01}. The glyph names |
| 47 |
are font specific and can be interrogated with third-party software such as \emph{FontForge}. |
| 48 |
|
| 49 |
A third-party collection of additional examples are maintained in the repository `\texttt{fonts-in-luatex}'\footnote{\url{https://github.com/mewtant/fonts-in-luatex}}. |
| 50 |
These examples are intended to correct or adjust font features in a range of commercial fonts and provide a good introduction to some of the possibilities that \LuaTeX\ affords. |
| 51 |
|
| 52 |
Please refer to the \LuaTeX/\pkg{luaotfload} documentation for more details. |
| 53 |
|
| 54 |
\begin{figure} |
| 55 |
\caption{An example of custom font features.} |
| 56 |
\label{fig:featurefile} |
| 57 |
\hrule |
| 58 |
\begin{Verbatim} |
| 59 |
\documentclass{article} |
| 60 |
\usepackage{fontspec} |
| 61 |
\directlua{ |
| 62 |
fonts.handlers.otf.addfeature { |
| 63 |
name = "oneb", |
| 64 |
type = "substitution", |
| 65 |
data = { |
| 66 |
["1"] = "one.ss01", |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
\setmainfont{Vollkorn-Regular.otf}[RawFeature=+oneb] |
| 71 |
\begin{document} |
| 72 |
1234567890 |
| 73 |
\end{document} |
| 74 |
\end{Verbatim} |
| 75 |
\hrule |
| 76 |
\end{figure} |
| 77 |
|
| 78 |
\end{document} |
| 79 |
|
| 80 |
% /© |
| 81 |
% ------------------------------------------------ |
| 82 |
% The FONTSPEC package <latex3.github.io/fontspec> |
| 83 |
% ------------------------------------------------ |
| 84 |
% Copyright 2022-2025 The LaTeX project, LPPL "maintainer" |
| 85 |
% Copyright 2004-2022 Will Robertson |
| 86 |
% Copyright 2009-2015 Khaled Hosny |
| 87 |
% Copyright 2013 Philipp Gesang |
| 88 |
% Copyright 2013-2016 Joseph Wright |
| 89 |
% ------------------------------------------------ |
| 90 |
% This package is free software and may be redistributed and/or modified under |
| 91 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 92 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 93 |
% ------------------------------------------------ |
| 94 |
% ©/ |
| 95 |
|