Fonts from various .otf to work with \bold, \emph, \bf, \bfa ...
Hello, although font switching used to be discussed here and I studied wiki about font changing, I don't switch fonts in ConTeXt very often and my "maximum" font change was provided by \setupbodyfont[(e.g. termes)]. Now I am in the situation that I need to use fonts defined in: work-sans.bold.otf work-sans.bold-italic.otf work-sans.light.otf work-sans.light-italic.otf (all from https://www.1001fonts.com/work-sans-font.html) so that: - normal text and math (nothing special - just subscripts) would be typeset with work-sans.light.otf - \bold (\bf) would use work-sans.bold.otf, - \emph (\em and \it) would use work-sans.light-italic.otf, - \bi would use work-sans.bold-italic.otf - also commands \bfa, \bfc, ... would use work-sans.bold.otf scaled somehow (probably by multiples of 1.2). Some help setting it up and making it work would be appreciated... Best regards, Lukas
On 2/6/20 10:04 AM, context@vivaldi.net wrote:
Hello,
although font switching used to be discussed here and I studied wiki about font changing, I don't switch fonts in ConTeXt very often and my "maximum" font change was provided by \setupbodyfont[(e.g. termes)]. [...] so that:
- normal text and math (nothing special - just subscripts) would be typeset with work-sans.light.otf - \bold (\bf) would use work-sans.bold.otf, - \emph (\em and \it) would use work-sans.light-italic.otf, - \bi would use work-sans.bold-italic.otf - also commands \bfa, \bfc, ... would use work-sans.bold.otf scaled somehow (probably by multiples of 1.2).
Some help setting it up and making it work would be appreciated...
Hi Lukas, I think this is what you might need: \definefontfamily [mainface] [rm] [WorkSans] [tf={style:light}, it={style:lightitalic}] \setupbodyfont[mainface] \setupbodyfontenvironment [default] [a=1.2, b=2.4, c=3.6, d=4.8, em=italic] \starttext \startTEXpage[offset=1em] roman\\ {\bf bold}\\ {\it italic}\\ {\bi bold italic}\\ {\tfa roman}\\ {\bfb bold}\\ {\itc italic}\\ {\bid bold italic}\\ \stopTEXpage \stoptext I hope it helps, Pablo -- http://www.ousia.tk
Hello Pablo, thank you for showing the way; unfortunately, still something is missing: - the resulting file uses LMRoman instead of WorkSans, - the log confirms: "selectfont > The requested font 'WorkSans' has no files for the 'tf' alternative, Latin Modern is used instead". - Note that all WorkSans files: work-sans.bold.otf work-sans.bold-italic.otf work-sans.light.otf work-sans.light-italic.otf are placed in the same directory as the main source file. (I can zip them and upload somewhere for testing purposes.) - In your code bellow, I cann't see any link to any work-sans .otf file name. - Does it mean that that ConTeXt browses its database of "known" fonts, searches for all fonts which contain "identification" as "WorkSans" (given from your \definefontfamily...[WorkSans])? - Also, I see assignments [tf={style:light},it={style:lightitalic}]: - Should also an assignment for "bf=[style:...]" be provided? - How ConTeXt gets to know from "it={style:lightitalic}" that file "work-sans.light-italic.otf" should be used? Sorry for elementary questions, I'm still "in captivity" of swtching fonts, their styles and font sizes by clicking a combo in Word toolbar (although I quit using Word about 15 ys ago). And although I'm aware of different dealing with fonts in TeX (and in professional typesetting in general), it's often difficult for me to imagine how exactly TeX switchches fonts, what is the relationship between (and how the comands cooperate) \definefontfamily, \setupbodyfontenvironment, \setupbodyfont, \definefontsynonym, \definefont, typescripts, simplefonts module and also what is the relations among parameters to the-above commands. So any practical samples (e.g. here discussed) helps me much. Best regards, Lukas
Hi Lukas,
I think this is what you might need:
\definefontfamily [mainface] [rm] [WorkSans] [tf={style:light}, it={style:lightitalic}] \setupbodyfont[mainface]
\setupbodyfontenvironment [default] [a=1.2, b=2.4, c=3.6, d=4.8, em=italic]
\starttext \startTEXpage[offset=1em] roman\\ {\bf bold}\\ {\it italic}\\ {\bi bold italic}\\ {\tfa roman}\\ {\bfb bold}\\ {\itc italic}\\ {\bid bold italic}\\ \stopTEXpage \stoptext
I hope it helps,
Pablo -- http://www.ousia.tk ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 2/7/20 8:34 AM, context@vivaldi.net wrote:
Hello Pablo,
thank you for showing the way; unfortunately, still something is missing:
Hi Lukas, I’m afraid you missed to install the fonts in ConTeXt.
- the resulting file uses LMRoman instead of WorkSans,
Otherwise, \definefontfamily won’t work (even if using "tf={file:work-sans.light.otf}"). Do you have any problem installing fonts in ConTeXt? This would make things easier.
- Note that all WorkSans files: [...] are placed in the same directory as the main source file. (I can zip them and upload somewhere for testing purposes.)
This was a feature already discussed in the past. "\definefont[Test][file:your-font-file.otf]" should work, but I never used this approach. I think you need to mix fonts into a typeface with something similar to a typescript (but this is all Greek to me). -- http://www.ousia.tk
"\definefont[Test][file:your-font-file.otf]" should work, but I never used this approach.
I think you need to mix fonts into a typeface with something similar to a typescript (but this is all Greek to me).
Here’s an example of a simple typescript using "file": \definefontfeature[smallcaps][default][smcp=yes] \starttypescriptcollection[charis] \starttypescript [serif] [charis] \definefontsynonym [Charis-Roman] [file:CharisSIL-R.ttf] \definefontsynonym [Charis-Italic] [file:CharisSIL-I.ttf] \definefontsynonym [Charis-Bold] [file:CharisSIL-B.ttf] \definefontsynonym [Charis-BoldItalic] [file:CharisSIL-BI.ttf] \definefontsynonym [Charis-Roman-Caps] [Charis-Roman] \stoptypescript \starttypescript [serif] [charis] [name] \setups[font:fallback:serif] \definefontsynonym [Serif] [Charis-Roman][features=default] \definefontsynonym [SerifItalic] [Charis-Italic][features=default] \definefontsynonym [SerifBold] [Charis-Bold][features=default] \definefontsynonym [SerifBoldItalic] [Charis-BoldItalic][features=default] \definefontsynonym [SerifSlanted] [Charis-Italic][features=default] \definefontsynonym [SerifBoldSlanted] [Charis-BoldItalic][features=default] \definefontsynonym [SerifCaps] [Charis-Roman-Caps][features=smallcaps] \stoptypescript \starttypescript [charis] % doesn’t make a lot of sense \definetypeface [charis] [rm] [serif] [charis] [default] \definetypeface [charis] [ss] [sans] [heros] [default] \definetypeface [charis] [tt] [mono] [modern] [default] \definetypeface [charis] [mm] [math] [default] [default] \stoptypescript \stoptypescriptcollection Greetlings, Hraban --- https://www.fiee.net http://wiki.contextgarden.net https://www.dreiviertelhaus.de GPG Key ID 1C9B22FD
Pablo Rodriguez schrieb am 07.02.2020 um 21:22:
On 2/7/20 8:34 AM, context@vivaldi.net wrote:
Hello Pablo,
thank you for showing the way; unfortunately, still something is missing: Hi Lukas,
I’m afraid you missed to install the fonts in ConTeXt.
- the resulting file uses LMRoman instead of WorkSans, Otherwise, \definefontfamily won’t work (even if using "tf={file:work-sans.light.otf}").
Do you have any problem installing fonts in ConTeXt? This would make things easier.
- Note that all WorkSans files: [...] are placed in the same directory as the main source file. (I can zip them and upload somewhere for testing purposes.)
The designer provides the latest version of the font on github without the change in file name from your source. https://github.com/weiweihuanghuang/Work-Sans
This was a feature already discussed in the past.
"\definefont[Test][file:your-font-file.otf]" should work, but I never used this approach.
Works at the moment only when the fonts in a place where ConTeXt can find them. Wolfgang
participants (4)
-
context@vivaldi.net
-
Henning Hraban Ramm
-
Pablo Rodriguez
-
Wolfgang Schuster