Are fractional font sizes OK?
Hi all,
I have read (somewhere or other) that fractional point font sizes are ok.
(And pagella at 10.5pt is what was used for the "fr" translation of ANSS.)
For example, the following happily compiles into a nice PDF:
%%%%%%%%%%%%%%%% cut here %%%%%%%%%%%%%%%
\setupbodyfont[10.5pt]
\starttext
This is a line of pagella at 10.5pt.
%\switchtobodyfont[script] % Happiness in the world without this line.
Boom!
\stoptext
%%%%%%%%%%%%%%%% cut here %%%%%%%%%%%%%%%
However, if one uncomments the \switchtobodyfont line, the context run
fails with this:
-----------------------------------------------------------------------
...
fonts > 'fallback modern rm 10.5pt' is loaded
tex error > tex error on line 7 in file ./crash-and-burn.tex: Illegal unit of measure (pt inserted)
<to be read again>
\relax
<macro> \normalizebodyfontsize
#1#2->\scratchdimen \ifchkdimension #2\or \lastchkdimension \else #2
\dimexpr \fontbody \relax \fi \expandafter \let \expandafter #1\csname \??fontnormalizedbody \number \scratchdimen \endcsname \ifrelax #1\normalizebodyfontsize_indeed #1\fi
<macro> \font_helpers_define_unknown_check_sizes
#1#2->\ifcsname \??fontenvironments \s!default #2\endcsname \expandafter \normalizebodyfontsize \csname \??fontenvironments #1#2\endcsname {\csname \??fontenvironments \s!default #2\endcsname \dimexpr #1\relax }
\c_font_defining_state \conditionaltrue
<macro> \font_helpers_process_relative_size_list
#1->#1\v!big
#1\v!small
<macro> \font_helpers_define_unknown_font
#1->\font_helpers_register_fontbody {#1}\c_font_defining_state \conditionalfalse \font_helpers_process_relative_size_list {\font_helpers_define_unknown_check_sizes {#1}}
\ifconditional \c_font_defining_state \c_font_defining_state \conditionalfalse \f
<macro> \font_basics_switch_points
#1->\ifcsname \??fontbodyknown #1\endcsname \else \font_helpers_define_unknown_font {#1}
\fi \ifcsname \??fontbodyknown #1\endcsname \font_basics_complete_switch {#1}\localbodyfontsize #1\relax \normalizebodyfontsize \normalizedbodyfontsize \localbody
...
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim, just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines). If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size. Your sample compiles fine, even with such an unorthodox approach such as: \definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt] I hope it helps, Pablo
On 5/31/2026 12:05 PM, Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
In mkii times there we limnitation son the amount of fonts so we snapped sizes to 2 digits. In mkiv times that was less needed but still we snap in order not to get excessive definitions due to 'interesting usa cases'. In lmtx we scale differently but still one needs to be careful esp as bodyfont environments are expected to behave consistently. In principle we could discard some compatibility here but that is always tricky and as such some work from Wolfgang and me that we currently happily delay. Of course there are sentimental reasons for such a delay too. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Am 31.05.2026 um 12:49 schrieb Hans Hagen via ntg-context:
On 5/31/2026 12:05 PM, Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
In mkii times there we limnitation son the amount of fonts so we snapped sizes to 2 digits. In mkiv times that was less needed but still we snap in order not to get excessive definitions due to 'interesting usa cases'. In lmtx we scale differently but still one needs to be careful esp as bodyfont environments are expected to behave consistently.
In principle we could discard some compatibility here but that is always tricky and as such some work from Wolfgang and me that we currently happily delay. Of course there are sentimental reasons for such a delay too.
An easy way to fix this problem is to limit the number of allowed keywords to small and big. %%%% patch for font-ini.mklx % macros=mkvi \unprotect \protected\def\font_basics_switchtobodyfont#specification% {\edef\m_font_step{\font_bodyfontvariable{#specification}}% \font_push_x_size % experiment \ifempty\m_font_step \font_helpers_set_font\zerocount{#specification}% - \else + \orelse\ifinset{#specification}{\v!small,\v!big}% \font_helpers_switch_bodyfont_step % so we have a fast [small] switch \fi \expand\everybodyfont \expand\everyswitchtobodyfont \expand\everyfont \expand\everyfontswitch \font_pop_x_size % experiment } \protect \starttext text \switchtobodyfont[script] text \switchtobodyfont[10.5pt] \switchtobodyfont[script] text \switchtobodyfont[small] text \stoptext %%%% Wolfgang
On Sun, May 31, 2026 at 13:21 (+0200), Wolfgang Schuster wrote:
Am 31.05.2026 um 12:49 schrieb Hans Hagen via ntg-context:
On 5/31/2026 12:05 PM, Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
In mkii times there we limnitation son the amount of fonts so we snapped sizes to 2 digits. In mkiv times that was less needed but still we snap in order not to get excessive definitions due to 'interesting usa cases'. In lmtx we scale differently but still one needs to be careful esp as bodyfont environments are expected to behave consistently.
In principle we could discard some compatibility here but that is always tricky and as such some work from Wolfgang and me that we currently happily delay. Of course there are sentimental reasons for such a delay too.
An easy way to fix this problem is to limit the number of allowed keywords to small and big.
%%%% patch for font-ini.mklx % macros=mkvi
\unprotect
\protected\def\font_basics_switchtobodyfont#specification% {\edef\m_font_step{\font_bodyfontvariable{#specification}}% \font_push_x_size % experiment \ifempty\m_font_step \font_helpers_set_font\zerocount{#specification}% - \else + \orelse\ifinset{#specification}{\v!small,\v!big}% \font_helpers_switch_bodyfont_step % so we have a fast [small] switch \fi \expand\everybodyfont \expand\everyswitchtobodyfont \expand\everyfont \expand\everyfontswitch \font_pop_x_size % experiment }
\protect
\starttext
text \switchtobodyfont[script] text \switchtobodyfont[10.5pt] \switchtobodyfont[script] text \switchtobodyfont[small] text
\stoptext %%%%
Wolfgang, thanks, that does the trick in removing the error the 10.5pt/script situation. However, in my test it seems to ignore \switchtobodyfont[script] for the default font size. Is this intended? Perhaps getting an error message when asking for some undefined size like this is the correct thing, and the only requirement is a bit of education for users like me. Cheers. Jim
Am 01.06.2026 um 17:25 schrieb Jim via ntg-context:
On Sun, May 31, 2026 at 13:21 (+0200), Wolfgang Schuster wrote:
Am 31.05.2026 um 12:49 schrieb Hans Hagen via ntg-context:
On 5/31/2026 12:05 PM, Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
In mkii times there we limnitation son the amount of fonts so we snapped sizes to 2 digits. In mkiv times that was less needed but still we snap in order not to get excessive definitions due to 'interesting usa cases'. In lmtx we scale differently but still one needs to be careful esp as bodyfont environments are expected to behave consistently.
In principle we could discard some compatibility here but that is always tricky and as such some work from Wolfgang and me that we currently happily delay. Of course there are sentimental reasons for such a delay too.
An easy way to fix this problem is to limit the number of allowed keywords to small and big.
%%%% patch for font-ini.mklx % macros=mkvi
\unprotect
\protected\def\font_basics_switchtobodyfont#specification% {\edef\m_font_step{\font_bodyfontvariable{#specification}}% \font_push_x_size % experiment \ifempty\m_font_step \font_helpers_set_font\zerocount{#specification}% - \else + \orelse\ifinset{#specification}{\v!small,\v!big}% \font_helpers_switch_bodyfont_step % so we have a fast [small] switch \fi \expand\everybodyfont \expand\everyswitchtobodyfont \expand\everyfont \expand\everyfontswitch \font_pop_x_size % experiment }
\protect
\starttext
text \switchtobodyfont[script] text \switchtobodyfont[10.5pt] \switchtobodyfont[script] text \switchtobodyfont[small] text
\stoptext %%%%
Wolfgang,
thanks, that does the trick in removing the error the 10.5pt/script situation.
However, in my test it seems to ignore \switchtobodyfont[script] for the default font size. Is this intended?
Perhaps getting an error message when asking for some undefined size like this is the correct thing, and the only requirement is a bit of education for users like me.
AFAIK script (and scriptscript) isn't meant as a named size switch and only used in math mode. \setupbodyfontenvironment[30pt][script=25pt,scriptscript=20pt] \setupbodyfont[30pt] \starttext \dm{a_{\text{b}_{\text{c}}}} \setupbodyfontenvironment[30pt][script=20pt,scriptscript=10pt] \dm{a_{\text{b}_{\text{c}}}} \stoptext Wolfgang
On Mon, Jun 1, 2026 at 23:34 (+0200), Wolfgang Schuster wrote:
Am 01.06.2026 um 17:25 schrieb Jim via ntg-context:
On Sun, May 31, 2026 at 13:21 (+0200), Wolfgang Schuster wrote:
Am 31.05.2026 um 12:49 schrieb Hans Hagen via ntg-context:
On 5/31/2026 12:05 PM, Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
In mkii times there we limnitation son the amount of fonts so we snapped sizes to 2 digits. In mkiv times that was less needed but still we snap in order not to get excessive definitions due to 'interesting usa cases'. In lmtx we scale differently but still one needs to be careful esp as bodyfont environments are expected to behave consistently.
In principle we could discard some compatibility here but that is always tricky and as such some work from Wolfgang and me that we currently happily delay. Of course there are sentimental reasons for such a delay too.
An easy way to fix this problem is to limit the number of allowed keywords to small and big.
%%%% patch for font-ini.mklx % macros=mkvi
\unprotect
\protected\def\font_basics_switchtobodyfont#specification% {\edef\m_font_step{\font_bodyfontvariable{#specification}}% \font_push_x_size % experiment \ifempty\m_font_step \font_helpers_set_font\zerocount{#specification}% - \else + \orelse\ifinset{#specification}{\v!small,\v!big}% \font_helpers_switch_bodyfont_step % so we have a fast [small] switch \fi \expand\everybodyfont \expand\everyswitchtobodyfont \expand\everyfont \expand\everyfontswitch \font_pop_x_size % experiment }
\protect
\starttext
text \switchtobodyfont[script] text \switchtobodyfont[10.5pt] \switchtobodyfont[script] text \switchtobodyfont[small] text
\stoptext %%%%
Wolfgang,
thanks, that does the trick in removing the error the 10.5pt/script situation.
However, in my test it seems to ignore \switchtobodyfont[script] for the default font size. Is this intended?
Perhaps getting an error message when asking for some undefined size like this is the correct thing, and the only requirement is a bit of education for users like me.
AFAIK script (and scriptscript) isn't meant as a named size switch and only used in math mode.
And now that you point that out, it makes perfect sense. So I think (part of, at least) the answer to my original question ("what should I learn") is that while using \switchtobodyfont[script] may be expeditious in non-math mode, it really isn't the right thing to do.
\setupbodyfontenvironment[30pt][script=25pt,scriptscript=20pt]
\setupbodyfont[30pt]
\starttext
\dm{a_{\text{b}_{\text{c}}}}
\setupbodyfontenvironment[30pt][script=20pt,scriptscript=10pt]
\dm{a_{\text{b}_{\text{c}}}}
\stoptext
Thanks for the information and the example. Jim
On Sun, May 31, 2026 at 12:05 (+0200), Pablo Rodriguez via ntg-context wrote:
On 5/28/26 02:39, Jim via ntg-context wrote:
Hi all, […] What do I learn from this? (a) Fractional point font sizes are not a thing, and I shouldn't do that? (b) Fractional point font sizes may work, but are unreliable? (c) \switchtobodyfont[script] doesn't work with fractional point font sizes? (d) Something else entirely?
Hi Jim,
just use the source: lines 654-662 from contain the explanation (or I just found the fix reading those lines).
If you use non-predefined font sizes (not just fractional, `50pt` gives the same result), it seems that you have to setup the size.
Your sample compiles fine, even with such an unorthodox approach such as:
\definebodyfontenvironment[10.5pt] [script=\cldcontext{10.5*(7/12)}pt] \setupbodyfont[10.5pt]
I hope it helps,
Hi Pablo, Thanks for the information, that looks very helpful. I probably would never have thought of using an irrational font size, but your formula there makes me wonder about using square roots in a similar statement. :-) Jim
participants (4)
-
Hans Hagen -
Jim -
Pablo Rodriguez -
Wolfgang Schuster