ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] how to reset and switch fallbackfont?
@ 2025-02-28 12:21 autumnus 
  2025-03-02 19:10 ` [NTG-context] " Wolfgang Schuster
  2025-03-03 13:00 ` Hans Hagen
  0 siblings, 2 replies; 5+ messages in thread
From: autumnus  @ 2025-02-28 12:21 UTC (permalink / raw)
  To: ntg-context

hi,

As described in the title, how to reset fallbackfont?

I have created a number of Chinese typescripts and related fallbackfont (latin).

However, in the actual operation process, 
I found that if you want to switch different fallbackfont, 
you must change the bodyfont at the same time (\setupbodyfont).

The following is an example. 
How should I reset and switch to fallbackfont without changing the bodyfont?

%%%%%%%

\definefontfeature[zh][mode=node,script=hang,lang=zhs]
 
\startsetups fallbacks:reset
  \resetfontfallback[serifwhatever]
  \resetfontfallback[serifboldwhatever]
  \resetfontfallback[serifitalicwhatever]
  \resetfontfallback[serifbolditalicwhatever]
\stopsetups

\startsetups fallback:lm
 \definefontfallback[serifwhatever]          [lmroman10-regular]   [0x0000-0x0400][force=yes]
 \definefontfallback[serifboldwhatever]      [lmroman10-bold]      [0x0000-0x0400][force=yes]
 \definefontfallback[serifitalicwhatever]    [lmroman10-italic]    [0x0000-0x0400][force=yes]
 \definefontfallback[serifbolditalicwhatever][lmroman10-bolditalic][0x0000-0x0400][force=yes]
\stopsetups

\startsetups fallback:eb
 \definefontfallback[serifwhatever]          [ebgaramondregular]   [0x0000-0x0400][force=yes]
 \definefontfallback[serifboldwhatever]      [ebgaramondbold]      [0x0000-0x0400][force=yes]
 \definefontfallback[serifitalicwhatever]    [ebgaramonditalic]    [0x0000-0x0400][force=yes]
 \definefontfallback[serifbolditalicwhatever][ebgaramondbolditalic][0x0000-0x0400][force=yes]
\stopsetups

 \starttypescript [serif] [zhfont]
    \definefontsynonym [Serif]          [AdobeSongStd-Light]   [features=zh,fallbacks=serifwhatever]
    \definefontsynonym [SerifBold]      [AdobeHeitiStd-Regular][features=zh,fallbacks=serifboldwhatever]
    \definefontsynonym [SerifItalic]    [AdobeKaitiStd-Regular][features=zh,fallbacks=serifitalicwhatever]
    \definefontsynonym [SerifBoldItalic][AdobeHeitiStd-Regular][features=zh,fallbacks=serifbolditalicwhatever]
 \stoptypescript

 \starttypescript[myfont]
    \definetypeface[myfont][rm][serif][zhfont]
 \stoptypescript

 \usetypescript[myfont] 
 \starttext

 \setups{fallback:lm}
 \setupbodyfont[myfont,rm,12pt]
 fonts {\bf fonts} {\bi fonts} {\it fonts} % will be lm font
 \\\the\font

 \setups{fallbacks:reset}
 \setups{fallback:eb}
 fonts {\bf fonts} {\bi fonts} {\it fonts} % expected eb but lm
 \\\the\font
 
 \setups{fallbacks:reset}
 \setups{fallback:eb}
 \setupbodyfont[myfont,rm,12pt]%% any other chinese font, and change to eb
 fonts {\bf fonts} {\bi fonts} {\it fonts}
 \\\the\font
 \stoptext
%%%%

best wishes,
autumnus
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: how to reset and switch fallbackfont?
  2025-02-28 12:21 [NTG-context] how to reset and switch fallbackfont? autumnus 
@ 2025-03-02 19:10 ` Wolfgang Schuster
  2025-03-03  4:35   ` autumnus 
  2025-03-03 13:00 ` Hans Hagen
  1 sibling, 1 reply; 5+ messages in thread
From: Wolfgang Schuster @ 2025-03-02 19:10 UTC (permalink / raw)
  To: ntg-context

Am 28.02.2025 um 13:21 schrieb autumnus:
> hi,
> 
> As described in the title, how to reset fallbackfont?
> 
> I have created a number of Chinese typescripts and related fallbackfont (latin).
> 
> However, in the actual operation process,
> I found that if you want to switch different fallbackfont,
> you must change the bodyfont at the same time (\setupbodyfont).
> 
> The following is an example.
> How should I reset and switch to fallbackfont without changing the bodyfont?

My guess (but I can be wrong here) is that these settings a fixed once 
you load a font with a fallback applied.

While creating separate typescripts for each fallback font means 
additional work, there are ways to avoid duplicate settings dependent on 
your requirements.

Do you need access to the main font with different fallbacks in the same 
document or is the purpose of the alternative font to ensure you get the 
correct output even when one font is missing on the system?

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: how to reset and switch fallbackfont?
  2025-03-02 19:10 ` [NTG-context] " Wolfgang Schuster
@ 2025-03-03  4:35   ` autumnus 
  2025-03-03 21:28     ` Wolfgang Schuster
  0 siblings, 1 reply; 5+ messages in thread
From: autumnus  @ 2025-03-03  4:35 UTC (permalink / raw)
  To: ntg-context

I want to set different fallbackfonts for the main font in the same document.

I think your guess is correct. 
Once the fallbacks is set, the mainfont will be bound to the font.
Even if I switch to other typescripts, 
as long as its style(rm,ss etc) does not change,
 it will still use the previous fallbackfont.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: how to reset and switch fallbackfont?
  2025-02-28 12:21 [NTG-context] how to reset and switch fallbackfont? autumnus 
  2025-03-02 19:10 ` [NTG-context] " Wolfgang Schuster
@ 2025-03-03 13:00 ` Hans Hagen
  1 sibling, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2025-03-03 13:00 UTC (permalink / raw)
  To: ntg-context

On 2/28/2025 1:21 PM, autumnus wrote:
> hi,
> 
> As described in the title, how to reset fallbackfont?
> 
> I have created a number of Chinese typescripts and related fallbackfont (latin).
> 
> However, in the actual operation process,
> I found that if you want to switch different fallbackfont,
> you must change the bodyfont at the same time (\setupbodyfont).
> 
> The following is an example.
> How should I reset and switch to fallbackfont without changing the bodyfont?
> 
> %%%%%%%
> 
> \definefontfeature[zh][mode=node,script=hang,lang=zhs]
>   
> \startsetups fallbacks:reset
>    \resetfontfallback[serifwhatever]
>    \resetfontfallback[serifboldwhatever]
>    \resetfontfallback[serifitalicwhatever]
>    \resetfontfallback[serifbolditalicwhatever]
> \stopsetups
> 
> \startsetups fallback:lm
>   \definefontfallback[serifwhatever]          [lmroman10-regular]   [0x0000-0x0400][force=yes]
>   \definefontfallback[serifboldwhatever]      [lmroman10-bold]      [0x0000-0x0400][force=yes]
>   \definefontfallback[serifitalicwhatever]    [lmroman10-italic]    [0x0000-0x0400][force=yes]
>   \definefontfallback[serifbolditalicwhatever][lmroman10-bolditalic][0x0000-0x0400][force=yes]
> \stopsetups
> 
> \startsetups fallback:eb
>   \definefontfallback[serifwhatever]          [ebgaramondregular]   [0x0000-0x0400][force=yes]
>   \definefontfallback[serifboldwhatever]      [ebgaramondbold]      [0x0000-0x0400][force=yes]
>   \definefontfallback[serifitalicwhatever]    [ebgaramonditalic]    [0x0000-0x0400][force=yes]
>   \definefontfallback[serifbolditalicwhatever][ebgaramondbolditalic][0x0000-0x0400][force=yes]
> \stopsetups
> 
>   \starttypescript [serif] [zhfont]
>      \definefontsynonym [Serif]          [AdobeSongStd-Light]   [features=zh,fallbacks=serifwhatever]
>      \definefontsynonym [SerifBold]      [AdobeHeitiStd-Regular][features=zh,fallbacks=serifboldwhatever]
>      \definefontsynonym [SerifItalic]    [AdobeKaitiStd-Regular][features=zh,fallbacks=serifitalicwhatever]
>      \definefontsynonym [SerifBoldItalic][AdobeHeitiStd-Regular][features=zh,fallbacks=serifbolditalicwhatever]
>   \stoptypescript
> 
>   \starttypescript[myfont]
>      \definetypeface[myfont][rm][serif][zhfont]
>   \stoptypescript
> 
>   \usetypescript[myfont]
>   \starttext
> 
>   \setups{fallback:lm}
>   \setupbodyfont[myfont,rm,12pt]
>   fonts {\bf fonts} {\bi fonts} {\it fonts} % will be lm font
>   \\\the\font
> 
>   \setups{fallbacks:reset}
>   \setups{fallback:eb}
>   fonts {\bf fonts} {\bi fonts} {\it fonts} % expected eb but lm
>   \\\the\font
>   
>   \setups{fallbacks:reset}
>   \setups{fallback:eb}
>   \setupbodyfont[myfont,rm,12pt]%% any other chinese font, and change to eb
>   fonts {\bf fonts} {\bi fonts} {\it fonts}
>   \\\the\font
>   \stoptext
> %%%%

What is the (realistic) use case for that. Normally you set up a main 
bodyfont and then that one has fallbacks bound to it. Maybe another one 
with likely different fallbacks. Changing fallback fonts 'in the middle
of anything' will introduce confusion, give clashes, add more code, with 
basically zero gain.

There are sitations where it's kind of fun to show if something can be 
done, but this is not one of them. As Wolfgang answered: it's no big 
deal to define an extra fontclass.

If the sole purpose is to be able to show something in a mnaual or so, 
one can use a subrun and include pages from that.

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 : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [NTG-context] Re: how to reset and switch fallbackfont?
  2025-03-03  4:35   ` autumnus 
@ 2025-03-03 21:28     ` Wolfgang Schuster
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2025-03-03 21:28 UTC (permalink / raw)
  To: ntg-context

Am 03.03.2025 um 05:35 schrieb autumnus:
> I want to set different fallbackfonts for the main font in the same document.
> 
> I think your guess is correct.
> Once the fallbacks is set, the mainfont will be bound to the font.
> Even if I switch to other typescripts,
> as long as its style(rm,ss etc) does not change,
>   it will still use the previous fallbackfont.


Even when you use separate typefaces for each fallback font you can 
shorten the typescript definition when you use \typescriptone and 
\typescriptwo to select the required fallback etc.

Notice \edefinefontsynonym (with an extra e at the beginning) which is 
required to use \typescripttwo with the fallbacks key.

%%%% begin example
\starttypescript [serif] [zhfont-garamond]
   \definefontfallback [\typescripttwo-serif-regular] 
[file:ebgaramondregular] [basiclatin] [force=yes]
\stoptypescript

\starttypescript [serif] [zhfont-modern]
   \definefontfallback [\typescripttwo-serif-regular] 
[file:lmroman10regular] [basiclatin] [force=yes]
\stoptypescript

\starttypescript [serif] [zhfont-garamond,zhfont-modern]
   \edefinefontsynonym [Serif] [file:adobesongstdlight] 
[features=default,fallbacks=\typescripttwo-serif-regular]
\stoptypescript

\starttypescript [zhfont-garamond,zhfont-modern]
   \definetypeface [\typescriptone] [rm] [serif] [\typescriptone] [default]
\stoptypescript

\starttext

\setupbodyfont[pagella]

abc ABC 123

\setupbodyfont[zhfont-garamond]

abc ABC 123

\setupbodyfont[zhfont-modern]

abc ABC 123

\stoptext
%%%% end example

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-03 21:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-28 12:21 [NTG-context] how to reset and switch fallbackfont? autumnus 
2025-03-02 19:10 ` [NTG-context] " Wolfgang Schuster
2025-03-03  4:35   ` autumnus 
2025-03-03 21:28     ` Wolfgang Schuster
2025-03-03 13:00 ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).