On 10/22/2026 3:45 AM, Jim Diamond via ntg-context wrote:

I find this interesting because of the fact that it is inside a group.  I
suppose if there is some \global\def inside \switchtobodyfont (or some
other use of \global} it would explain the effect.

yes, some things local, some things global, a \switch... assumes a \use... or \setup...
In that discussion, Hans and Wolfgang explained aspects of the relationship
between |\setupbodyfont|, |\usebodyfont|, and |\switchtobodyfont|.

In particular, Hans recommended preparing the required body-font families
before |\starttext|.

*2. April 2025* — Initializing a typeface inside a local group

indeed
https://lists.contextgarden.net/archives/list/[email protected]/thread/LRMIHD5PPSTDW2EOVBO76KHZJWS4HSPV/
 
<https://lists.contextgarden.net/archives/list/[email protected]/thread/LRMIHD5PPSTDW2EOVBO76KHZJWS4HSPV/>

In this exchange, Wolfgang explained that when a typeface is initialized for
the first time inside a local group, some settings may be lost when the
group ends.
 indeed
His suggested solution was to preload the relevant family globally, for
example:

\usebodyfont[dejavu] \setupbodyfont[modern]|

These discussions seem closely related to Jim's observations, although we
cannot assume that the underlying mechanism is necessarily identical in the
current LMTX implementation.

indeed

      _A possible first test?_

Jim, would you be willing to try explicitly preloading Schola in the
preamble?

For example:

\usefontpath[NCMS] \usebodyfont[newcomputermodern] \usebodyfont[schola]
\setupbodyfont[modern]|

Adding the \usebodyfont[schola] does indeed fix the problem, thanks.

Unfortunately, that apparently (?) means that one has to
         \usebodyfont[XYZ]
for every font in the document.  This is problematic and error-prone in a
large document which uses many fonts.

how many different fonts do you mix? a single font can en \definefont'd
Thus, while it is a pragmatic work-around, I feel that it is not an elegant
solution.

well, you can load later on, but don't do it in a group .. \tracingall at the top of your document can educate you on what happens with fonts
The remainder of your minimal example could remain unchanged, including the
grouped |\setbox0=\hbox{...}|line.

If the resulting |\showbodyfont[schola,8pt]|table becomes correct, this
would support the hypothesis that the problem is related to the first
initialization of Schola inside a local group.

Indeed.  And why would that be?

all depends on definitions being local, global, remembered, etc .. and also with having a system thst handles a lot and still has th be fast
Of course, it would not yet explain why preloading New Computer Modern seems
to influence the behaviour.

Indeed.  And why would that be?

when something is not found you are stuck with whatever font was active that time which then take sit place which of course is unpredictable

      _Comparing two LMTX releases:_

There is another experiment that might help distinguish an existing feature
of font initialization from a possible change introduced in a recent
release.

We could therefore compile the same minimal example under two different
ConTeXt releases:

Test    ConTeXt version         |\usebodyfont[schola]|
A       2026.10.01      Absent
B       2026.10.01      Present
C       2026.10.16      Absent
D       2026.10.16      Present

For the comparison to be meaningful, the same font files and identical
source code should be used, with separate caches and formats for each
installation.

So far my tests on three different stand-alone versions all show the same
results.

The version in TL2026 works, but I suspect that is because TL2026 has the
New CM fonts already included.  The log file indicates those files are
read, rather than the ones supplied in ./NCMS.

guess so, se eother mail: put them in a known spot, one where the system searches for 'otf' files (tds compliant ...)
It would also be useful to retain the original grouped construction in all
four tests:

{\setbox0=\hbox{\switchtobodyfont[schola] Schola!!!}}|

We could then perform a second comparison in which Schola is selected once
outside the group before this line is executed.

Several outcomes would be informative.

If the behaviour is identical in both releases, it may reflect an
established characteristic of font initialization and grouping.

If the anomaly occurs only with the October 16 release, we may have
identified a possible regression.

I think that turns out not to be the case.  Which is too bad, because if it
was we all know someone who would be keen to fix it.  ;-)

the font system (unless wolfgang finds a bug) will nto be made more complex thamn it already is (we might at some point remove non-compct mode code which is not used; even drop the design sizes as one can just define additional typescripts and so a switch)
If explicitly preloading Schola eliminates the anomaly in both versions, we
would at least have a reproducible workaround and a clearer indication of
where the problem originates.

You may have a clearer indication.  I remain boggled.  ;-)

One remaining question:

What I find particularly intriguing is the interaction between:

\usebodyfont[newcomputermodern]|

and the first local invocation of:

\switchtobodyfont[schola]|

Are we simply observing the consequences of delayed typeface
initialization within a TeX group, or is something else involved in the
way the different body-font collections are registered?

I look forward to someone answering that question.

Just think of what needs to be done if we load local. Do you really want to load all the stuff again and again when you do it in 50 boxes? Normally a choice for a font is global.
The earlier explanations from Hans and Wolfgang suggest a possible
direction, but I think the comparison between the two LMTX releases could
help us establish what is actually happening.

dunno, did font definition files change then? how do the logs compare (there's more than on the console)?
I haven't reproduced the anomaly myself, so these are hypotheses rather than
conclusions.

Lack of time or did the anomaly not happen for you?

Still, the experiments seem straightforward enough, and the results might
be useful to others working with several font families in the same
document.

Jim, perhaps an earlier ConTeXt release will prove useful for something more
interesting than simply keeping a stable installation at hand!

Not in this case, although keeping a stable installation certainly has some
benefits.

Many thanks to Wolfgang and Hans for their explanations, and to Jim for
providing such a revealing example.

Thanks for your thoughts and pointers to those other discussions.

Now, does the simple example i sent you work with fonts put in the right spot? No \hbox ... just a tufte test

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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to