In the pieces of text created programmatically I would like to be able to fix that the text is done in one of the styles available in the special characters palette, such as Gothic. It may be useful in preparation of a demonstration or making a title of say, a panel and so on. Is it possible?
1 Answer
Edit:
Quoting from Heike´s comment: "The font families used for Greek, script, gothic, and double struck symbols are respectively "Mathematica1", "Mathematica5", "Mathematica6", and "Mathematica7" "
With this knowledge, just use Style
together with the FontFamily
option:
Style["Doth this help?", FontFamily -> "Mathematica6",
FontSize -> 100]
Now for my first version, which seems like prime obfuscation. The one benefit is that characters that are not in the special fonts do not get replaced. So I´ll leave this for purely educational purposes:
text = "Hello world!";
gothic = StringReplace[
text, {x_?UpperCaseQ :>
ToString @ ToExpression["\\[GothicCapital" <> x <> "]"],
x_?LowerCaseQ :>
ToString @ ToExpression["\\[Gothic" <> ToUpperCase[x] <> "]"]}];
Style[gothic, 30]
You can get the right prefixes for this solution by looking at the FullForm of your favorite special character (here: Gothic
or GothicCapital
).
-
6$\begingroup$ I don't have much to add to Yves' solution except that the font families used for Greek, script, gothic, and double struck symbols are respectively
"Mathematica1"
,"Mathematica5"
,"Mathematica6"
, and"Mathematica7"
, so so to get double struck text you can do something likeStyle["This is some text", FontFamily -> "Mathematica7", FontSize -> 30]
. $\endgroup$– HeikeMar 26, 2012 at 16:02 -
$\begingroup$ Knowing that now, the first part of my answer looks a bit silly (but I did warn). I' d say your comment should be elevated to answer status. $\endgroup$ Mar 26, 2012 at 16:28
-
$\begingroup$ @Heike I added your comment to the answer. Hope that is all right. And while I´m at it: Is there a way to get a characters font programmatically? $\endgroup$ Mar 26, 2012 at 17:14
-
2$\begingroup$ Yes that's fine. I don't know how to get a font of a character programmatically I'm afraid. I found the corresponding fonts in the file
UnicodeFontMapping.tr
located in$InstallationDirectory/SystemFiles/FrontEnd/TextResources
$\endgroup$– HeikeMar 26, 2012 at 17:42 -
4$\begingroup$ By the way, you can get a list of all available fonts in Mathematica with
FE`Evaluate[FEPrivate`GetPopupList["MenuListFonts"]]
$\endgroup$– HeikeMar 26, 2012 at 18:05