【问题标题】:A font doesn't appear in IntelliJ's dialog of choosing a fontIntelliJ 选择字体的对话框中没有出现字体
【发布时间】:2014-04-08 23:47:36
【问题描述】:

我使用这个code 安装了 Monaco 字体。但是,它没有出现在Setting -> Editor -> Color and fonts -> Font 中。我该怎么办?

【问题讨论】:

    标签: linux fonts intellij-idea linux-mint


    【解决方案1】:

    尝试以其他方式安装字体。只需使用Font Viewer

    我在 ElementaryOS 下使用 IDEA,它适用于我。

    更新:

    【讨论】:

    • 字体查看器显示 monaco 已安装。
    • @Alex In Setting -> Editor -> Color & Fonts -> Font 选项 Show only monospaced fonts 必须禁用。查看更新。
    • IntelliJ 的字体选择对话框中没有出现字体!不清楚吗?
    【解决方案2】:

    在 IntelliJ 设置中,您只能更改编辑器窗格的字体。但是您可以将系统中可用的任何字体设置为任何 IntelliJ UI 组件。如果您想控制整个 IDE(项目树、菜单栏、标签等),请使用以下代码创建简单的插件:@987654322 @ 其中 XXX 是 UI 组件的名称,例如 Label、TextField、Tree 等)。您可以在此处找到 Swing 组件的完整列表(使用 Swing 框架构建的 IntelliJ):List of Java Swing UI properties? 执行插件后,所有新字体设置都将应用于 IntelliJ 的 UI。这是代码示例:

    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);
    }
    

    }

    此外,您甚至可以编写小的 Swing 代码来代替 JLabel 占位符,通过调用 GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts() 来使用 UI 元素列表和系统中所有可用字体的列表。您可以直接在插件窗口中为不同的组件类型分配不同的字体,并完全自定义 IntelliJ UI 字体。

    【讨论】:

      【解决方案3】:

      我按照说明从这个 repo 安装它解决了这个问题:https://github.com/probil/Monaco-IDE-font

      【讨论】:

        【解决方案4】:

        您需要在目录/usr/share/fonts/truetype/中创建一个文件夹monaco

        并将字体“monaco.ttf”复制到此文件夹中。

        然后,运行fc-cache -v -f

        【讨论】:

          【解决方案5】:

          我最近遇到了类似的问题。 IDEA找不到字体的原因可能是字体的安装位置不正确。

          一开始我的字体放在~/.fonts下,IDEA设置里没有显示字体名称。然后我把字体复制到.local/share/fonts,用命令fc-cache -v -f刷新缓存,字体名称可以在IDEA字体设置中选择。

          希望对您有所帮助。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2010-09-21
            • 1970-01-01
            • 2018-10-11
            • 1970-01-01
            • 2011-01-19
            • 1970-01-01
            • 2012-11-18
            • 1970-01-01
            相关资源
            最近更新 更多