Hacker News new | past | comments | ask | show | jobs | submit login
Thoughts on different fonts for different languages in a text editor
4 points by greenn on Sept 27, 2023 | hide | past | favorite | 11 comments
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.




My text editor has this feature, all non-English symbols use to render like ▯▯▯▯▯ ▯▯▯ ▯ ▯▯▯▯▯▯▯▯▯.


On Japanese Windows, if a configured font misses glyph, it fallback to default font (Maybe "MS Gothic" for Japanese). It's common behavior on most editors. I found that random Hangul can be shown too.

Most programmers use far better aligned font like Source Han Code JP, or merged and aligned font like Myrica. So I don't know much. I don't recommend mixing fonts for coding that prefer monospaced font, but it should have a fallback.


> Wouldn't it be nice if we could select one font for English and a different but matching font for Japanese?

That “matching” is what font designers do when they make a font with a large character set. Making a nice match is highly nontrivial.

I think you might be better of with a tool that makes it easy to merge fonts.


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.


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.



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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: