8
$\begingroup$

I recently suggested creating dynamic community ads with Wolfram Cloud. @C.E. made a proof of concept ad to show that it works well.

Fonts are an important part of graphics design. It is useful to know which ones we can use for generating graphics using the cloud service.

Question: Which fonts can be used in Wolfram Cloud?


To clarify, when using the web interface, Style["FooBar", FontFamily -> someFont] works with any font that is installed locally on my computer and that my browser has access to. But Rasterize@Style[..., FontFamily -> ...] only works with fonts which are installed in the cloud. Which are these?

Alternatively, from Mathematica, which fonts work with CloudEvaluate[Rasterize@Style[..., FontFamily -> ...]]?

$\endgroup$
6
$\begingroup$

A partial and likely incomplete answer to this is the following:

fonts = FileNameTake /@ 
   FileNames@
    FileNameJoin[{$InstallationDirectory, "SystemFiles", "Fonts", 
      "TrueType", "*"}];

names = Union@Flatten[
  StringCases[#, StartOfString ~~ Shortest[name__] ~~ "-" :> name] & /@
    fonts
  ]

In the cloud this yields the following list:

{AlegreyaSC, ClearSans, Cousine, DroidSerif, 
 EBGaramond08, EBGaramond12, EBGaramondSC08, EBGaramondSC12,
 Economica, Felipa, Inconsolata, Kalam, 
 Lato, LeagueGothic, Mathematica, MathematicaMono, MathematicaSans,
 Oswald, PlayfairDisplay, Roboto, RobotoCondensed, RobotoSlab, 
 ShadowsIntoLightTwo, SourceCodePro, SourceSansPro, SourceSerifPro, 
 TitilliumWeb, VeraMono, YanoneKaffeesatz}

We can test these like so:

CloudEvaluate[Rasterize@Style["Font name: " <> #, FontFamily -> #]] & /@ names

This test reveals that Mathematica, MathematicaMono, and MathematicaSans cannot be used with general text. The rest seem to work.

Additionally, we can try these:

$FontFamilies

{Arial,Courier,Gill Sans,Helvetica,Source Sans Pro,Times New Roman,Trebuchet MS}

Of these, at least Arial, Helvetica and Trebuchet MS are not available. They fall back to the default font which looks different from any of these.


This is a naive function to try to test whether a certain font name is available (or rather: whether it renders differently from the default).

CloudEvaluate@Module[{rast},
   rast = 
    Rasterize[
      Style["Abcd Efgh Ijkl Opqr Stuv Wzyx ", FontFamily -> #, 
       FontSize -> 20], "Image"] &;
   # -> (ImageData[rast["not a font"]] != ImageData[rast[#]])
   ] &
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.