Hi,

   I am using Extrafont package to install more fonts for my graphs. My
primary graphic tool is ggplot2. I seem to have problem installing the
package, but could not pinpoint where it is.

  I try to follow the instruction here:

https://github.com/wch/extrafont

  I guess (but am not sure) the fonts are successfully installed.

Problem encountered:
1. The following line sometimes yields an error. Sometimes it works.
> pdf("font_plot.pdf", family="Times New Roman", width=4, height=4)
2. The compiler could not find the fonts installed, e.g., Georgia, Impact,
Times New Romans, Arial Black. Error message: "Font family not found in
Windows font database....."
3. The plot could not show up at all. I use RStudio. I need to close
RStudio and reopen it in order to see the plots produced by ggplot2 .

  Could someone provide an example of how Extrafont package is used?
Thanks,

Miao



> rm(list=ls())
> library(ggplot2)
> library(extrafont)
> font_import()
Importing fonts may take a few minutes, depending on the number of fonts
and the speed of the system. Continue? [y/n] y
Scanning ttf files in C:\WINDOWS\Fonts ...
Extracting .afm files from .ttf files...
C:\WINDOWS\Fonts\arial.ttf : ArialMT already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\arialbd.ttf : Arial-BoldMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\arialbi.ttf : Arial-BoldItalicMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\ariali.ttf : Arial-ItalicMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\ariblk.ttf : Arial-Black already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\Braille.ttf : Braille already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\comic.ttf : ComicSansMS already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\comicbd.ttf : ComicSansMS-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cour.ttf : CourierNewPSMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\courbd.ttf : CourierNewPS-BoldMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\courbi.ttf : CourierNewPS-BoldItalicMT already registered
in fonts database. Skipping.
C:\WINDOWS\Fonts\couri.ttf : CourierNewPS-ItalicMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\cwfs.ttf : cwTeXFangSong already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwheib.ttf : cwTeXHeiBold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwkai.ttf : cwTeXKai already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\cwming.ttf : cwTeXMing already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\cwyen.ttf : cwTeXYen already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\Dr.eye phonetic symbol.ttf : Dr-eye-phonetic-symbol
already registered in fonts database. Skipping.
C:\WINDOWS\Fonts\estre.ttf : EstrangeloEdessa already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\framd.ttf : FranklinGothic-Medium already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\framdit.ttf : FranklinGothic-MediumItalic already
registered in fonts database. Skipping.
C:\WINDOWS\Fonts\gautami.ttf : Gautami already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgia.ttf : Georgia already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiab.ttf : Georgia-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiai.ttf : Georgia-Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\georgiaz.ttf : Georgia-BoldItalic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\impact.ttf : Impact already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\kaiu.ttf : DFKaiShu-SB-Estd-BF already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\kartika.ttf : Kartika already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\l_10646.ttf : LucidaSansUnicode already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\latha.ttf : Latha already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\lingoes.ttf : LingoesUnicode already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\liquidcr.ttf : LiquidCrystal already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\lucon.ttf : LucidaConsole already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\mangal.ttf : Mangal-Regular already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\marlett.ttf : Marlett already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\micross.ttf : MicrosoftSansSerif already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\mvboli.ttf : MVBoli already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\pala.ttf : PalatinoLinotype-Roman already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\palab.ttf : PalatinoLinotype-Bold already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\palabi.ttf : PalatinoLinotype-BoldItalic already
registered in fonts database. Skipping.
C:\WINDOWS\Fonts\palai.ttf : PalatinoLinotype-Italic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\phony.ttf : phony already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\raavi.ttf : Raavi already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\shruti.ttf : Shruti already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\Simbrl.ttf : SimBraille already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\simhei.ttf : SimHei already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\sylfaen.ttf : Sylfaen already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\symbol.ttf : SymbolMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tahoma.ttf : Tahoma already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tahomabd.ttf : Tahoma-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci1.ttf : Tci1 already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci1b.ttf : Tci1Bold already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci1bi.ttf : Tci1BoldItalic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci1i.ttf : Tci1Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci2.ttf : Tci2 already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci2b.ttf : Tci2Bold already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci2bi.ttf : Tci2BoldItalic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci2i.ttf : Tci2Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci3.ttf : Tci3 already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci3b.ttf : Tci3Bold already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci3bi.ttf : Tci3BoldItalic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci3i.ttf : Tci3Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci4.ttf : Tci4 already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci4b.ttf : Tci4Bold already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\tci4bi.ttf : Tci4BoldItalic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\tci4i.ttf : Tci4Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\times.ttf : TimesNewRomanPSMT already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\timesbd.ttf : TimesNewRomanPS-BoldMT already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\timesbi.ttf : TimesNewRomanPS-BoldItalicMT already
registered in fonts database. Skipping.
C:\WINDOWS\Fonts\timesi.ttf : TimesNewRomanPS-ItalicMT already registered
in fonts database. Skipping.
C:\WINDOWS\Fonts\trebuc.ttf : TrebuchetMS already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\trebucbd.ttf : TrebuchetMS-Bold already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\trebucbi.ttf : Trebuchet-BoldItalic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\trebucit.ttf : TrebuchetMS-Italic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\tunga.ttf : Tunga-Regular already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\verdana.ttf : Verdana already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\verdanab.ttf : Verdana-Bold already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\verdanai.ttf : Verdana-Italic already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\verdanaz.ttf : Verdana-BoldItalic already registered in
fonts database. Skipping.
C:\WINDOWS\Fonts\vrinda.ttf : Vrinda already registered in fonts database.
Skipping.
C:\WINDOWS\Fonts\webdings.ttf : Webdings already registered in fonts
database. Skipping.
C:\WINDOWS\Fonts\wingding.ttf : Wingdings-Regular already registered in
fonts database. Skipping.
Found FontName for 0 fonts.
Scanning afm files in C:/Program Files/RStudio/R/library/extrafontdb/metrics
> loadfonts()
Registering font with R using pdfFonts(): Arial Black
Registering font with R using pdfFonts(): Arial
Registering font with R using pdfFonts(): Braille
Registering font with R using pdfFonts(): Comic Sans MS
Registering font with R using pdfFonts(): Courier New
Registering font with R using pdfFonts(): cwTeXFangSong
Registering font with R using pdfFonts(): cwTeXHeiBold
Registering font with R using pdfFonts(): cwTeXKai
Registering font with R using pdfFonts(): cwTeXMing
Registering font with R using pdfFonts(): cwTeXYen
Registering font with R using pdfFonts(): DFKai-SB
Registering font with R using pdfFonts(): Dr.eye phonetic symbol
Registering font with R using pdfFonts(): Estrangelo Edessa
Registering font with R using pdfFonts(): Franklin Gothic Medium
Registering font with R using pdfFonts(): Gautami
Registering font with R using pdfFonts(): Georgia
Registering font with R using pdfFonts(): Impact
Registering font with R using pdfFonts(): Kartika
Registering font with R using pdfFonts(): Latha
Registering font with R using pdfFonts(): Lingoes Unicode
Registering font with R using pdfFonts(): LiquidCrystal
Registering font with R using pdfFonts(): Lucida Console
Registering font with R using pdfFonts(): Lucida Sans Unicode
Registering font with R using pdfFonts(): Mangal
Registering font with R using pdfFonts(): Marlett
Registering font with R using pdfFonts(): Microsoft Sans Serif
Registering font with R using pdfFonts(): MV Boli
Registering font with R using pdfFonts(): Palatino Linotype
Registering font with R using pdfFonts(): phony
Registering font with R using pdfFonts(): Raavi
Registering font with R using pdfFonts(): Shruti
Registering font with R using pdfFonts(): SimBraille
Registering font with R using pdfFonts(): SimHei
Registering font with R using pdfFonts(): Sylfaen
Registering font with R using pdfFonts(): Symbol
Registering font with R using pdfFonts(): Tahoma
Registering font with R using pdfFonts(): tci1
Registering font with R using pdfFonts(): tci2
Registering font with R using pdfFonts(): tci3
Registering font with R using pdfFonts(): tci4
Registering font with R using pdfFonts(): Times New Roman
Registering font with R using pdfFonts(): Trebuchet MS
Registering font with R using pdfFonts(): Tunga
Registering font with R using pdfFonts(): Verdana
Registering font with R using pdfFonts(): Vrinda
Registering font with R using pdfFonts(): Webdings
Registering font with R using pdfFonts(): Wingdings
> x1<-1:4
> y1<-6:9
> df00<-data.frame(cbind(x1,y1))
> pdf("font_plot.pdf", family="Times New Roman", width=4, height=4)
Unknown Characters 221

Unknown Characters 221

Unknown Characters 221

Unknown Characters 221

Warning messages:
1: In pdf("font_plot.pdf", family = "Times New Roman", width = 4, height =
4) :
  unknown AFM entity encountered
2: In pdf("font_plot.pdf", family = "Times New Roman", width = 4, height =
4) :
  unknown AFM entity encountered
3: In pdf("font_plot.pdf", family = "Times New Roman", width = 4, height =
4) :
  unknown AFM entity encountered
4: In pdf("font_plot.pdf", family = "Times New Roman", width = 4, height =
4) :
  unknown AFM entity encountered
> pdf("font_plot.pdf", family="Impact", width=4, height=4)
Unknown Characters 222

Unknown Characters 222

Unknown Characters 222

Unknown Characters 222

Warning messages:
1: In pdf("font_plot.pdf", family = "Impact", width = 4, height = 4) :
  unknown AFM entity encountered
2: In pdf("font_plot.pdf", family = "Impact", width = 4, height = 4) :
  unknown AFM entity encountered
3: In pdf("font_plot.pdf", family = "Impact", width = 4, height = 4) :
  unknown AFM entity encountered
4: In pdf("font_plot.pdf", family = "Impact", width = 4, height = 4) :
  unknown AFM entity encountered

> p12<-ggplot(df00, aes(x=x1,
y=y1))+geom_line(color="blue")+ggtitle("MYXLAB")+theme_bw()
> p23<-p12+ theme(plot.title = element_text(family="Times New Roman"))
> p23

	[[alternative HTML version deleted]]

