Custom editor font issues (Thai/Korean language)

Answered

The CSV plugin provides an additional table editor (good old Swing component) next to the text editor. While the text editor can show all kind of characters for Thai/Korean, the table editor doesn't (please see issue).

I already fixed an issue by using `UIUtil.getFontWithFallback` to set the font in the table editor, but it didn't solve the issues related to Thai/Korean. I couldn't figure out how the text-editor handles the actual font. Any help is appreciated!

2 comments
Comment actions Permalink

This is a problem with good old Swing components in JDK. Using `UIUtil.getFontWithFallback` will only get your component to the same level of font fallback support as Java's logical fonts (Monospaced, Serif, Dialog, etc) can provide. But the latter is not that perfect, especially on Windows. Specifically, certain fonts used as fallback components by JDK are not installed by default in Windows 10, see https://docs.microsoft.com/en-us/windows/deployment/windows-10-missing-fonts for details.

IntelliJ platform's editor component uses its own mechanism for font fallback (basically searching over all fonts installed in the system to find the fallback), so it might show certain characters even if Swing components don't. That mechanism can be accessed via `FontFallbackIterator` class. Probably the only way to use it in a Swing component is to wrap text in HTML with fallback fonts explicitly specified as tags, similar to what `com.intellij.openapi.vcs.ui.FontUtil#getHtmlWithFonts(java.lang.String)` does.

2
Comment actions Permalink

That's a wholesome answer - Thanks Dmitry!

0

Please sign in to leave a comment.