Inlay wont display Chinese

Answered

In MyEditorCustomElementRenderer, I got font like this:
Font font = editor.getColorsScheme().getFont(EditorFontType.PLAIN);

And draw string in paint method:
Graphics2D g = (Graphics2D) graphics_s.create();
g.setFont(font);
g.drawString(text, rectangle.x, yPos);


When a inlay contains Chinese, it looks like this:

But you can see the first line of the comment, Chinese can be displayed correctly.

I don't know if this was related to OS, cuz there is no problem in my Mac and Windows, this problem was found in colleague's Windows,  here is the version info of that Windows: 
Windows10 Professional, 21H2, 19044.1288, Windows Feature Experience Pack 120.2212.3920.0 
And the IDE Version info: 
IntelliJ IDEA 2023.3 (Community Edition)
Build #IC-233.11799.241, built on December 2, 2023
Runtime version: 17.0.9+7-b1087.7 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Registry:
ide.experimental.ui=true
Non-Bundled Plugins:
com.nnthink.aixcoder.enterprise (5.6.0-20240129195030-2020)
Kotlin: 233.11799.241-IJ

0
2 comments

Hi,

Most likely your colleague's IDE has a different font configured. I suggest checking the used font and verifying it supports Chinese characters.

0

I solved the problem by this line:
font = com.intellij.util.ui.UIUtil.getFontWithFallbackIfNeeded(font, text);

 

0

Please sign in to leave a comment.