Skip to content

feat: Support \textsc via small caps font cmcsc10#3085

Open
benrbray wants to merge 3 commits intoKaTeX:mainfrom
benrbray:master
Open

feat: Support \textsc via small caps font cmcsc10#3085
benrbray wants to merge 3 commits intoKaTeX:mainfrom
benrbray:master

Conversation

@benrbray
Copy link
Copy Markdown

@benrbray benrbray commented Jun 17, 2021

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/Makefile to call perl with perl -I . since @INC no 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}

image

Questions / Concerns:

  1. 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.
  2. Should anything be added to src/fonts/makeFF or src/fonts/makeBolder?
  3. 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?
  4. What's the difference between src/fonts/makeFF and src/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.
  5. How should the documentation be updated? I see some font prefetching instructions at docs/browser.md which I suspect will need to be updated with the new font.
  6. All existing tests (jest and screenshots) pass on my machine. What kind of tests should be added for the new font and command?

@benrbray
Copy link
Copy Markdown
Author

benrbray commented Jun 17, 2021

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!

@benrbray
Copy link
Copy Markdown
Author

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.

@benrbray benrbray changed the title Support \textsc via small caps font cmcsc10 feat: Support \textsc via small caps font cmcsc10 Jun 18, 2021
@benrbray
Copy link
Copy Markdown
Author

benrbray commented Jul 6, 2021

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.

@RexYuan
Copy link
Copy Markdown

RexYuan commented Jun 24, 2023

Any update on this?

@RexYuan RexYuan mentioned this pull request Jun 24, 2023
@yuvaltassa
Copy link
Copy Markdown

Yes please can someone please review this?
Thanks @benrbray ❤️

@edemaine edemaine force-pushed the main branch 8 times, most recently from 9a985be to 0ef8921 Compare January 25, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support small caps

3 participants