Changing Leo Fonts -Tree and Body - On The Fly

30 views
Skip to first unread message

Thomas Passin

unread,
May 9, 2026, 11:53:53 AM (12 days ago) May 9
to leo-editor
I've been finding I want to adjust font sizes of both the tree and body panes while I'm working in Leo. Also I've been doing a lot of writing and prefer using a variable-spacing font instead of a mono-spaced programming font. Trying to tinker with theme outlines for every trial change is not practical, and besides I want to be able to use the different font-families in different outlines while they are all open in Leo at the same time.

Leo does have the zoom-in and zoom-out command to change the size of the body editor font, but they if I've switched the font family they change it back. Besides, they use an unnecessarily complicated method (munging the CSS style sheet) when there's a simpler, more direct way.

I have attached an outline with little scripts to change the font sizes in the tree and the body (separate commands), and to toggle the body's font family between the default and a variable font. The outline also includes the setting nodes, ready to be copied into your @settings node, and a new menu that toggles the body font family. The scripts work on a per-outline basis.

The way these scripts work is by asking the tree or body widget for its current font. The size and font family are gotten from the current font and adjusted as needed. Finally, a CSS fragment is applied to the widget. This does not change any other CSS values that the theme applies.

To change the font size there is a script that takes a boolean (increase=true). This script, which creates a leo command,  is installed in the outline's c.user_dict. The scripts that call this install the command if it isn't already there, then call it.

I defined shortcuts CTRL+= and CTRL+- to call the right command for the tree or the body depending on which one has the focus. You can copy these to your @shortcuts node.

If you don't like the variable font-families I have included in the font-family changing script, just edit it to your liking. Note that variable-spacing fonts usually look smaller for a given font size than monospaced fonts so after changing the font family you will probably have to change the size too.

I didn't include a way to get back to the default theme settings. It would be easy to do, though. Just copy one of the size-setting scripts but make the CSS fragment have an empty string between the { } braces of the CSS.

Now that have them, I am using these commands frequently. Try them yourself, see if you like them.
change_font.zip

jkn

unread,
May 9, 2026, 3:02:42 PM (12 days ago) May 9
to leo-editor
I'm not on the right machine right now, but on at least one (Linux) PC that I work on, I can zoom fonts with the mouse middle wheel. I have not checked what mechanism this invokes...

Viktor Ransmayr

unread,
May 11, 2026, 11:13:44 AM (10 days ago) May 11
to leo-editor
Hello Thomas,

tbp1...@gmail.com schrieb am Samstag, 9. Mai 2026 um 17:53:53 UTC+2:
I've been finding I want to adjust font sizes of both the tree and body panes while I'm working in Leo. Also I've been doing a lot of writing and prefer using a variable-spacing font instead of a mono-spaced programming font. Trying to tinker with theme outlines for every trial change is not practical, and besides I want to be able to use the different font-families in different outlines while they are all open in Leo at the same time.
...

Now that have them, I am using these commands frequently. Try them yourself, see if you like them.

I did  try it out in a fresh Leo 6.8.8 installation on a Debian VM.

The commands work well - and - the result is really nice !

With kind regards,

Viktor

Thomas Passin

unread,
May 11, 2026, 12:08:36 PM (10 days ago) May 11
to leo-editor
I'm glad to hear it, Viktor. Of course, one could use the same techniques to change the font family of the outline too. These scripts ought to help anyone who is trying to tune up a theme as well.
Reply all
Reply to author
Forward
0 new messages