Skip to content

Instantly share code, notes, and snippets.

@GitaiQAQ
Created August 23, 2017 04:35
Show Gist options
  • Save GitaiQAQ/99a89fddccd992e367fcce9f0889d086 to your computer and use it in GitHub Desktop.
Save GitaiQAQ/99a89fddccd992e367fcce9f0889d086 to your computer and use it in GitHub Desktop.
An example R script that will generate a table of all the fonts rendered so you can compare them a little easier between the 2 systems.
fonttable <- read.table(header=TRUE, sep=",", stringsAsFactors=FALSE,
text='
Short,Canonical
mono,Courier
sans,Helvetica
serif,Times
serif,Times
,AvantGarde
,Bookman
,Helvetica-Narrow
,NewCenturySchoolbook
,Palatino
,URWGothic
,URWBookman
,NimbusMon
URWHelvetica,NimbusSan
,NimbusSanCond
,CenturySch
,URWPalladio
URWTimes,NimbusRom
,思源宋体
,文泉驿等宽微米黑
')
fonttable$pos <- 1:nrow(fonttable)
library(reshape2)
fonttable <- melt(fonttable, id.vars="pos", measure.vars=c("Short","Canonical"),
variable.name="NameType", value.name="Font")
# Make a table of faces. Make sure factors are ordered correctly
facetable <- data.frame(Face = factor(c("plain","bold","italic","bold.italic"),
levels = c("plain","bold","italic","bold.italic")))
fullfonts <- merge(fonttable, facetable)
library(ggplot2)
pf <- ggplot(fullfonts, aes(x=NameType, y=pos)) +
geom_text(aes(label=Font, family=Font, fontface=Face)) +
facet_wrap(~ Face, ncol=2)
png('fonttable.png', height = 1080, width = 1024, res = 120)
print(pf)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment