-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Force-override sub/superscript metrics for 华文宋体 (STSong, Songti SC/TC) #7664
Description
Description
华文宋体 (aka. STSong, Songti SC/TC, 宋体-简/繁) is one of the default Chinese fonts on macOS.
When using #super or #sub with it, the text size becomes 1/10 of the original size, and can barely be noticed.
#set text(font: "Songti SC", 50pt)
国口#super[上标国口]#sub[下标国口]
// In the screenshot below, “n 像素” means n pixels on screen.
Workaround
Override metrics from the font.
#set super(size: 0.4em)
#set sub(size: 0.4em)
Importance
Non-typographic superscripts are common for Chinese (simplified) articles, because the national standard stipulates the citation format as [1], in which [ and ] usually do not have typographic variants.
This issue makes cite almost invisible.
#set text(font: "Songti SC", lang: "zh")
引用@key\根本看不清。
#bibliography(bytes("@article{key, title = {Title}}"), style: "gb-7714-2015-numeric")
More tests and analyses
All 8 versions of 华文宋体 in Songti.ttc shipped with macOS are affected.
Typst code
#set page(height: auto, width: auto, margin: 1em)
#set text(fallback: false)
#table(
columns: 2,
stroke: none,
align: start,
[#text(font: "Songti SC", weight: 300)[国口#super[国口]] Songti SC Light],
[#text(font: "Songti TC", weight: 300)[國口#super[國口]] Songti TC Light],
[#text(font: "STSong", weight: 300)[国口#super[国口]] STSong Regular], [],
// STSong is 300, yet the name is Regular. Also, its `glyf` table is identical to that of Songti SC Light (300).
[#text(font: "Songti SC", weight: 400)[国口#super[国口]] Songti SC Regular],
[#text(font: "Songti TC", weight: 400)[國口#super[國口]] Songti TC Regular],
[#text(font: "Songti SC", weight: 700)[国口#super[国口]] Songti SC Bold],
[#text(font: "Songti TC", weight: 700)[國口#super[國口]] Songti TC Bold],
[#text(font: "Songti SC", weight: 900)[国口#super[国口]] Songti SC Black],
)The default {sub,super}.size is 1 em × ({sub,super}script size in OS/2 table) / (unitsPerEm in head table).
According to the following, that's 1 em × 100 / 1000 = 0.1 em for 华文宋体.
$ ttx -t head -t OS/2 -o - Songti.ttc -y 0 | rg 'unitsPerEm|y(Sub|Super)script[XY]Size'
<unitsPerEm value="1000"/>
<ySubscriptXSize value="100"/>
<ySubscriptYSize value="100"/>
<ySuperscriptXSize value="100"/>
<ySuperscriptYSize value="100"/>Full ttx output
$ ttx -t head -t OS/2 -o - Songti.ttc -y 1
Dumping "Songti.ttc" to "<stdout>"...
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.53">
Dumping 'head' table...
<head>
<!-- Most of this table will be recalculated by the compiler -->
<tableVersion value="1.0"/>
<fontRevision value="2.002"/>
<checkSumAdjustment value="0x6da101a2"/>
<magicNumber value="0x5f0f3cf5"/>
<flags value="00000000 00001011"/>
<unitsPerEm value="1000"/>
<created value="Fri Nov 2 16:02:02 2012"/>
<modified value="Thu Jul 1 01:17:48 2021"/>
<xMin value="-140"/>
<yMin value="-305"/>
<xMax value="1068"/>
<yMax value="936"/>
<macStyle value="00000000 00000000"/>
<lowestRecPPEM value="12"/>
<fontDirectionHint value="1"/>
<indexToLocFormat value="1"/>
<glyphDataFormat value="0"/>
</head>
Dumping 'OS/2' table...
<OS_2>
<!-- The fields 'usFirstCharIndex' and 'usLastCharIndex'
will be recalculated by the compiler -->
<version value="2"/>
<xAvgCharWidth value="407"/>
<usWeightClass value="700"/>
<usWidthClass value="5"/>
<fsType value="00000000 00001000"/>
<ySubscriptXSize value="100"/>
<ySubscriptYSize value="100"/>
<ySubscriptXOffset value="0"/>
<ySubscriptYOffset value="150"/>
<ySuperscriptXSize value="100"/>
<ySuperscriptYSize value="100"/>
<ySuperscriptXOffset value="0"/>
<ySuperscriptYOffset value="650"/>
<yStrikeoutSize value="100"/>
<yStrikeoutPosition value="250"/>
<sFamilyClass value="0"/>
<panose>
<bFamilyType value="2"/>
<bSerifStyle value="1"/>
<bWeight value="6"/>
<bProportion value="0"/>
<bContrast value="4"/>
<bStrokeVariation value="1"/>
<bArmStyle value="1"/>
<bLetterForm value="1"/>
<bMidline value="1"/>
<bXHeight value="1"/>
</panose>
<ulUnicodeRange1 value="00000000 00000000 00000010 10000111"/>
<ulUnicodeRange2 value="00001000 00001111 00000000 00000000"/>
<ulUnicodeRange3 value="00000000 00000000 00000000 00000000"/>
<ulUnicodeRange4 value="00000000 00000000 00000000 00000000"/>
<achVendID value="SINO"/>
<fsSelection value="00000000 01000000"/>
<usFirstCharIndex value="32"/>
<usLastCharIndex value="127"/>
<sTypoAscender value="860"/>
<sTypoDescender value="-140"/>
<sTypoLineGap value="144"/>
<usWinAscent value="860"/>
<usWinDescent value="140"/>
<ulCodePageRange1 value="00000000 00000100 00000000 10011111"/>
<ulCodePageRange2 value="11011111 11010111 00000000 00000000"/>
<sxHeight value="446"/>
<sCapHeight value="695"/>
<usDefaultChar value="0"/>
<usBreakChar value="32"/>
<usMaxContext value="0"/>
</OS_2>
</ttFont>Perhaps 华文宋体 could be added to font/exceptions.rs?
华文楷体 (STKaiti), another typeface made by the same company, was issued in #4532 and added in #4616.
However, Exception currently does not support describing the sub/superscript sizes.
typst/crates/typst-library/src/text/font/exceptions.rs
Lines 10 to 15 in 846d5d0
| pub struct Exception { | |
| pub family: Option<&'static str>, | |
| pub style: Option<FontStyle>, | |
| pub weight: Option<FontWeight>, | |
| pub stretch: Option<FontStretch>, | |
| } |
Reference implementations
LaTeX/xeCJK/ctex does not have this issue.
TeX source
% !TeX program = xelatex
\documentclass{minimal}
\usepackage{xeCJK}
\setCJKfamilyfont{Songti SC Black}{Songti.ttc:0}
\setCJKfamilyfont{Songti SC Bold}{Songti.ttc:1}
\setCJKfamilyfont{Songti TC Bold}{Songti.ttc:2}
\setCJKfamilyfont{Songti SC Light}{Songti.ttc:3}
\setCJKfamilyfont{STSong Regular}{Songti.ttc:4}
\setCJKfamilyfont{Songti TC Light}{Songti.ttc:5}
\setCJKfamilyfont{Songti SC Regular}{Songti.ttc:6}
\setCJKfamilyfont{Songti TC Regular}{Songti.ttc:7}
\begin{document}
\begin{tabular}{ll}
{\CJKfamily{Songti SC Light} 国口\textsuperscript{国口}} Songti SC Light &
{\CJKfamily{Songti TC Light} 國口\textsuperscript{國口}} Songti TC Light
\\
{\CJKfamily{STSong Regular} 国口\textsuperscript{国口}} STSong Regular
\\
{\CJKfamily{Songti SC Regular} 国口\textsuperscript{国口}} Songti SC Regular &
{\CJKfamily{Songti TC Regular} 國口\textsuperscript{國口}} Songti TC Regular
\\
{\CJKfamily{Songti SC Bold} 国口\textsuperscript{国口}} Songti SC Bold &
{\CJKfamily{Songti TC Bold} 國口\textsuperscript{國口}} Songti TC Bold
\\
{\CJKfamily{Songti SC Black} 国口\textsuperscript{国口}} Songti SC Black
\end{tabular}
\end{document}Pages (the software made by Apple) does not have this issue either.
Reproduction URL
No response
Operating system
Windows, macOS
Typst version
- I am using the latest version of Typst
#8005 is a similar issue.