Referencing fonts by path within ConTeXt
![](https://secure.gravatar.com/avatar/607919c9bb8a0aebced8df36da178182.jpg?s=120&d=mm&r=g)
Hi, I'm interested in packaging a ConTeXt project in a self-contained way, so that the environment/component/project .tex files, the bibliography .bib file(s), and fonts used for typesetting are all provided in one place. (The goal is that others can generate the PDFs themselves from the source files as long as they have a sufficiently recent version of ConTeXt installed.) The usual ConTeXt directory structure makes sense for most of this, but it doesn't address the possibility of accessing fonts locally. I think I could do this with a script that temporarily sets the OSFONTDIR variable to the local fonts directory and then invokes ConTeXt to typeset the project-level file, but I was wondering if there is an easier way to do this from within ConTeXt. Specifically, is there a way to specify a font via a local path with font setup commands in an environment file? Thank you! Joey
![](https://secure.gravatar.com/avatar/e5aa6984b53b8925e405ebbdbc051ad9.jpg?s=120&d=mm&r=g)
Am 07.08.2021 um 22:29 schrieb Joey McCollum via ntg-context
: Hi,
I'm interested in packaging a ConTeXt project in a self-contained way, so that the environment/component/project .tex files, the bibliography .bib file(s), and fonts used for typesetting are all provided in one place. (The goal is that others can generate the PDFs themselves from the source files as long as they have a sufficiently recent version of ConTeXt installed.) The usual ConTeXt directory structure makes sense for most of this, but it doesn't address the possibility of accessing fonts locally. I think I could do this with a script that temporarily sets the OSFONTDIR variable to the local fonts directory and then invokes ConTeXt to typeset the project-level file, but I was wondering if there is an easier way to do this from within ConTeXt. Specifically, is there a way to specify a font via a local path with font setup commands in an environment file?
You can just specify your fonts in the typescript as [file:relative_path/fontname.otf]. OSFONTDIR isn’t as reliable as you need "mtxrun --script fonts --reload" after changing it (and sometimes "mtxrun --generate" before). Hraban
![](https://secure.gravatar.com/avatar/74d41c3215dcdd377343cdc47311757c.jpg?s=120&d=mm&r=g)
Joey McCollum via ntg-context schrieb am 07.08.2021 um 22:29:
Hi,
I'm interested in packaging a ConTeXt project in a self-contained way, so that the environment/component/project .tex files, the bibliography .bib file(s), and fonts used for typesetting are all provided in one place. (The goal is that others can generate the PDFs themselves from the source files as long as they have a sufficiently recent version of ConTeXt installed.) The usual ConTeXt directory structure makes sense for most of this, but it doesn't address the possibility of accessing fonts locally. I think I could do this with a script that temporarily sets the OSFONTDIR variable to the local fonts directory and then invokes ConTeXt to typeset the project-level file, but I was wondering if there is an easier way to do this from within ConTeXt. Specifically, is there a way to specify a font via a local path with font setup commands in an environment file?
You can use \usefontpath[...] to set a directory where ConTeXt searches for fonts but this works only when you use a typescript and not for \definefontfamily. Wolfgang
participants (3)
-
Henning Hraban Ramm
-
Joey McCollum
-
Wolfgang Schuster