setting a new font when using the Word_cloud package


possibly a dumb question !

In using A Mueller's word_cloud package (github link) he says you can change font by using font_path, and this should point a file containing truetype font. e.g. arial.ttf.

In using this on PythonAnywhere - are there .ttf files provided somewhere and if so where ? Or do I need to find the .ttf file myself and if so where would I find it (it just so happened that Arial is the one I am looking for, but also interested in the general case.

Hi there, you'll find some system-installed ttf files in /usr/share/fonts/truetype/ . you can also download your own if you like...

Thanks Harry ! I notice the fonts there don't include Arial. Looking on the internet, it looks like the .ttf files have to be either bought or downloaded from some dubious looking websites. Can you give me any guidance as to how to go about finding a reputable source of the .ttf for Arial. If I have to pay I will, (definitely don't want to use some of the dubious looking website), but would rather find something FOSS.

This website has a list of FOSS equivalents for popular fonts -- it looks like Liberation Sans is a good match for Arial. You can download the TTF on the official page for the Liberation fonts. Google's Arimo is also similar, and looks like it has a slightly looser license

Thanks Giles, Helpful. The documentation on Liberation looks a bit daunting, but Ill give it a try.

Good luck! Let us know how you get on.


that turned out to be a lot less daunting than expected.

Simple as :

  • download tarball of the Liberation fonts, then upload to PA files
  • decompress with "tar zxvf liberation-fonts-[VERSION].tar.gz"
  • that creates a sub-directory ... and voila ... all the ttf files are there !

This now seems to work well with 'wordcloud' package (sorry I incorrectly spelt as 'word_cloud' earlier) - which by the way is well worth checking out if you want to create a very pleasant word cloud !

Excellent! Glad you got it working, and thanks for posting the details.