首页 > 解决方案 > 如何在 RStudio 中为 ggplot2 安装 Courier 字体

问题描述

更新我的操作系统后,我的 Rstudio 中的字体消失了,特别是我需要 ggolot2的Courier 。

为了解决我安装的问题:

library(extrafont)

接着:

font_import()

现在我有几种字体,但它们大多不受欢迎。例如:

fonts()
"aakar" "Abyssinica SIL"  "Ani" "AnjaliOldLipi" "Chilanka"  "DejaVu Sans"            
"DejaVu Sans Mono" "DejaVu Serif" "Droid Sans Fallback" "Dyuthi" 

如何安装我需要的 Courier 字体?

我跑:

标签: rrstudio

解决方案


只需将样式添加到 .Rmd 文件中的 yaml 定义中,如下所示:

---
title: "R Notebook"
output:
  html_document:
    css: style.css
---

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.

style.css然后在同一文件夹中创建一个文件并粘贴此代码:

body{
  font-family: "Courier New", Courier, monospace;
  font-size: 16pt;
}

然后重新编织它,它会工作。

如果 Courier 字体不在您的 Ubuntu 系统中,您可以通过此处安装它


推荐阅读