From: Hans Hagen <j.hagen@xs4all.nl>
To: Ali Ali <111414w@gmail.com>,
mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: [NTG-context] Re: Playing with math font setup
Date: Tue, 21 May 2024 17:16:00 +0200 [thread overview]
Message-ID: <2e169e65-6356-41e6-8dc9-bf0b52279f15@xs4all.nl> (raw)
In-Reply-To: <171630244572.1996.3670850218643042704@cgl.ntg.nl>
On 5/21/2024 4:40 PM, Ali Ali wrote:
> Hi, hope everyone's doing well!
>
> Is it possible to setup math font so that all the basic ascii characters (i.e. a..zA..Z0..9) glyphs are substituted with current serif (or sans) font. I tried playing with fallback thing but it didn't got me anywhere!
>
> e.g. $x$ will use the 'x' glyph from current serif italic font, and $\bf x$ will use the 'x' glyph from current serif bold font!
> I would appreciate any suggestions and help!
>
> Suppose we have all the required font files in the 'font' directory of the working directory, and below is the minimal source code!
> """
> \starttypescriptcollection[CustomFontSelection]
> \starttypescript [serif] [CustomFontSelection] [name]
> \setups[font:fallback:serif]
> \definefontsynonym [Serif]
> % [file:font/Lora-Regular.ttf]
> [file:font/Lora-Medium.ttf]
> [features=default,fallbacks=Serif]
> \definefontsynonym [SerifBold]
> [file:font/Lora-Bold.ttf]
> [features=default,fallbacks=SerifBold]
> \definefontsynonym [SerifItalic]
> % [file:font/Lora-Italic.ttf]
> [file:font/Lora-MediumItalic.ttf]
> [features=default,fallbacks=SerifItalic]
> \definefontsynonym [SerifBoldItalic]
> [file:font/Lora-BoldItalic.ttf]
> [features=default,fallbacks=SerifBoldItalic]
> \stoptypescript
>
> \starttypescript [math] [CustomFontSelection] [name]
> %%% \definefontfallback [MathRomanFallBack]
> %%% [SansItalic]
> %%% [extendedlatin]
> %%% [force=yes]
> \definefontsynonym [MathRoman]
> [file:font/STIXTwoMath-Regular.otf]
> [features=math,fallbacks=MathRomanFallBack]
> \stoptypescript
>
> \starttypescript[CustomFontSelection]
> \definetypeface [CustomFontSelection] [rm] [serif] [CustomFontSelection] [default] [rscale=0.9]
> \definetypeface [CustomFontSelection] [ss] [sans] [newcomputermodern-book] [default]
> \definetypeface [CustomFontSelection] [tt] [mono] [newcomputermodern-book] [default]
> \definetypeface [CustomFontSelection] [mm] [math] [CustomFontSelection] [default] [rscale=0.97]
> \stoptypescript
> \stoptypescriptcollection
>
> \setupbodyfont[CustomFontSelection]
>
>
> \starttext
>
> We use $X$, $Y$, $Z$ and $n$, $m$, etc. $\sin(x) \to \limsup x_n$ whatever.
>
> \mathematics{%
> \delta_{ij} =
> \startmathcases
> \NC 1 \NC \text{if } i = j \NR
> \NC 0 \NC \text{otherwise} \NR
> \stopmathcases
> }
>
> We use $\bf X$, $\bf Y$, $\bf Z$ and $\bf n$, $\bf m$, etc. $\bf \sin(x) \gets \limsup x_n$ whatever.
>
> \stoptext
> """
More like this (if you want decent math). Also, use a math font as base
that matches the fallbacks, also metric wise.
\starttypescriptcollection[CustomFontSelection]
\starttypescript [serif] [CustomFontSelection] [name]
\setups[font:fallback:serif]
\definefontsynonym [Serif] [name:dejavuserif]
[features=default]
\definefontsynonym [SerifBold] [name:dejavuserifbold]
[features=default]
\definefontsynonym [SerifItalic] [name:dejavuserifitalic]
[features=default]
\definefontsynonym [SerifBoldItalic]
[name:dejavuserifbolditalic] [features=default]
\stoptypescript
\starttypescript [math] [CustomFontSelection] [name]
\definefontfallback [MathRomanFallBack]
[name:dejavuserifitalic]
[lowercaseitalic,uppercaseitalic]
[force=yes]
\definefontfallback [MathRomanFallBack]
[name:dejavuserifbolditalic]
[lowercasebolditalic,uppercasebolditalic]
[force=yes]
\definefontfallback [MathRomanFallBack]
[name:dejavuserif]
[lowercasenormal,uppercasenormal]
[force=yes]
\definefontfallback [MathRomanFallBack]
[name:dejavuserifbold]
[lowercasebold,uppercasebold]
[force=yes]
\definefontsynonym
[MathRoman]
[file:stixtwomath-regular.ttf]
[features={math\mathsizesuffix,stixtwomath,stixtwo:mathextra,mathextra},%
fallbacks=MathRomanFallBack,%
goodies=stixtwo-math]
\definefontsynonym
[MathRomanBold]
[file:stixtwomath-regular.ttf]
[features={math\mathsizesuffix,stixtwo-math-bold,stixtwomath,stixtwo:mathextra,mathextra},%
fallbacks=MathRomanFallBack,%
goodies=stixtwo-math]
\stoptypescript
\starttypescript[CustomFontSelection]
\definetypeface [CustomFontSelection] [rm] [serif]
[CustomFontSelection] [default] [rscale=0.9]
\definetypeface [CustomFontSelection] [ss] [sans]
[newcomputermodern-book] [default]
\definetypeface [CustomFontSelection] [tt] [mono]
[newcomputermodern-book] [default]
\definetypeface [CustomFontSelection] [mm] [math]
[CustomFontSelection] [default] [rscale=0.97]
\stoptypescript
\stoptypescriptcollection
\setupbodyfont[CustomFontSelection]
\starttext
We use $X$, $Y$, $Z$ and $n$, $m$, etc. $\sin(x) \to \limsup x_n$ whatever.
We use $\bf X$, $\bf Y$, $\bf Z$ and $\bf n$, $\bf m$, etc. $\bf \sin(x)
\gets \limsup x_n$ whatever.
\stoptext
-----------------------------------------------------------------
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
___________________________________________________________________________________
prev parent reply other threads:[~2024-05-21 15:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-21 14:40 [NTG-context] " Ali Ali
2024-05-21 15:16 ` Hans Hagen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2e169e65-6356-41e6-8dc9-bf0b52279f15@xs4all.nl \
--to=j.hagen@xs4all.nl \
--cc=111414w@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).