15
$\begingroup$

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?

$\endgroup$

1 Answer 1

20
$\begingroup$

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 Styletogether with the FontFamily option:

Style["Doth this help?", FontFamily -> "Mathematica6", 
      FontSize -> 100]

Mathematica graphics

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]

Mathematica graphics

You can get the right prefixes for this solution by looking at the FullForm of your favorite special character (here: Gothic or GothicCapital).

$\endgroup$
5
  • 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 like Style["This is some text", FontFamily -> "Mathematica7", FontSize -> 30]. $\endgroup$
    – Heike
    Commented Mar 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$
    – Yves Klett
    Commented 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$
    – Yves Klett
    Commented 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$
    – Heike
    Commented Mar 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$
    – Heike
    Commented Mar 26, 2012 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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