A font doesn't appear in IntelliJ's dialog of choosing a font

可紊 提交于 2019-12-10 16:42:28

问题


I installed Monaco font using this code. However, it doesn't appear in Setting -> Editor -> Color and fonts -> Font. What should I do?


回答1:


Try to install fonts in another way. Just use the Font Viewer.

I use IDEA under ElementaryOS and it works for me.

Update:




回答2:


You need to create a folder monaco in directory /usr/share/fonts/truetype/

and copy the font 'monaco.ttf' into this folder.

Then, run fc-cache -v -f




回答3:


I had the similar problems recently. The reason IDEA could not find the font might be the installing location of the fonts not correct.

At the beginning, my font was put under ~/.fonts, the font name not show in IDEA settings. Then I put a copy of the font to .local/share/fonts, and with command fc-cache -v -f to refresh the cache, the font name can be selected in IDEA font settings.

Hope it would be helpful.




回答4:


In IntelliJ settings you can change only Editor Pane's font. But you can set any font available in your system to any IntelliJ UI component.If you want to be in control of entire IDE (Project tree, Menu Bar, Labels, etc) create simple plugin with this line of code in it: UIManager.put("XXX.font", new Font("fontName", style, size)) where XXX is name of UI component like Label, TextField, Tree, etc.). Full list of Swing components (IntelliJ built using Swing framework) you can find here: List of Java Swing UI properties? After executing plugin all new font settings will be applied to IntelliJ's UI. Here is the code sample:

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;

import javax.swing.*;
import java.awt.*;

public class MyUIPlugin implements ToolWindowFactory
{

    private ToolWindow myToolWindow;

    public static final String TOOL_WINDOW_ID = "MyUISettings";

    public MyUIPlugin() {}

    // Create the tool window content.
    public void createToolWindowContent(final Project project, final ToolWindow toolWindow) {
        myToolWindow = toolWindow;
        this.createContent(toolWindow);
}

public void createContent(final ToolWindow toolWindow) {
    final ContentFactory contentFactory = toolWindow.getContentManager().getFactory();
    JLabel myPluginUI = new JLabel("This is empty panel with my custom fonts settings behind it");
    final Content content = contentFactory.createContent(myPluginUI, "", true);
    toolWindow.getContentManager().addContent(content);
    UIManager.put("TextField.font", new Font(...));
    UIManager.put("List.font", new Font(...));
    UIManager.put("Label.font", new Font(...));
    UIManager.put("Button.font", new Font(...));
    .....
    SwingUtilities.updateComponentTreeUI(myPluginUI);
}

}

Additionally you even can write small Swing code instead of JLabel placeholder, with list of UI elements and list of all fonts available in the system by calling GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(). And you can assign different font to different component types right in your plugin window and have full customization of IntelliJ UI fonts.




回答5:


I solved this issue by following the instructions and installing it from this repo: https://github.com/probil/Monaco-IDE-font.



来源:https://stackoverflow.com/questions/22222833/a-font-doesnt-appear-in-intellijs-dialog-of-choosing-a-font

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!