Live data from Hacker News

Thoughts on different fonts for different languages in a text editor

news.ycombinator.com

1–10 of 12 posts

Thoughts on different fonts for different languages in a text editor

#1
It would be nice if text editors could select different fonts for different languages.

Suppose I have a nice font that only supports latin characters but the codebase I work with contains symbols and strings in both English and Japanese. At best, my editor will render my font's supported characters and fall back to some default for everything else. At worst, any characters not in the font won't be rendered at all. Wouldn't it be nice if we could select one font for English and a different but matching font for Japanese?

I'm not aware of any text editor that has this sort of feature. Does anyone share a desire for this?

I'm thinking of contributing work on this for some editor but I'm not sure how welcome this would be.

Re: Thoughts on different fonts for different languages in a text editor

#3
i havent encountered such codebase yet, but i can imagine it being a real acenario as i have friends in an english speaking country trying to migrate to japan.

that would be a cool vscode extension i guess, albeit in a niche use case. what could be the possible challenges here? one i can think of is the alignment of monospace width on differing font families.

Re: Thoughts on different fonts for different languages in a text editor

#6
post #3

i havent encountered such codebase yet, but i can imagine it being a real acenario as i have friends in an english speaking country trying to migrate to japan. that would be a cool vscode extension i guess, albeit in a niche use case. what could be the possible challenges here? one i can think of is the alignment of monospace width on differing font families.

Alignment could definitely be a challenge. Perhaps a better personal solution would be to write something to combine two fonts in a way that also solves alignment. Not a very "accessible" solution but definitely easier.

Re: Thoughts on different fonts for different languages in a text editor

#7
Interesting idea.

I imagine Emacs would be able to support this if you’re willing to dive into Elisp. You would probably need some heuristic to guess language (per line?).

However, have you considered a much easier solution: Use a typeface with good glyph coverage. The DejaVu family is probably a good bet.

Re: Thoughts on different fonts for different languages in a text editor

#8
post #7

Interesting idea. I imagine Emacs would be able to support this if you’re willing to dive into Elisp. You would probably need some heuristic to guess language (per line?). However, have you considered a much easier solution: Use a typeface with good glyph coverage. The DejaVu family is probably a good bet.

As a baseline solution "language" could be substituted for "unicode range".

Re "use a better font": fonts are something I enjoy and I try new ones frequently.

Re: Thoughts on different fonts for different languages in a text editor

#9
post #5
post #2

Emacs https://www.emacswiki.org/emacs/SetFonts#h5o-2

This is applying a font for an entire window/frame/buffer, right? Not applying two fonts for different characters within the same buffer.

So write some Lisp to do exactly what you want and package it up into a mode?

The alternative is shopping for a solution that does exactly what you want.

That’s another name for hiring a consultant.

Re: Thoughts on different fonts for different languages in a text editor

#10
post #9
post #5

Earlier quoted context omitted.

This is applying a font for an entire window/frame/buffer, right? Not applying two fonts for different characters within the same buffer.

So write some Lisp to do exactly what you want and package it up into a mode? The alternative is shopping for a solution that does exactly what you want. That’s another name for hiring a consultant.

I'm not sure emacs modes offer this level of extensibility, but I'll check them out.
Post reply on HN