rio icon indicating copy to clipboard operation
rio copied to clipboard

Failure to load fonts should default back to Cascadia Mono

Open jmg-duarte opened this issue 9 months ago • 4 comments

Hey! I've been following Rio for a while now and decided to take it for another spin.

My font of choice is TX-02 SemiCondensed (Berkeley Mono v2), it just so happens that I need to manually set the weights (it seems).

(Note, I know the font name is wrong on the following screenshot, I had to change it to re-trigger the error and take the screenshot)

Image

The issue is that Rio error'd and gave me an even worse experience since I can't edit it like this:

Image

Given a bit of help where to look, I'd be interested in helping implement the fallback behavior

jmg-duarte avatar Mar 05 '25 10:03 jmg-duarte

Hey @jmg-duarte thank you for the issue,

I did a fix for that with https://github.com/raphamorim/rio/pull/980/files could you test that branch?

raphamorim avatar Mar 05 '25 14:03 raphamorim

Just did, same result

jmg-duarte avatar Mar 05 '25 20:03 jmg-duarte

I was debugging this issue and I found how to load my font correctly (by reading the code)

[fonts]
size = 12
#
[fonts.regular]
family = "TX-02"
width = "SemiCondensed"
weight = 400

[fonts.bold]
family = "TX-02"
# style = "Bold"
weight = 800
width = "SemiCondensed"

[fonts.italic]
family = "TX-02"
# style = "Oblique"
weight = 400
width = "SemiCondensed"

[fonts.bold-italic]
family = "TX-02"
# style = "Bold Oblique"
weight = 800
width = "SemiCondensed"

This is problematic because fonts don't always follow this convention — https://fonts.google.com/knowledge/choosing_type/exploring_width_in_type

For example, before Berkeley Mono/TX-02 I was using Input Mono Narrow, that font would be (to the best of my knowledge) impossible to loading using Sugarloaf.

Instead of segregating the fonts into these "neat" categories, I think the user should be able to load it much more flexibly, I want to write editor_font = "TX-02 SemiCondensed"

I wasn't able to find the place where the fallback shown in the original issue is applied but I did realize that is does not happen if I use the fonts.XXX format instead of fonts.family = XXX

jmg-duarte avatar Apr 01 '25 08:04 jmg-duarte

Ah @jmg-duarte thank you the explanation, I think is worth to add information about it in the documentation.

One possible fix for it as you described prob would be doing something like

[fonts]
family = "TX-02"
# it will override default width
width = "SemiCondensed"

raphamorim avatar Apr 14 '25 11:04 raphamorim