diff options
author | Holden Rohrer <hr@hrhr.dev> | 2020-07-06 18:20:32 -0400 |
---|---|---|
committer | Holden Rohrer <hr@hrhr.dev> | 2020-07-06 18:41:47 -0400 |
commit | a1d245cfd1979ec78bbc01e5125af80071f8cc42 (patch) | |
tree | 9bf0ec38631e4f0879940dc4a0b133d78fc2f17c /fmt/font.h | |
parent | 5a18c8a33b90003a2c930a207f766800883c3622 (diff) |
File reorganization
More makefile-friendly
Diffstat (limited to 'fmt/font.h')
-rw-r--r-- | fmt/font.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/fmt/font.h b/fmt/font.h new file mode 100644 index 0000000..54d4b54 --- /dev/null +++ b/fmt/font.h @@ -0,0 +1,50 @@ +%% Fonts +\newcount\thespacing +\newdimen\size +\begingroup + \edef\specialAt{{ \string a\string t }}% + \def\x#1{% + \def\getfontsize##1=##2{% The user level macro + \expandafter\getfontsizE\fontname##2#1\relax{##1}% + }% + \def\getfontsizE##1#1##2\relax##3{% + \ifx*##2*% Loaded at designsize + \begingroup + \font\tmpfont"##1" scaled 2000 + \getfontsize\dimen0=\tmpfont + \divide\dimen0 by 2 + \expandafter + \endgroup + \expandafter\getfontsiZe\the\dimen0\relax{##3}% + \else% Otherwise #2 holds the size. But is is followed by " at ", so we have to strip that + \getfontsiZE{##3}##2% + \fi + }% + \def\getfontsiZE##1##2#1{##1=##2}% Strip " at " + \def\getfontsiZe##1\relax##2{##2=##1} + } + \expandafter\expandafter\expandafter +\endgroup +\expandafter\x\specialAt % From StackOverflow +{ +\catcode`\@=11 + +\global\let\f@nt\font + +\gdef\spacing{ + \afterassignment\adjs \thespacing} +\gdef\adjs{%adjust spacing + \baselineskip=\size \multiply\baselineskip by \thespacing + \divide\baselineskip by 100\relax} + +\gdef\font#1{% + \def\orig{#1}\edef\realname{\csname\string#1@font\endcsname} + \afterassignment\xfont + \expandafter\f@nt\realname +} +\gdef\xfont{ + \expandafter\getfontsize\expandafter\dimen0\expandafter=\realname + \expandafter\expandafter\expandafter\def + \expandafter\orig\expandafter{\realname\size\dimen0\adjs} +} +} |