How to change the typewriter font in TeXmacs?

I would like to use the Fira Code font as my programming font in sessions rather than the default typewriter font.

To that goal, I copied the Fira Code fonts (ttf version) to \AppData\Roaming\TeXmacs\fonts\truetype folder and then did Tools => Fonts => Scan disk for fonts. Now I can see the Fira Code font in the font family list on “Document font selector” window via Document => Font. However, when I try to change the typewriter font in “Document font selector” window (under Font Customization) I do not see it. The only typewriter fonts available are: Default, TexMacs Computer Modern, Stix, Tex Gyre Bonum, Tex Gyre Pagella, Tex Gyre Scholla, Tex Gyre Termes.

How do I change the default typewriter font in TeXmacs to a font of my choice?

To choose a specific typewriter font to your document, you can include the following in the preamble: <assign|font|tt=Fira Code,roman> .
The roman part specifies the main font for the document, but you can replace it with any font you prefer.

Thanks very much @xuyiqi1, but it does not seem to work…

I’m sorry, but I don’t have the font Fira Code installed on my Mac. However, other fonts work with this method in TeXmacs 2.1.4. Could you please let me know which version of TeXmacs you’re using? Also, does this method work for any other fonts besides Fira Code? Which programming session are you using?

Thanks again @xuyiqi1 . Yes, I am using TeXmacs 2.1.4 as well. I tried with Arial font, which also does not work. I tried with Python session. Here is the complete style file:

<use-package|generic>
<assign|font|tt=Arial,roman>
<assign|full-screen-mode|false>

Not sure if I doing something wrong in terms of loading the preamble. Is there any equivalent Scheme code that I can put in my my-init-texmacs.scm or my-init-buffer.scm?

Thanks for your feedback! The Python session, like other programming languages, uses the font family rm by default. You may change it in the style file env-program.ts yourself. For instance, you can replace the variable font-family with your-preferred-font, e.g., replace

<assign|python|<macro|body|<with|mode|prog|prog-language|python|font-family|rm|<arg|body>>>>

with

<assign|python|<macro|body|<with|mode|prog|prog-language|python|font-family|Fira Code|<arg|body>>>>

Please let me know if it works.

Thanks @xuyiqi1, but unfortunately this does not work still. I tried using a few other fonts (Arial, Fira Mono) as well.

what about font-family|tt instead of font-family|Fira Code, together with the definition of @xuyiqi1 How to change the typewriter font in TeXmacs? post
<assign|font|tt=Fira Code,roman> in the preamble?

Nope, still does not work. The typewriter code seems to be the same.

<assign|prog-font|Fira Sans>

from https://www.texmacs.org/tmdoc/devel/format/environment/env-font.en.html

1 Like