How to know the fonts supported by commonality.cloud?

Question:

I would like to know which fonts are supported either by wordcloud or commonality.cloud.

I imported some fonts with the package below but many of them don't work.

install.packages("extrafont")
library(extrafont)
font_import()

Below is a code example for the word cloud.

commonality.cloud(mydata, 
                  colors = "black", 
                  scale= c(32,4) ,
                  random.order=FALSE,
                  vfont=c("Fontes_suportadas","plain"))

Answer:

The only fonts supported by commonality.cloud (as well as wordclouds) are the fonts from the Hershey family, which has as its main advantage the fact that each character is described as a set of dots (they are vector fonts), and rendering this character means join these dots with a line. With this, we avoid the size problem (since it is vector, there is no pixelation effect) and when plotting a rotated character, the appearance is better.

The following typefaces and fontindex are supported:

  • typeface: 'serif' | fontindex: {'plain', 'italic', 'bold', 'bold italic', 'cyrillic', 'oblique cyrillic', 'EUC'}

  • typeface: 'sans serif' | fontindex: {'plain', 'italic', 'bold', 'bold italic'}

  • typeface: 'script' | fontindex: {'plain', 'italic', 'bold'}

  • typeface: 'gothic english' | fontindex: {'plain'}

  • typeface: 'gothic german' | fontindex: {'plain'}

  • typeface: 'gothic italian' | fontindex: {'plain'}

  • typeface: 'serif symbol' | fontindex: {'plain', 'italic', 'bold'}

  • typeface: 'sans serif symbol' | fontindex: {'plain', 'italic'}

Example:

library(tm)
library(wordcloud)

data(SOTU)
corp <- SOTU

term.matrix <- TermDocumentMatrix(corp)
term.matrix <- as.matrix(term.matrix)
commonality.cloud(term.matrix, 
                  colors = "black", 
                  scale= c(32,4) ,
                  random.order=FALSE,
                  vfont=c("sans serif","plain"))

For more information, ?Hershey

Scroll to Top