【发布时间】:2014-04-08 23:47:36
【问题描述】:
我使用这个code 安装了 Monaco 字体。但是,它没有出现在Setting -> Editor -> Color and fonts -> Font 中。我该怎么办?
【问题讨论】:
标签: linux fonts intellij-idea linux-mint
我使用这个code 安装了 Monaco 字体。但是,它没有出现在Setting -> Editor -> Color and fonts -> Font 中。我该怎么办?
【问题讨论】:
标签: linux fonts intellij-idea linux-mint
【讨论】:
Setting -> Editor -> Color & Fonts -> Font 选项 Show only monospaced fonts 必须禁用。查看更新。
在 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 字体。
【讨论】:
我按照说明从这个 repo 安装它解决了这个问题:https://github.com/probil/Monaco-IDE-font。
【讨论】:
您需要在目录/usr/share/fonts/truetype/中创建一个文件夹monaco
并将字体“monaco.ttf”复制到此文件夹中。
然后,运行fc-cache -v -f
【讨论】: