Incerteza
Incerteza

Reputation: 34924

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

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

Upvotes: 4

Views: 11163

Answers (4)

Anton Dozortsev
Anton Dozortsev

Reputation: 4902

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

enter image description here

I use IDEA under ElementaryOS and it works for me.

Update:

enter image description here

Upvotes: 2

Andrei Nazariev
Andrei Nazariev

Reputation: 11

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.

Upvotes: 1

KidOfLaMancha
KidOfLaMancha

Reputation: 61

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

Upvotes: 6

alijandro
alijandro

Reputation: 12167

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.

enter image description here

Upvotes: 1

Related Questions