1

I'm trying to use a different font file just for the numerals in the text (that is, NOT in math mode), while keeping the rest of the text as is. The typeface I'm using lacks old-style numerals, so I would like to borrow them from a different font.

I know I can easily declare a new font and create a command about this, but that would mean going back and editing every place in the text where there are numbers (which would take a while).

So, is it possible to automate this process?

3
  • 1
    You need a combo font for this: tex.stackexchange.com/questions/371647/… – Henri Menke Feb 10 '19 at 20:34
  • I'm having a little bit of trouble understanding the commands in that post. – johnymm Feb 10 '19 at 21:41
  • Perhaps I'd have better luck if I directly modified the otf font files to include old-style figures---maybe through FontForge or something. – johnymm Feb 10 '19 at 21:44
3

Here’s a working example with combofont:

\documentclass[12pt,a5paper]{book}
\usepackage{combofont}
\setupcombofont{schneidler-regular}
 {
  {file:SchneidlerMed-Med.otf:\combodefaultfeat} at #1pt,
  {file:SchneidlerMedSC-Med.otf} at #1pt
 }
 {
   {} ,
   0x30-0x39
 }
\setupcombofont{schneidler-italic}
 {
  {file:SchneidlerAma-MedIta.otf:\combodefaultfeat} at #1pt,
  {file:SchneidlerAma-MedIta.otf} at #1pt
 }
 {
   {} ,
   0x30-0x39
 }
\DeclareFontFamily{TU}{schneidler}{}
\DeclareFontShape{TU}{schneidler}{m}{n}{<->combo*schneidler-regular}{}
\DeclareFontShape{TU}{schneidler}{m}{it}{<->combo*schneidler-italic}{}
\renewcommand{\rmdefault}{schneidler}% using \fontfamily{schneidler}\selectfont after \begin{document} would produce lining page numbers in Latin Modern
\linespread{1.103}
\begin{document}
URW’s version of Schneidler Medieval has its lowercase 1234567890 in a
separate, small caps font. This is far less inconvenient on \today\
than it was when I first acquired the type, since we now have
combofont.

\textit{There are no italic small caps, but the result is still
  pleasing, because the italic 1234567890 seem to be a hybrid of
  uppercase and lowercase figures.}
\end{document}

output

Because I’m not clever enough to combine my definition of schneidler-regular with an invocation of fontspec to select the italic, I defined schneidler-italic using the same font as both recipient and donor of glyphs. There may well be a better way of proceeding.

Standard ligatures were broken until I added \combodefaultfeat.

A Problem

The above worked because lowercase figures are the default in SchneidlerMedSC-Med.otf. But it’s not clear how to procede when lowercase figures exist in but are not the default of the donor font. Here, for instance, is a deliberately tasteless attempt to combine Punk Nova with Neo Euler:

\documentclass{standalone}
\usepackage{combofont,tikz}
\usetikzlibrary{calendar}
\setupcombofont{punk-regular}
 {
  {file:punknova-regular.otf:\combodefaultfeat} at #1pt,
  {file:euler.otf:+onum} at #1pt
 }
 {
   {} ,
   0x30-0x39
 }
\DeclareFontFamily{TU}{punk}{}
\DeclareFontShape{TU}{punk}{m}{n}{<->combo*punk-regular}{}
\renewcommand{\rmdefault}{punk}
\begin{document}
\tikz\calendar[dates=2019-02-01 to 2019-02-last,
               week list,month label above centered]
               if (Sunday) [purple];
\end{document}

output of second example

I’d have expected +onum to produce Neo Euler’s lowercase figures, but it didn’t. By playing with the luaotfload manual, I found this solution (there may be better ones):

\documentclass{standalone}
\usepackage{combofont,tikz}
\usetikzlibrary{calendar}
\def\feats{mode=base;+kern;+onum}
\setupcombofont{punk-regular}
 {
  {file:punknova-regular.otf:\combodefaultfeat} at #1pt,
  {file:euler.otf:\feats} at #1pt
 }
 {
   {} ,
   0x30-0x39
 }
\DeclareFontFamily{TU}{punk}{}
\DeclareFontShape{TU}{punk}{m}{n}{<->combo*punk-regular}{}
\renewcommand{\rmdefault}{punk}
\begin{document}
\tikz\calendar[dates=2019-02-01 to 2019-02-last,
               week list,month label above centered]
               if (Sunday) [purple];
\end{document}

output of third example

1
  • 1
    Very nice and my compliments. – Sebastiano Feb 17 '19 at 16:49

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.