6

This is partially answered by other questions which the TeX search found for me, but not in a comprehensive manner.

I am a writer, not a mathematican or academic. I write fiction. So, my needs are only a subset of what TeX has to offer. I've already mastered what I need to know with pdfLaTeX and microtype. I can create and edit fonts, am licensed for a number of commerical fonts (such as Adobe Garamond Pro), and post-process the resulting PDF using Acrobat Pro.

Until now, I decomposed OpenType fonts into Type 1 with LY1 encoding, so that pdfLaTeX could understand them. Different OpenType style sets were decomposed to different fonts, which I called separately, each time I needed a particular style set. So far, so good. Understand that I do not use any of the TeX fonts, in any format.

Now I am trying to use LuaLaTeX to directly read OpenType fonts. The non-working features of microtype won't be a problem, as the working features in LuaLaTeX suffice for my needs. I already have LuaLaTeX working with a simple, sample document that uses an OpenType font but not any OpenType features.

I'll be darned if I can figure out how to select OpenType features. I've looked through available docs, and online here, for examples. What I've seen are some code examples that select a feature by common name, rather than by the 4-character style set designation. Example:

Numbers={OldStyle,Proportional},

But most style sets do not have a common name. So, what I do I do?

I'm looking for something like this (pseudo-code):

In the preamble:

\newcommand\useThisStyleSet[3]{opentype font name}{4-character style code}{string to be styled}

\newcommand\myStyle[1]{\useThisStyleSet{Adobe Garamond Pro}{c2sc}{$1}}

\newcommand\myOtherStyle[1]{\useThisStyleSet{Adobe Caslon Pro}{ss03}{$1}}

\newcommand\myNextStyle[1]{\useThisStyleSet{Source Sans Pro}{loca}{$1}}

In the document body:

\myStyle{The quality} of mercy \myOtherStyle{is not} \myNextStyle{strained.}
  • Welcome! Please provide a complete, minimal document we can compile. I assume you want to enable (groups of) raw features as explained in fontspec's manual, but it isn't clear to me whether that's what you mean by a 'style set' or not. – cfr Apr 14 '16 at 23:08
  • I'll get to work on the MWE. By "style set" I mean "OpenType font feature." I know which fonts have which features, and can examine their properties in FontForge. Each "font feature" is designated by a 4-character code. Some are standard, such as smcp for small caps, dlig for discretionary ligatures. But others are roll-your- own, and are designed such as ss01, ss02, cv01, cv02, cv03, loca, c2sc. There are many others. I can call them by code with using otftotfm by LCDF TypeTools, so I would hope to call them by code in LuaLaTex. – user103221 Apr 14 '16 at 23:49
  • Yes, they are 'raw features'. For those which have them, best to use the provided fontspec options. For the others, you have to use the raw feature code, as you say. But I don't see why this is a problem. You don't say why you can't do this. Have you tried reading the manual? – cfr Apr 15 '16 at 0:24
  • Was looking in the wrong manual (of course). Needed to look in fontspec, which I'd never previously used (new to LuaTeX). In any case, the list is shown in the answer below. The working examples I came across, prior to this, all referred to changing numerical style. – user103221 Apr 15 '16 at 14:20
6

Here’s an updated version of the summary I made for myself when I began using fontspec.

| tag  | fontspec option                      | comments                                            |
|------+--------------------------------------+-----------------------------------------------------|
| abvm | Diacritics=[No]AboveBase             | default                                             |
| afrc | Fractions=Alternate                  |                                                     |
| anum | Numbers=Arabic                       | luatex only: see manual §10.3                       |
| blvm | Diacritics=[No]BelowBase             | default                                             |
| c2pc | Letters=UppercasePetiteCaps          |                                                     |
| c2sc | Letters=UppercaseSmallCaps           |                                                     |
| calt | Contextuals=[No]Alternate            | default in xetex, not in luatex                     |
| case | Letters=Uppercase                    |                                                     |
| clig | Ligatures=[No]Contextual             | default                                             |
| cpsp | Kerning=Uppercase                    |                                                     |
| cswh | Contextuals=[No]Swash                |                                                     |
| cv01 | CharacterVariant=1                   | see manual §10.8                                    |
| dlig | Ligatures=Rare/Discretionary         |                                                     |
| dnom | VerticalPosition=Denominator         |                                                     |
| expt | CJKShape=Expert                      |                                                     |
| falt | Contextuals=[No]LineFinal            |                                                     |
| fina | Contextuals=[No]WordFinal            | has sometimes worked in xetex                       |
| frac | Fractions=On[/Off]                   |                                                     |
| fwid | CharacterWidth=Full                  | for Asian fonts                                     |
| halt | CharacterWidth=AlternateHalf         |                                                     |
| hist | Style=Historic                       |                                                     |
| hkna | Style=HorizontalKana                 |                                                     |
| hlig | Ligatures=Historic                   |                                                     |
| hwid | CharacterWidth=Half                  |                                                     |
| init | Contextuals=[No]WordInitial          | has sometimes worked in xetex                       |
| ital | Style=Italic                         |                                                     |
| jp78 | CJKShape=JIS1978                     |                                                     |
| jp83 | CJKShape=JIS1983                     |                                                     |
| jp90 | CJKShape=JIS1990                     |                                                     |
| kern | Kerning=On[/Off]                     | default                                             |
| liga | Ligatures=[No]Common                 | default                                             |
| lnum | Numbers=Uppercase/Lining             |                                                     |
| mark | Diacritics=[No]MarkToBase            | default                                             |
| medi | Contextuals=[No]Inner                | has sometimes worked in xetex                       |
| mkmk | Diacritics=[No]MarkToMark            | default                                             |
| nalt | Annotation=#…                        | see manual §10.14                                   |
| nlck | CJKShape=NLC                         |                                                     |
| numr | VerticalPosition=Numerator           |                                                     |
| onum | Numbers=Lowercase/OldStyle           |                                                     |
| ordn | VerticalPosition=Ordinal             |                                                     |
| palt | CharacterWidth=AlternateProportional |                                                     |
| pcap | Letters=PetiteCaps                   |                                                     |
| pnum | Numbers=Proportional                 |                                                     |
| pwid | CharacterWidth=Proportional          |                                                     |
| qwid | CharacterWidth=Quarter               |                                                     |
| rand | Letters=Random                       |                                                     |
| rlig | Ligatures=[No]Required               | default                                             |
| ruby | Style=Ruby                           |                                                     |
| salt | Style=Alternate or Alternate=…       | see manual §10.9                                    |
| sinf | VerticalPosition=ScientificInferior  |                                                     |
| size | SizeFeatures={…} and OpticalSize=…   | default for some fonts; see manual §§7.6, 8.6, 12.4 |
| smcp | Letters=SmallCaps                    |                                                     |
| smpl | CJKShape=Simplified                  |                                                     |
| ss01 | StylisticSet=1                       |                                                     |
| subs | VerticalPosition=Inferior            |                                                     |
| sups | VerticalPosition=Superior            | see also realscripts package                        |
| swsh | Style=Swash                          |                                                     |
| titl | Style=TitlingCaps                    |                                                     |
| tnum | Numbers=Monospaced                   |                                                     |
| trad | CJKShape=Traditional                 |                                                     |
| twid | CharacterWidth=Third                 |                                                     |
| unic | Letters=Unicase                      |                                                     |
| vkna | Style=VerticalKana                   |                                                     |
| zero | Numbers=[No]SlashedZero              |                                                     |

(Ignore the color, which is this web site taking my ASCII table for .tex source.)

Note that defaults may vary by script; see Khaled Hosny’s remarks at article.gmane.org/gmane.comp.tex.xetex/15187.

To judge from the manual at §28.0.12, there are also vertical kerning options, probably to be explained in §10.17.

Update

Since version 2.5c (2017/01/20), the fontspec manual also has a table; in version 2.6g (2017/11/09), it’s Table 2, on page 35.

  • That's what I needed to know. Now I can put it together what what I already knew, and get most of what I want. See MWE in my own answer, below. – user103221 Apr 15 '16 at 14:21
2

EDIT: Based on the accepted answer above, the following answer, and comments, I have been able to solve my problem in detail. Thanks, all! Here is a MWE showing how it works.

% !TeX program = LuaLaTeX
% !TEX encoding = UTF-8
\documentclass{article}
\usepackage{fontspec} % required with LuaLaTeX
\setmainfont[
  Ligatures=TeX,
  Numbers=Proportional, % but cannot use Monospaced as below
]{Adobe Garamond Pro}
\newfontfamily{\myCustom}[
  Ligatures=TeX,
]{RAcustom} % my own created opentype font
\newcommand\myFraktur{\addfontfeature{StylisticSet=1}} % only for \myCustom
\newcommand\myUncial{\addfontfeature{StylisticSet=2}} % only for \myCustom
\newcommand\myEmoticons{\addfontfeature{StylisticSet=3}} % only for \myCustom
\begin{document}
Hello {\myCustom world.} Here: {\myCustom\myEmoticons ^^^^46c7}
\end{document}

The above gives the expected output: "Hello " in AGaramondPro, "world." in RAcustom, "Here: " in AGaramondPro, and Unicode 46c7 (which would ordinarily be an Asian Han character) in RAcustom opentype feature ss03, which is a grin emoticon. Factoid: the Han character means "grin." I didn't want to use the full Unicode range beyond the BMP.

Thank you thank you thank you!

Image of output:

  • You don't need \selectfont. You just specify the font's name in place of LM Roman or whatever. (LM Roman is default if you load fontspec anyway.) Get the name from otfinfo. – cfr Apr 15 '16 at 16:14
  • Right, cfr. Done deal. – user103221 Apr 27 '16 at 23:36
1

The fontspec package easily takes care of most of your needs. Using \addfontfeatures should rarely be needed.

It's true that Latin Modern Roman doesn't honor the +scmp feature, but you can easily define the small caps font. Don't use LM Roman 12, but the generic family name.

\documentclass{article}
\usepackage{fontspec} % required with LuaLaTeX

\setmainfont[
  Numbers={Lining,Proportional},
  SmallCapsFont=Latin Modern Roman Caps,
]{Latin Modern Roman}

\newfontfamily{\oldstyle}[
  Numbers={OldStyle,Monospaced},
  SmallCapsFont=Latin Modern Roman Caps,
]{Latin Modern Roman}

\newfontfamily{\test}[
  Numbers={OldStyle,Proportional},
  SmallCapsFont=Latin Modern Roman Caps,
]{Latin Modern Roman}

\begin{document}

0123456789 {\oldstyle 0123456789} 0123456789

0123456789 Latin Modern Roman \emph{does} have small caps, so 
\textsc{This Text shows them}

{\oldstyle 0123456789 Latin Modern Roman \emph{does} have small caps, so 
\textsc{This Text shows them}}

{\test 0123456789 Latin Modern Roman \emph{does} have small caps, so 
\textsc{This Text shows them}}

\end{document}

enter image description here

  • Thanks, egreg. I am using licensed commerical fonts, not TeX fonts. The commercial fonts have all the OpenType features built into one font, not split among several fonts as with LM. The only reason I chose LM Roman 12 for the MWE was because most users wouldn't have the fonts I actually use. Good to know that if I ever need a TeX font, then I have to use the family name. You also pointed the way to using a second font, which was not the expected syntax from my previous non-Lua experience. – user103221 Apr 15 '16 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy