ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Non-standard font alternatives
@ 2022-12-13  8:15 Matthew McCabe via ntg-context
  2022-12-13  8:53 ` Hans Hagen via ntg-context
  2022-12-14 18:02 ` Wolfgang Schuster via ntg-context
  0 siblings, 2 replies; 11+ messages in thread
From: Matthew McCabe via ntg-context @ 2022-12-13  8:15 UTC (permalink / raw)
  To: ntg-context; +Cc: Matthew McCabe


[-- Attachment #1.1: Type: text/plain, Size: 4967 bytes --]

Hi list,

I'm looking to import a font with medium and light weights (in this case Roboto) and define font alternatives so one can quickly switch to light text just as one would switch to bold text. There is a stackexchange answer from Wolfgang (https://tex.stackexchange.com/questions/303648/context-font-weights) which details a solution to this problem for ConTeXt MkIV but despite my best efforts I haven't been able to get things to work for me. There is the Roboto typescript example on ConTeXt garden but it isn't exactly what I'm looking for as for the document I'm making I would prefer to be able to treat the font weights as alternatives rather than separate families since I will be switching often.

One can download the exact set of fonts I am using from https://fonts.google.com/specimen/Roboto

Here is my code:

\definefontalternative[lf] % light
\definefontalternative[li] % lightitalic
\definefontalternative[md] % medium
\definefontalternative[mi] % mediumitalic

\starttypescript [sans] [roboto]
  \definefontsynonym [SansLight]        [file:Roboto-Light]        [features=default]
  \definefontsynonym [SansLightItalic]  [file:Roboto-LightItalic]  [features=default]
  \definefontsynonym [Sans]             [file:Roboto-Regular]      [features=default]
  \definefontsynonym [SansItalic]       [file:Roboto-Italic]       [features=default]
  \definefontsynonym [SansMedium]       [file:Roboto-Medium]       [features=default]
  \definefontsynonym [SansMediumItalic] [file:Roboto-MediumItalic] [features=default]
  \definefontsynonym [SansBold]         [file:Roboto-Bold]         [features=default]
  \definefontsynonym [SansBoldItalic]   [file:Roboto-BoldItalic]   [features=default]
  \definefontsynonym [SansCaps]         [file:Roboto-Sans]         [features=smallcaps]
\stoptypescript

\starttypescript [sans] [roboto]
  \definebodyfont [default] [rm]
     [lf=SansLight sa 1,
      li=SansLightItalic sa 1,
      tf=Sans sa 1,
      it=SansItalic sa 1,
      md=SansMedium sa 1,
      mi=SansMediumItalic sa 1,
      bf=SansBold sa 1,
      bi=SansBoldItalic sa 1,
      sc=SansCaps sa 1]
\stoptypescript

\definetypeface[roboto][rm][sans][roboto][default]

\setupbodyfont[roboto]

\starttext

\lf Light
\li LightItalic
\tf Regular
\it Italic
\md Medium
\mi MediumItalic
\bf Bold
\bi BoldItalic
\sc SmallCaps

\stoptext

- The result is entirely in the regular weight default font:



What I've tried:

1. I've tried a great deal of alternative \definefontsynonym arguments such as specifying by name, including the full path to each ttf file

2. I played around with different two character \definefontalternative arguments to ensure there was no overlap with existing commands (as far as I am aware the existing set are otherwise undefined)


A few things to note:

1. My current version of ConTeXt is 2022.12.09 16:34

2. For portability I have included the ttf files for Roboto in a directory within my project directory and while setting things up I set OSFONTDIR to include this directory and run `mtxrun --script fonts --reload --force`

3. `mtxrun --script fonts --list --all --pattern=Robo` yields:

identifier           familyname   fontname             filename                                 subfont   instances

roboto               roboto       robotoregular        ./fonts/Roboto/Roboto-Regular.ttf
robotoblack          roboto       robotoblack          ./fonts/Roboto/Roboto-Black.ttf
robotoblackitalic    roboto       robotoblackitalic    ./fonts/Roboto/Roboto-BlackItalic.ttf
robotobold           roboto       robotobold           ./fonts/Roboto/Roboto-Bold.ttf
robotobolditalic     roboto       robotobolditalic     ./fonts/Roboto/Roboto-BoldItalic.ttf
robotoitalic         roboto       robotoitalic         ./fonts/Roboto/Roboto-Italic.ttf
robotolight          roboto       robotolight          ./fonts/Roboto/Roboto-Light.ttf
robotolightitalic    roboto       robotolightitalic    ./fonts/Roboto/Roboto-LightItalic.ttf
robotomedium         roboto       robotomedium         ./fonts/Roboto/Roboto-Medium.ttf
robotomediumitalic   roboto       robotomediumitalic   ./fonts/Roboto/Roboto-MediumItalic.ttf
robotonormal         roboto       robotoregular        ./fonts/Roboto/Roboto-Regular.ttf
robotoregular        roboto       robotoregular        ./fonts/Roboto/Roboto-Regular.ttf
robotothin           roboto       robotothin           ./fonts/Roboto/Roboto-Thin.ttf
robotothinitalic     roboto       robotothinitalic     ./fonts/Roboto/Roboto-ThinItalic.ttf

4. Using `\definedfont[name:robotomedium*default] hello` and `\definedfont[file:Roboto-Thin*default] hello` (for example) work exactly as expected


I hope this isn't a silly question, I'm very new to ConTeXt and have been struggling for a while so thought I may as well ask in case there's something I'm missing, would appreciate any guidance :)

Regards, Matt


[-- Attachment #1.2.1: Type: text/html, Size: 33235 bytes --]

[-- Attachment #1.2.2: screenshot.png --]
[-- Type: image/png, Size: 37479 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-04-20 21:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13  8:15 Non-standard font alternatives Matthew McCabe via ntg-context
2022-12-13  8:53 ` Hans Hagen via ntg-context
2022-12-14 10:49   ` Matthew McCabe via ntg-context
2023-01-06  7:55     ` Hans Hagen via ntg-context
2023-04-19 14:53       ` [NTG-context] " Pawel Urbanski via ntg-context
2023-04-19 16:52         ` Henning Hraban Ramm via ntg-context
2023-04-19 18:02           ` Pawel Urbanski via ntg-context
2023-04-19 19:24         ` Henning Hraban Ramm via ntg-context
2023-04-19 21:57           ` Pawel Urbanski via ntg-context
2023-04-20 21:34           ` Pawel Urbanski via ntg-context
2022-12-14 18:02 ` Wolfgang Schuster via ntg-context

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).