Specifying font size as x-height
How would one specify the font size in LMTX, but via x-height? I know this is a simple scaling, but I wonder if it could be done automatically? Sincerely, Stefan
How would one specify the font size in LMTX, but via x-height?
You could try this: \starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition Demo: \starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition \define[1]\sample{% \setxheight[#1][10pt] Hello% } \setuppapersize[letter, landscape] \starttext \dontleavehmode\rlap{\vrule width\textwidth height 10.5pt depth -10pt}% \processcommalist[modern, pagella, termes, heros, bonum, scholas, adventor, cursor, chorus, dejavu]\sample \stoptext This is kind of a hacky solution though. It works reasonably well, although there's likely a better (perhaps builtin?) way to do this. -- Max
Awesome, thank you very much Max!
On Sat, May 28, 2022 at 8:49 AM Max Chernoff
How would one specify the font size in LMTX, but via x-height?
You could try this:
\starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition
Demo:
\starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition
\define[1]\sample{% \setxheight[#1][10pt] Hello% }
\setuppapersize[letter, landscape]
\starttext \dontleavehmode\rlap{\vrule width\textwidth height 10.5pt depth -10pt}% \processcommalist[modern, pagella, termes, heros, bonum, scholas, adventor, cursor, chorus, dejavu]\sample \stoptext
This is kind of a hacky solution though. It works reasonably well, although there's likely a better (perhaps builtin?) way to do this.
-- Max
One slight problem is when I use 2\measured{xheight} as the font size I get
an error. \measure works fine though.
On Sat, May 28, 2022 at 9:34 AM Stefan Nedeljkovic
Awesome, thank you very much Max!
On Sat, May 28, 2022 at 8:49 AM Max Chernoff
wrote: How would one specify the font size in LMTX, but via x-height?
You could try this:
\starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition
Demo:
\starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \switchtobodyfont[#1, \cldcontext{tex.sp"#2" / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition
\define[1]\sample{% \setxheight[#1][10pt] Hello% }
\setuppapersize[letter, landscape]
\starttext \dontleavehmode\rlap{\vrule width\textwidth height 10.5pt depth -10pt}% \processcommalist[modern, pagella, termes, heros, bonum, scholas, adventor, cursor, chorus, dejavu]\sample \stoptext
This is kind of a hacky solution though. It works reasonably well, although there's likely a better (perhaps builtin?) way to do this.
-- Max
On 2022-05-28 2:27 a.m., Stefan Nedeljkovic wrote:
One slight problem is when I use 2\measured{xheight} as the font size I get an error. \measure works fine though.
The old version expected direct input, not a \dimen. Try this: \starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \scratchdimen=\dimexpr#2\relax \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition \definemeasure[xheight][2.5pt] \starttext \setxheight[adventor][10\measured{xheight}] Hello! \stoptext -- Max
Perfect, thank you very much Max!
On Sat, May 28, 2022 at 10:40 AM Max Chernoff
On 2022-05-28 2:27 a.m., Stefan Nedeljkovic wrote:
One slight problem is when I use 2\measured{xheight} as the font size I get an error. \measure works fine though.
The old version expected direct input, not a \dimen. Try this:
\starttexdefinition setxheight [#1][#2] \switchtobodyfont[#1, 12pt] \scratchdimen=\dimexpr#2\relax \switchtobodyfont[#1, \cldcontext{tex.dimen.scratchdimen / tex.sp"1ex" * tex.sp"1em" .. "sp"}] \stoptexdefinition
\definemeasure[xheight][2.5pt]
\starttext \setxheight[adventor][10\measured{xheight}] Hello! \stoptext
-- Max
participants (2)
-
Max Chernoff
-
Stefan Nedeljkovic