commit 7f87d30878e97f839060d5fb030daad6ec51b7b3
parent ffd3b9ad8e6c895cb41cfcd8f57ed59e1ce0fb3d
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Thu, 13 Apr 2023 21:04:55 -0700
Font system WIP
Diffstat:
| A | font.tex | | | 391 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 391 insertions(+), 0 deletions(-)
diff --git a/font.tex b/font.tex
@@ -0,0 +1,391 @@
+% Default font size parameters. Layouts can define more if they wish (e.g.,
+% for titles, headers, etc.).
+\newdimen\Fhsize % default (horizontal mode)
+\newdimen\Ftsize % display and text
+\newdimen\Fssize % script
+\newdimen\Fzsize % script script
+
+\newdimen\Ftarget % Target size when searching font sets
+\newcount\Fscale % Used by Foptical; scales by this value divided by 1000
+
+\newdimen\Fbight
+\newdimen\FBight
+\newdimen\Fbigght
+\newdimen\FBigght
+
+\mathchardef\Fbigchar="0300
+\mathchardef\FBigchar="0310
+\mathchardef\Fbiggchar="0312
+\mathchardef\FBiggchar="0320
+
+\defevent[Fresize]
+\def\Fresize{\event[Fresize]}
+
+\def\FSnull{\let\Ffont=\nullfont}
+
+% Foptical is for use inside font sets
+% Usage: \Foptical[name_for_caching]{%
+% \\5:font_used_when_Ftarget_is_at_most_5 %<- Need space after each line
+% \\6:font_used_when_Ftarget_is_greater_than_5_and_at_most_6
+% \\7:font_used_when_Ftarget_is_greater_than_7_and_at_most_7
+% % Etc..
+% \\*:font_used_when_Ftarget_is_greater_than_all_previous % optional
+% }
+\def\Foptical[#1]#2{%
+ \ifcs#1@\the\Ftarget\endcs \else
+ \beggroup
+ \Fscale=1000
+ \let\Ffont=\nullfont
+ \let\\=\@Fopticalsearch #2%
+ \gcslet{#1@\the\Ftarget}\Ffont
+ \endgroup
+ \fi
+ \letcs\Ffont{#1@\the\Ftarget}%
+}
+\def\@Fopticalsearch#1:#2 {%
+ \if*#1%
+ \dimenA=\maxdimen
+ \else
+ \dimenA=\dimexpr#1pt\relax
+ \fi
+ \ifdim\dimenA<\Ftarget \else
+ \font\Ffont={#2}at\dimexpr\Ftarget*\Fscale/1000\relax
+ \let\\=\@Fopticalgobble
+ \fi
+}
+\def\@Fopticalgobble#1:#2 {}
+
+% Usage: \Fdef\myfont\FSmyfontset3.14pt
+\def\Fdef#1#2{\def\csA{#2\let#1=\Ffont}\afterassignment\csA\Ftarget=}
+
+\addhook[Fresize]{%
+ \lineht=.7\normalbaselineskip
+ \linedp=.3\normalbaselineskip
+}
+
+\def\Fsetfam{\afterassignment\@Fsetfam\countA=}
+\def\@Fsetfam#1#2#3{%
+ \gcsdef{FMt:\number\countA}{#1}%
+ \gcsdef{FMs:\number\countA}{#2}%
+ \gcsdef{FMz:\number\countA}{#3}%
+}
+
+% Initialize all 256 math families.
+% Need braces here to prevent expansion.
+\fornum\i="00.."FF+1\do{\Fsetfam\i{\FSnull}\FSnull\FSnull}
+
+\Fsetfam"00 \FSpnrutl\FSpnrutl\FSpnrutl
+\Fsetfam"01 \FSeurm\FSeurm\FSeurm
+\Fsetfam"02 \FSmpalsy\FSmpalsy\FSmpalsy
+\Fsetfam"03 \FSmpalexx\FSmpalexx\FSmpalexx
+\Fsetfam"04 \FSeuex\FSeuex\FSeuex
+\Fsetfam"05 \FSeurb\FSeurb\FSeurb
+\Fsetfam"06 \FSeusm\FSeusm\FSeusm
+\Fsetfam"07 \FSeusb\FSeusb\FSeusb
+\Fsetfam"08 \FSeufm\FSeufm\FSeufm
+\Fsetfam"09 \FSeufb\FSeufb\FSeufb
+\Fsetfam"0A \FSpmds\FSpmds\FSpmds
+\Fsetfam"0B \FSpnritl\FSnull\FSnull
+\Fsetfam"0C \FSpnbutl\FSnull\FSnull
+\Fsetfam"0D \FSpnbitl\FSnull\FSnull
+\Fsetfam"0E \FSmpalmia\FSmpalmia\FSmpalmia
+\Fsetfam"0F \FSmpalsym\FSmpalsym\FSmpalsym
+\Fsetfam"10 \FSmpalmi\FSmpalmi\FSmpalmi
+\Fsetfam"11 \FSmpalexa\FSmpalexa\FSmpalexa
+\Fsetfam"12 \FSmpalsyc\FSmpalsyc\FSmpalsyc
+\Fsetfam"13 \FSincr\FSincr\FSincr
+\Fsetfam"14 \FSincb\FSincb\FSincb
+\Fsetfam"15 \FSpslutl\FSpslutl\FSpslutl
+\Fsetfam"16 \FSpsrutl\FSpsrutl\FSpsrutl
+\Fsetfam"17 \FSpsmutl\FSpsmutl\FSpsmutl
+\Fsetfam"18 \FSpsbutl\FSpsbutl\FSpsbutl
+\Fsetfam"19 \FSrrrmpalwidecheck\FSrrrmpalwidecheck\FSrrrmpalwidecheck
+\Fsetfam"1A \FSpalr\FSpalr\FSpalr
+\Fsetfam"1B \FSpnrust\FSpnrust\FSpnrust
+\Fsetfam"1C \FSpnrist\FSpnrist\FSpnrist
+
+\addhook[Fresize]{%
+ \fornum\i="00.."FF+1\do{%
+ \Ftarget=\Ftsize \cs{FMt:\number\i}\textfont\i=\Ffont
+ \Ftarget=\Fssize \cs{FMs:\number\i}\scriptfont\i=\Ffont
+ \Ftarget=\Fzsize \cs{FMz:\number\i}\scriptscriptfont\i=\Ffont
+ }%
+}
+
+\def\Fupdatedelim#1#2{%
+ \setbox\boxA=\vbox{\hbox{$\m@th#2$}\kern0pt}%
+ #1=\dimexpr\ht\boxA/2 + \fontdimen22 \textfont2\relax
+}
+
+\addhook[Fresize]{%
+ \Fupdatedelim\Fbight\Fbigchar
+ \Fupdatedelim\FBight\FBigchar
+ \Fupdatedelim\Fbigght\Fbiggchar
+ \Fupdatedelim\FBigght\FBiggchar
+}
+
+\addhook[Fresize]{%
+ \Fdef\rmfont\FSpnrutl\Fhsize
+ \Fdef\fmfont\FSeufm\Fhsize
+ \Fdef\itfont\FSpnritl\Fhsize
+ \Fdef\bffont\FSpnbutl\Fhsize
+ \Fdef\bifont\FSpnbitl\Fhsize
+ \Fdef\trfont\FSincr\Fhsize
+ \Fdef\tbfont\FSincb\Fhsize
+ \Fdef\slfont\FSpslutl\Fhsize
+ \Fdef\srfont\FSpsrutl\Fhsize
+ \Fdef\smfont\FSpsmutl\Fhsize
+ \Fdef\sbfont\FSpsbutl\Fhsize
+ \Fdef\rmscfont\FSpnrust\Fhsize
+ \Fdef\itscfont\FSpnrist\Fhsize
+}
+
+\def\rm{\fam="00 \rmfont}
+\def\mi{\fam="01 }
+\def\sy{\fam="02 }
+\def\bm{\fam="05 }
+\def\hr{\fam="06 }
+\def\hb{\fam="07 }
+\def\fr{\fam="08 } \def\oldstyle{\fam=8 \fmfont}
+\def\fb{\fam="09 }
+\def\bb{\fam="0A }
+\def\it{\fam="0B \itfont}
+\def\bf{\fam="0C \bffont}
+\def\bi{\fam="0D \bifont}
+\def\tr{\fam="13 \trfont}
+\def\tb{\fam="14 \tbfont}
+\def\sl{\fam="15 \slfont}
+\def\sr{\fam="16 \srfont}
+\def\sm{\fam="17 \smfont}
+\def\sb{\fam="18 \sbfont}
+\def\rmsc{\fam="1B \rmscfont}
+\def\itsc{\fam="1C \itscfont}
+
+\def\tenpt{%
+ % Looser baselines and tighter display skips
+ \Fhsize=10pt \Ftsize=10pt \Fssize=7pt \Fzsize=5pt
+ \normalbaselineskip=12.5pt
+ \abovedisplayskip=8pt plus3pt minus5pt
+ \belowdisplayskip=8pt plus3pt minus5pt
+ \abovedisplayshortskip=0pt plus3pt
+ \belowdisplayshortskip=5pt plus3pt minus2pt
+ \Fresize
+}
+
+\def\ninept{%
+ \Fhsize=9pt \Ftsize=9pt \Fssize=6pt \Fzsize=5pt
+ \normalbaselineskip=11pt
+ \abovedisplayskip=7pt plus3pt minus5pt
+ \belowdisplayskip=7pt plus3pt minus5pt
+ \abovedisplayshortskip=0pt plus3pt
+ \belowdisplayshortskip=4pt plus3pt minus1pt
+ \Fresize
+}
+
+\beggroup
+\catcode`\_=11
+
+\foreach
+ n/nova
+ s/sans
+\do#1/#2 {%
+ \foreach
+ lu/light
+ li/light_italic
+ ru/regular
+ ri/regular_italic
+ mu/medium
+ mi/medium_italic
+ bu/bold
+ bi/bold_italic
+ \do##1/##2 {
+ \gcsdef{FSp#1##1tl}{\Foptical[p#1##1tl]{\\*:r3-palatino_#2-##2-tlf }}
+ \gcsdef{FSp#1##1to}{\Foptical[p#1##1to]{\\*:r3-palatino_#2-##2-tof }}
+ \gcsdef{FSp#1##1pl}{\Foptical[p#1##1pl]{\\*:r3-palatino_#2-##2-plf }}
+ \gcsdef{FSp#1##1po}{\Foptical[p#1##1po]{\\*:r3-palatino_#2-##2-pof }}
+ \gcsdef{FSp#1##1st}{\Foptical[p#1##1st]{\\*:r3-palatino_#2-##2-sc-tf }}
+ \gcsdef{FSp#1##1sp}{\Foptical[p#1##1sp]{\\*:r3-palatino_#2-##2-sc-pf }}
+ }
+}
+
+\gdef\FSpntit{\Foptical[pntit]{\\*:r3-palatino_nova-titling }}
+\gdef\FSpntits{\Foptical[pntits]{\\*:r3-palatino_nova-titling-sc }}
+
+\gdef\FSpnimp{\Foptical[pnimp]{\\*:r3-palatino_nova-imperial }}
+\gdef\FSpnimps{\Foptical[pnimps]{\\*:r3-palatino_nova-imperial-sc }}
+
+\gdef\FSpmds{\Foptical[pmds]{\\*:r3-palatino_math-ds }}
+
+\gdef\FSpalr{\Foptical[palr]{\\*:zpl-Regular-tlf-t1 }}
+
+\gdef\FSmpalmi {\Foptical[mpali]{\defaultskewchar127 \\*:zplmi }}
+\gdef\FSmpalmia{\Foptical[mpalia]{\defaultskewchar127 \\*:zplmia }}
+\gdef\FSmpalsy {\Foptical[mpalsy]{\defaultskewchar120 \\*:zplsy }}
+\gdef\FSmpalsym{\Foptical[mpalsym]{\\*:zplsym }}
+\gdef\FSmpalsyc{\Foptical[mpalsyc]{\\*:zplsyc }}
+\gdef\FSmpalexx{\Foptical[mpalexx]{\\*:zplexx }}
+\gdef\FSmpalexa{\Foptical[mpalexa]{\\*:zplexa }}
+
+\gdef\FSmpalbmi {\Foptical[mpalbi]{\defaultskewchar127 \\*:zplbmi }}
+\gdef\FSmpalbmia{\Foptical[mpalbia]{\defaultskewchar127 \\*:zplbmia }}
+\gdef\FSmpalbsy {\Foptical[mpalbsy]{\defaultskewchar120 \\*:zplbsy }}
+\gdef\FSmpalbsym{\Foptical[mpalbsym]{\\*:zplbsym }}
+\gdef\FSmpalbsyc{\Foptical[mpalbsyc]{\\*:zplbsyc }}
+\gdef\FSmpalbexx{\Foptical[mpalbexx]{\\*:zplbexx }}
+\gdef\FSmpalbexa{\Foptical[mpalbexa]{\\*:zplbexa }}
+
+\gdef\FSrrrmpalwidecheck{\Foptical[r3mpalwidecheck]{\\*:r3-widecheck }}
+
+% Inconsolata (not narrow and without variant 0, l, but with straight quotes)
+\gdef\FSincr{\Foptical[incr]{\Fscale1100 \\*:t1-zi4r-4 }}
+\gdef\FSincb{\Foptical[incb]{\Fscale1100 \\*:t1-zi4b-4 }}
+
+\gdef\FSeurm{\Foptical[eurm]{\defaultskewchar'177 \\6:eurm5 \\8.5:eurm7 \\*:eurm10 }}
+\gdef\FSeurb{\Foptical[eurb]{\defaultskewchar'177 \\6:eurb5 \\8.5:eurb7 \\*:eurb10 }}
+\gdef\FSeusm{\Foptical[eusm]{\defaultskewchar'60 \\6:eusm5 \\8.5:eusm7 \\*:eusm10 }}
+\gdef\FSeusb{\Foptical[eusb]{\defaultskewchar'60 \\6:eusb5 \\8.5:eusb7 \\*:eusb10 }}
+\gdef\FSeufm{\Foptical[eufm]{\\6:eufm5 \\8.5:eufm7 \\*:eufm10 }}
+\gdef\FSeufb{\Foptical[eufb]{\\6:eufb5 \\8.5:eufb7 \\*:eufb10 }}
+\gdef\FSeuex{\Foptical[euex]{\\7.5:euex7 \\8.5:euex8 \\9.5:euex9 \\*:euex10 }}
+
+\endgroup
+
+
+
+
+% Encoding stuff necessary for euler (see gkpmac.tex)
+% Actually, we take most non-letter symbols from newpx instead. This keeps
+% things consistent (since euler is somewhat incomplete) and easy (since
+% we needn't change many of the conventions from plain).
+
+% Take numerals from euler rm (default is fam 0)
+\mathcode`\0="7130
+\mathcode`\1="7131
+\mathcode`\2="7132
+\mathcode`\3="7133
+\mathcode`\4="7134
+\mathcode`\5="7135
+\mathcode`\6="7136
+\mathcode`\7="7137
+\mathcode`\8="7138
+\mathcode`\9="7139
+
+% Take certain symbols from euler sm/fm (default is cmsy)
+% \mathcode`\!="0821
+% \mathcode`\(="4828 \delcode`(="828300
+% \mathcode`\)="5829 \delcode`)="829301
+% \mathcode`\+="282B
+% \mathcode`\-="282D
+% \mathcode`\:="383A
+% \mathcode`\;="683B
+% \mathcode`\=="383D
+% \mathcode`\?="583F
+% \mathcode`\[="485B \delcode`[="85B302
+% \mathcode`\]="585D \delcode`]="85D303
+% \mathcode`\{="4666
+% \mathcode`\}="5667
+
+% Euler doesn't have these
+\let\varsigma=\sigma
+\let\varrho=\rho
+
+% Take uppercase Greek from euler rm (default is fam 0)
+\mathchardef\Alpha="0141
+\mathchardef\Beta="0142
+\mathchardef\Gamma="0100
+\mathchardef\Delta="0101
+\mathchardef\Epsilon="0145
+\mathchardef\Zeta="015A
+\mathchardef\Eta="0148
+\mathchardef\Theta="0102
+\mathchardef\Iota="0149
+\mathchardef\Kappa="014B
+\mathchardef\Lambda="0103
+\mathchardef\Mu="014D
+\mathchardef\Nu="014E
+\mathchardef\Xi="0104
+\mathchardef\Omicron="014F
+\mathchardef\Pi="0105
+\mathchardef\Rho="0150
+\mathchardef\Sigma="0106
+\mathchardef\Tau="0154
+\mathchardef\Upsilon="0107
+\mathchardef\Phi="0108
+\mathchardef\Chi="0158
+\mathchardef\Psi="0109
+\mathchardef\Omega="010A
+
+% TODO: arrows?
+\mathchardef\intop="1452
+\mathchardef\ointop="1448
+% \mathchardef\coprod="1460
+% \mathchardef\prod="1451
+\mathchardef\sum="1450
+% \mathchardef\braceld="047A \mathchardef\bracerd="047B
+% \mathchardef\bracelu="047C \mathchardef\braceru="047D
+% \mathchardef\infty="0431
+% \def\rbrace{\delimiter"5667409 }
+% \def\lbrace{\delimiter"4666408 }
+% \def\vert{\delimiter"066A30C }
+% \def\backslash{\delimiter"066E30F }
+
+\mathcode`\,="602C
+\mathcode`\.="002E
+\Umathcode`\/="0"10"3D
+\Umathcode`\<="3"10"3C
+\Umathcode`\>="3"10"3E
+\Umathcode`\=="3"1A"3D
+\Umathcode`\+="2"1A"2B
+\Umathchardef\star="2"10"3F
+\Umathchardef\ldotp="6"10"3A
+\mathchardef\nmid="3F2D
+\mathchardef\notto="3F39
+% \mathchardef\emptyset="029B
+\def\emptyset{{\mathpalette\@emptyset{}}}
+\def\@emptyset#1#2{\hbox{%
+ \Fdef\csA\FSmpalsy\dimexpr\Ftsize+1.5pt\relax \textfont2=\csA
+ \Fdef\csA\FSmpalsy\dimexpr\Fssize+1.5pt\relax \scriptfont2=\csA
+ \Fdef\csA\FSmpalsy\dimexpr\Fzsize+1pt\relax \scriptscriptfont2=\csA
+ $\m@th\sty#1\mathchar"029B$%
+}}
+\mathchardef\neq="3E3C
+\Umathchardef\notin="3"12"3C
+\Umathchardef\notsimeq="3"12"3B
+\def\Relbar{\mathrel{\mathchar"3E35}}
+\def\divides{\mid}
+\Umathchardef\ldbrack="4"12"7E
+\Umathchardef\rdbrack="5"12"7F
+\mathchardef\models="3F8F
+\mathchardef\notmodels="3F32
+\mathchardef\forces="3F8D
+\mathchardef\notforces="3F31
+\mathchardef\notprec="3F06
+\mathchardef\notpreceq="3F0E
+\mathchardef\notsucc="3F07
+\mathchardef\notsucceq="3F0F
+\mathchardef\notsubseteq="3F2A
+\mathchardef\notsupseteq="3F2B
+\mathchardef\surjto="3F90
+\mathchardef\symdiff="2234
+\mathchardef\Re="0852
+\mathchardef\Im="0849
+\Umathchardef\notsim="3"12"2F
+\mathchardef\transpose="0FFC
+\mathchardef\notleq="3F02
+\mathchardef\notgeq="3F03
+\mathchardef\notl="3F04
+\mathchardef\notg="3F05
+\def\grave{\mathaccent"029E }
+\def\acute{\mathaccent"029F }
+\def\hat{\mathaccent"02A0 }
+\def\tilde{\mathaccent"02A1 }
+\def\dot{\mathaccent"02A4 }
+\def\ddot{\mathaccent"02A5 }
+\def\ring{\mathaccent"02A6 }
+\def\check{\mathaccent"02A7 }
+
+
+
+\tenpt\rm
+
+\endinput