feat: Support `\textsc` via small caps font `cmcsc10`
Fixes #471 , adding support for the \textsc command via the small caps font cmcsc10. Thanks to everyone who suggested solutions in the original thread. I'm willing to take this over the finish line, but will need a bit of assistance verifying that the changes I made are reasonable.
For future reference, these are the steps I needed to take (inside the dev container) to run the font generation scripts on my machine:
-
sudo apt install mftrace fontforge fonttools ttfautohint texlive-fonts-recommended(should these be added to the dev container?) - modify
src/fonts/Makefileto call perl withperl -I .since@INCno longer includes the current working directory in recent Perl versions -
sudo apt-get install python-pip -
pip install fonttools zopfli brotli -
./dockers/fonts/buildMetrics.sh -
cd src/fonts && make clean && make all
Output for \textsc{Lorem Ipsum Dolor}

Questions / Concerns:
- [ ] I'm not sure how to deal with combinations of font weight/shape/style (esp in
src/buildCommon.js). Not all combinations are valid, and I'm not sure what the desired priority is, so I made my best guess. - [ ] Should anything be added to
src/fonts/makeFForsrc/fonts/makeBolder? - [x] In the Chrome inspector, unchecking the "font-style" property of any text command (like
\textit,\textsc,\mathbf, etc.) causes the text to render as small caps. Why might this be? How to fix it? - [ ] What's the difference between
src/fonts/makeFFandsrc/metrics/mapping.pl? Is one generated from the other? Should they be kept in sync somehow? The changes I made to each were just my best guess. - [ ] How should the documentation be updated? I see some font prefetching instructions at
docs/browser.mdwhich I suspect will need to be updated with the new font. - [ ] All existing tests (jest and screenshots) pass on my machine. What kind of tests should be added for the new font and command?
Based on the failing automated test artifacts, the new small caps font overrides the default font in some cases. There are also some strange spacing issues. I'll investigate myself, but any help would certainly be appreciated. Thanks!
The new commit fixes the font override issue. According to the CSS spec, the font-variant property is not used by the font matching algorithm when determining which font to display. Instead, I created a separate font family for the smallcaps font.
The generated character mappings still need some attention, and the automated tests will reveal whether this fixed the spacing issues.
This PR is ready for review, no rush though. (the tasklist just has some questions that need attention before merging). The changes to font building at #2866 might also affect this PR.
Any update on this?
Yes please can someone please review this? Thanks @benrbray ❤️