How to know the fonts supported by commonality.cloud?

Asked

Viewed 60 times

3

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 an example of code for the word cloud.

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

1 answer

1


The only sources supported by commonality.cloud (just like wordclouds) are the sources of the Hershey family, which has the main advantage that each character is described as a set of points (are the vector sources), and rendering this character means joining these points with a line. With this, we avoid the size problem (as it is vector there is no pixelization 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

  • Amazing reply. Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.