fontspec icon indicating copy to clipboard operation
fontspec copied to clipboard

`SmallCapsFeatures` parsing grows exponentially when interacting with `SizeFeatures` and friends

Open RuixiZhang42 opened this issue 3 years ago • 0 comments

Description

I was setting up a commercial type family with 3 optical sizes, and I tried to follow the “strict hierarchy” as written by the manual:

UprightFeatures =
 {
  SizeFeatures =
   {
    {
     Size = -10,
     Font = ...,
     SmallCapsFeatures = {...},
     ...
    },
    ...
   }
 }

The idea is that letter spacing for small caps should be different at various sizes. But SmallCapsFeatures parsing produces a lot of junk repetitions, and these repetitions grow “exponentially” (and are definitely not intended).

Check/indicate

  • [x] Relevant for XeTeX
  • [ ] Relevant for LuaTeX (maybe?)
  • [x] Issue tracker has been searched for similar issues?
  • [ ] Links to <tex.stackexchange.com> discussion if appropriate

Minimal example demonstrating the issue

\documentclass{article}
\usepackage{fontspec}
\setmainfont{texgyretermes-regular.otf}[
 UprightFeatures =
  {
   SizeFeatures =
    {
     {
      Size = -8,
      Font = texgyrepagella-regular.otf,
      SmallCapsFeatures = {LetterSpace=8}
     },
     {
      Size = 8-12,
      SmallCapsFeatures = {LetterSpace=5}
     },
     {
      Size = 12-15,
      Font = texgyreadventor-regular.otf,
      SmallCapsFeatures = {LetterSpace=3}
     },
     {
      Size = 15-,
      Font = texgyreadventor-regular.otf
      % no letter spacing small caps for 15pt or larger
     }
    }
  }
]
\begin{document}
hello
\end{document}

The relevant logs are alarming:

(fontspec)             - 'small caps'  (m/sc) with NFSS spec.:
(fontspec)             <-8>"[texgyrepagella-regular.otf]/OT:script=latn;languag
e=dflt;letterspace=8;+smcp;mapping=tex-text;"<8-12>"[texgyretermes-regular.otf]
/OT:script=latn;language=dflt;letterspace=8;letterspace=8;letterspace=5;+smcp;m
apping=tex-text;"<12-15>"[texgyreadventor-regular.otf]/OT:script=latn;language=
dflt;letterspace=8;letterspace=8;letterspace=5;letterspace=5;letterspace=3;+smc
p;mapping=tex-text;"<15->"[texgyreadventor-regular.otf]/OT:script=latn;language
=dflt;letterspace=8;letterspace=8;letterspace=5;letterspace=5;letterspace=3;let
terspace=3;+smcp;mapping=tex-text;"
  1. There are repetitions carried over from ALL previous size ranges.
  2. The 15- range is supposed to have no letter spacing small caps. But due to those repetitions we end up with letterspace=3.

RuixiZhang42 avatar Dec 12 '21 16:12 RuixiZhang42