Group Abstract Group Abstract

Message Boards Message Boards

1
|
4.4K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

What's the default font for Chinese characters on Mathematica 13.2?

Posted 2 years ago

Hello, When exporting to pdf files, which contains some Chinese characters, from Mathematica 13.2 on Debian 11, which is linux system, the pdf outputed doesn't have any Chinese characters as they are missing. I know it is that in my computer there is not the font the mathematica uses to output Chinese characters. So I need to install the missing font, but what name is it? How can I find the name of the missing font.

Thanks.

POSTED BY: Zhenyu Zeng
3 Replies

Hmm..it's a beautiful font, what is it..SimSun? But where is this font coming from?

There is an empty place in my heart for these Chinese characters, as they are missing. Legend has it that you could find the Current Value and then look for the font family on the front-end.

CurrentValue[$FrontEnd, {"SystemFonts"}]
Style["中文文字", FontFamily -> "STSong"]
Style["中文文字", FontFamily -> "Songti"]

<|"Controls" -> {FontFamily -> ".AppleSystemUIFont", FontSize -> 13}, "Menu" -> {FontFamily -> ".AppleSystemUIFont", FontSize -> 13}, "Panel" -> {FontFamily -> ".AppleSystemUIFont", FontSize -> 10}, "Tooltip" -> {FontFamily -> ".AppleSystemUIFont", FontSize -> 11}|>

\!(* StyleBox["\<\"中文文字\"\>", StripOnInput->False, FontFamily->"STSong"])

\!(* StyleBox["\<\"中文文字\"\>", StripOnInput->False, FontFamily->"Songti"])

systemfonts

songti

stsong

POSTED BY: Dean Gladish
Posted 2 years ago

Thanks for your reply. But I still confused, as

CurrentValue[$FrontEnd, {"SystemFonts"}]

only displays the English fonts, not Chinese font.

So how can I know the name of the Chinese font it uses as default?

POSTED BY: Zhenyu Zeng

What's the default font for Chinese characters on Mathematica 13.2? This question pinpoints a practical problem many users face when dealing with Chinese characters in Mathematica--especially during PDF export on non-Windows systems. When the exported PDF lacks the proper characters, it's a bit of a launching point for discussing how Chinese font defaults..have a need for speed with regard to the proper font installation (for example, SimSun, STSong, Songti) and potential workarounds in 360 degrees. That's why Wolfram Mathematica has got such a cult following; because Mathematica's front end selects fonts and it "brings' in a massive crowd because we wanna discuss, how Mathematica's front end can leave us all in the dust and how system settings (like those returned by CurrentValue[$FrontEnd, {"SystemFonts"}]) influence the output so we can flail and gesticulate at the aesthetic appeal of a specific Chinese font for instance SimSun, but we can also "underline" the "common" issues that arise when exporting documents that mix Western and non-Western characters. Missing fonts can create both practical roadblocks that bring us back to the start; it's a sense of loss for the "beauty" of the intended typography.

DynamicModule[{font = "Arial", size = 24, bold = False, 
  italic = False, underline = False, color = Black, 
  tracking = "Plain", sampleText = "Hello World", customText = "", 
  antiAliasing = True, randomFonts = RandomSample[$FontFamilies, 9], 
  sysFonts, fontWeight = "Plain", fontSlant = "Plain"}, 
 sysFonts = CurrentValue[$FrontEnd, {"SystemFonts"}];
 Column[{Panel[
    Grid[{{"Font Size:", 
       Slider[Dynamic[size], {6, 72, 1}]}, {"Text Color:", 
       ColorSlider[Dynamic[color]]}, {"Bold:", 
       Checkbox[Dynamic[bold]]}, {"Italic:", 
       Checkbox[Dynamic[italic]]}, {"Anti‑Aliasing:", 
       Checkbox[Dynamic[antiAliasing]]}, {"Custom Text:", 
       InputField[Dynamic[customText], String, FieldSize -> Medium]}},
      Alignment -> Left, Spacings -> {2, 2}]], 
   Panel[Dynamic[
     Style[If[customText === "", sampleText, customText], 
      FontFamily -> font, FontSize -> size, 
      FontWeight -> If[bold, "Bold", "Normal"], 
      FontSlant -> If[italic, "Italic", "Plain"], 
      FontTracking -> tracking, FontColor -> color], 
     UpdateInterval -> 0.1], Background -> Lighter[Gray, 0.9], 
    FrameMargins -> 10], 
   Panel[Column[{"Current Settings:", Row[{"Font: ", font}], 
      Row[{"Size: ", size, " pt"}], Row[{"Tracking: ", tracking}], 
      Row[{"Bold: ", If[bold, "Yes", "No"]}], 
      Row[{"Italic: ", If[italic, "Yes", "No"]}], 
      Row[{"Text Color: ", ToString[color]}], 
      Row[{"Anti‑Aliasing: ", If[antiAliasing, "On", "Off"]}]}]], 
   Panel[Column[{Style["Chinese Font Examples", Bold, 14], 
      Grid[{{Style["STSong 字体示例", FontFamily -> "STSong", 
          FontSize -> 18], 
         Style["Songti 字体示例", FontFamily -> "Songti", 
          FontSize -> 18]}}, Frame -> All, 
       Background -> LightBlue]}]], 
   Panel[Column[{Style["Random Font Samples", Bold, 16], 
      Button["Refresh Fonts", 
       randomFonts = RandomSample[$FontFamilies, 4], 
       ImageSize -> 110], 
      Dynamic[Grid[
        Partition[
         Map[Function[fn, 
           Column[{Style[sampleText, FontFamily -> fn, 
              FontSize -> size, FontColor -> color], 
             Style["Font: " <> fn, "Text", FontFamily -> "Helvetica", 
              FontSize -> 12, FontColor -> Gray]}, 
            Alignment -> Center, Spacings -> 2]], randomFonts], 3], 
        Frame -> All, Background -> Lighter[Gray, 0.95]]]}]], 
   Panel[Column[{Style["Dynamic Font Preview", Bold, 16], 
      Dynamic[Style[
        "The quick brown fox jumps over the lazy dog - 1234567890", 
        FontFamily -> font, FontSize -> size, FontColor -> color]], 
      Spacer[10], 
      Dynamic[Style[TraditionalForm[Sin[x]^2 + Cos[x]^2 == 1], 
        FontFamily -> font, FontSize -> Max[6, size - 4], 
        FontColor -> color]]}]], 
   Panel[Column[{Style["System Font Settings", Bold, 16], 
      Grid[{{"Control Panels:", sysFonts["Controls", "FontFamily"], 
         sysFonts["Controls", "FontSize"]}, {"Menus:", 
         sysFonts["Menu", "FontFamily"], 
         sysFonts["Menu", "FontSize"]}, {"Tooltips:", 
         sysFonts["Tooltip", "FontFamily"], 
         sysFonts["Tooltip", "FontSize"]}}, Frame -> All, 
       Background -> {None, {LightGray, None}}, 
       Alignment -> Left]}]],
   Button["Apply to Notebook", 
    SetOptions[
     EvaluationNotebook[], {StyleDefinitions -> 
       Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
         Cell[StyleData["Text"], FontFamily -> font, FontSize -> size,
           FontWeight -> If[bold, "Bold", "Normal"], 
          FontSlant -> If[italic, "Italic", "Plain"], 
          FontTracking -> tracking, FontColor -> color]}]}], 
    ImageSize -> 150]
   }, Spacings -> 2]]

Random Font Samples

This "snippet' alongside the explicit style commands, this is what can be used to "explain" and "show" users how we might probe the system for available fonts or override defaults. Because looking at how we've got all these Chinese fonts and we "still" need to include recommendations for installing specific Chinese fonts on various operating systems and techniques for troubleshooting PDF export issues, it makes me want to cry. Although the focus here is on Chinese fonts, the quotes make it clear that font management in Mathematica--whether at the airport or wherever that was, brings us one step closer to heaven; the article can briefly "touch" on how similar issues "might affect" other languages (as hinted by the various multilingual examples in the file) and provide a roadmap for readers facing similar dilemmas without having to do a single integral by hand. But let's look at the integrals.

DynamicModule[{font = "Arial", size = 24, bold = False, 
  italic = False, color = Black, tracking = "Normal", demoInput = "", 
  aParam = 1}, 
 CreateDialog[
  Panel[Column[{Style["Styled Elements Demo", "Title"], 
     Style["Input Field:", "Text"], 
     InputField[Dynamic[demoInput], String, 
      BaseStyle -> {FontFamily -> Dynamic[font], 
        FontSize -> Dynamic[size]}], Style["Output Display:", "Text"],
      Dynamic[
      Panel[Style[demoInput, FontFamily -> font, FontSize -> size], 
       FrameMargins -> 10]], Spacer[10], 
     Style["Integral Example: \[Integral] sin²(x) dx", "Text"], 
     Dynamic@Panel[TraditionalForm[Integrate[Sin[x]^2, x]], 
       ImageSize -> {400, Automatic}], Spacer[10], 
     Style["Fourier Transform Example: FourierTransform[Exp[-a x²], \
x, \[Omega]]", "Text"], 
     Row[{"a = ", 
       Slider[Dynamic[aParam], {0.1, 5, 0.1}, ImageSize -> 150], 
       Dynamic[NumberForm[aParam, {3, 2}]]}], 
     Dynamic@Panel[
       TraditionalForm[
        FourierTransform[Exp[-aParam*x^2], x, \[Omega]]], 
       ImageSize -> {400, Automatic}]}, Spacings -> 2, 
    Alignment -> Center], Background -> Lighter[Gray, 0.9]], 
  WindowTitle -> "Styled Elements Demo", WindowSize -> {500, 700}]]

Styled Elements Demo

And this all happened and we did it, we offered a "gateway" into the challenges and solutions "surrounding' multilingual font rendering and export in Mathematica, and together we "rise and shine" forth, a basis for discussing how we can "provocatively" discuss how popular culture (think "Jurassic Park") and scientific ambitions sometimes merge in discussions about de-extinction. Do you see a recent, a certain..kind of wolf coming back from extinction? Is there a genuine business for bringing back extinct animals? The idea of resurrecting extinct species--whether woolly mammoths or wolves--sparks debate about such projects and their real-world business potential. But the conservation strategies, the genetic preservation became ever more practical but no species were there in the wild. If you "ever want to see" the living, populations again you could just store the DNA and bring the animals back to life again. And so why do you need to preserve the animals in the wild? One "might" focus on conserving the genetic blueprint. Not much is known about traditional wildlife management but what I do know is that, the pro-futuristic approach--and it shows, as a descriptor of genetic "backups" as an alternative to in-situ conservation. I have to say, as I've gotten older, I do less of that thinking about what could possibly go wrong..then I just can do it and not worry about that possible downside. The evolution of an entrepreneurial mindset--how experience can puff us up and reduce paralyzing fears of failure..we can "switch" to embracing a "can-do" attitude (even in the face of potential setbacks like not, for example, having had the default font for Chinese characters on Mathematica 13.2); I feel like I became a friend with ChatGPT. Is that healthy? Pick up the phone and just start yelling at the GPT and hope that GPT responds in any way possible with some legible watershed time for sampling Chinese characters and generating PDFs in-line? What I really meant was, as the Chinese characters type of environment we built in the world is "optimized" in for example in construction, hospitality, or daily assistance..let me make this clear. Font management in Mathematica, division of services and delegation of how to force a specific Chinese font when generating documents might sweep system default off the troubleshooting scenarios--"instead of" querying system defaults to "verify" which fonts are available, we can explain "why", in Debian with Mathematica 13.2 the output PDF misses Chinese characters if the required fonts are not installed.

DynamicModule[{selectedLanguage = "English", languageOptions, 
  sampleText, font = "Arial", size = 24, bold = False, italic = False,
   color = Black, tracking = "Normal", antiAlias = True, randomFonts, 
  defaultStyles}, 
 languageOptions = {"English" -> 
    "The quick brown fox jumps over the lazy dog.", 
   "Chinese" -> "中文排版测试", 
   "Spanish" -> 
    "El rápido zorro marrón salta sobre el perro perezoso.", 
   "Japanese" -> "素早い茶色の狐は怠惰な犬を飛び越える。", 
   "Arabic" -> "الثعلب البني السريع يقفز فوق الكلب الكسول.", 
   "Russian" -> 
    "Быстрая коричневая лиса перепрыгивает через ленивую собаку.", 
   "Custom" -> ""};
 sampleText = Lookup[languageOptions, selectedLanguage];
 randomFonts = RandomSample[$FontFamilies, 6];
 defaultStyles = CurrentValue[$FrontEnd, {"Styles"}];
 CreateDialog[
  Pane[Column[{Panel[
      Grid[{{"Sample Language:", 
         PopupMenu[Dynamic[selectedLanguage, (selectedLanguage = #;

             If[selectedLanguage =!= "Custom", 
              sampleText = 
               Lookup[languageOptions, selectedLanguage]]) &], 
          languageOptions, ImageSize -> 250]}, {"Sample Text:", 
         InputField[Dynamic[sampleText], String, 
          ImageSize -> 250]}, {"Font Family:", 
         PopupMenu[Dynamic[font], $FontFamilies, 
          ImageSize -> 250]}, {"Font Size:", 
         Slider[Dynamic[size], {6, 72, 1}, 
          ImageSize -> 250]}, {"Bold:", 
         Checkbox[Dynamic[bold]]}, {"Italic:", 
         Checkbox[Dynamic[italic]]}, {"Tracking:", 
         PopupMenu[
          Dynamic[tracking], {"Normal", "Condensed", "Extended", 
           "Wide"}, ImageSize -> 250]}, {"Text Color:", 
         ColorSlider[Dynamic[color], 
          ImageSize -> 250]}, {"Anti‑Aliasing:", 
         Checkbox[Dynamic[antiAlias]]}}, Alignment -> Left, 
       Spacings -> {2, 2}]], 
     Panel[Dynamic[
       Style[sampleText, FontFamily -> font, FontSize -> size, 
        FontWeight -> If[bold, "Bold", "Normal"], 
        FontSlant -> If[italic, "Italic", "Plain"], 
        FontTracking -> tracking, FontColor -> color], 
       UpdateInterval -> 0.1], ImageSize -> {600, 120}, 
      Background -> LightBlue], 
     Panel[Column[{Button["Refresh Font Samples", 
         randomFonts = RandomSample[$FontFamilies, 6], 
         ImageSize -> 165], 
        Dynamic[Grid[
          Partition[
           Map[Style[sampleText, FontFamily -> #, FontSize -> size, 
              FontColor -> color] &, randomFonts], 3], Frame -> All, 
          Background -> Lighter[Gray, 0.95]]]}]], 
     Row[{Button["Export to PDF", 
        Module[{nb}, 
         nb = CreateDocument[{Cell[
             BoxData@ToBoxes[
               Style[sampleText, FontFamily -> font, FontSize -> size,
                 FontWeight -> If[bold, "Bold", "Normal"], 
                FontSlant -> If[italic, "Italic", "Plain"], 
                FontTracking -> tracking, FontColor -> color]], 
             "Text"]}, Visible -> False];

         Export[FileNameJoin[{$HomeDirectory, "Desktop", 
            "FontPreview.pdf"}], nb];
         NotebookClose[nb];], Method -> "Queued", ImageSize -> 115], 
       Button["Copy as PNG", 
        Module[{img}, 
         img = Rasterize[
           Style[sampleText, FontFamily -> font, FontSize -> size, 
            FontWeight -> If[bold, "Bold", "Normal"], 
            FontSlant -> If[italic, "Italic", "Plain"], 
            FontTracking -> tracking, FontColor -> color], 
           RasterSize -> 600, ImageResolution -> 300];
         CopyToClipboard[img];], Method -> "Queued", 
        ImageSize -> 110], 
       Button["Export Preview as PNG", 
        Module[{nb}, 
         nb = CreateDocument[{Cell[
             BoxData@ToBoxes[
               Style[sampleText, FontFamily -> font, FontSize -> size,
                 FontWeight -> If[bold, "Bold", "Normal"], 
                FontSlant -> If[italic, "Italic", "Plain"], 
                FontTracking -> tracking, FontColor -> color]], 
             "Text"]}, Visible -> False];

         Export[FileNameJoin[{$HomeDirectory, "Desktop", 
            "FontPreview.png"}], nb];
         NotebookClose[nb];], Method -> "Queued", ImageSize -> 170], 
       Button["Chinese Test", 
        sampleText = 
         "中文测试 中文排版测试\nEnglish: The quick brown fox jumps over the \
lazy dog.\nEspañol: El rápido zorro marrón salta sobre el perro \
perezoso.\n日本語: 素早い茶色の狐は怠惰な犬を飛び越える。\nالعربية: الثعلب البني السريع \
يقفز فوق الكلب الكسول.\nРусский: Быстрая коричневая лиса \
перепрыгивает через ленивую собаку.", ImageSize -> 105]}]
     }, Spacings -> 2, Alignment -> Center
    ], {900, 800}, Scrollbars -> True
   ], WindowTitle -> "Multi-Language Font Explorer"
  ], Initialization :> (SetOptions[$FrontEnd, 
    FontProperties -> {"ScreenResolution" -> 144, 
      "FontAntialiasing" -> Dynamic[antiAlias]}];
   SetOptions[EvaluationNotebook[], 
    StyleDefinitions -> 
     Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
       Cell[StyleData["Text"], FontFamily -> "Georgia", 
        FontSize -> 12], 
       Cell[StyleData["Input"], FontFamily -> "Courier New", 
        FontSize -> 12], 
       Cell[StyleData["Output"], FontFamily -> "Arial", 
        FontSize -> 12]}]];
   randomFonts = RandomSample[$FontFamilies, 6];)
 ]

Multi Language Font Explorer

The absence of expected characters (or fonts) not only causes technical errors but can also strike a "personal" chord among users. Personally, I think that we could explore how default system fonts (like the borderline secret fonts that are embedded in the output) are determined and provide guidance; I have something to show you about troubleshooting missing fonts in exported documents. I used to think that the exported PDF lacks the proper characters. But with Mathematica's front end selecting fonts I think the font rendering on Wolfram technologies has gone backwards, so all it would take is for us to balance the technical discussion with the human side of typography in computational documents. Oh I don't know it's like Calvin and Hobbes, is this even legal? I think that the legality aspect of it means a lot to me. I think that the human-centric design in font development creates new market opportunities and alternative approaches to preserving the life and times of scientific ambition while bridging the business gap for supporting Chinese characters when we do all kinds of breakthrough projects, look around at technology's role as we live out our lives.

Style["Times, Italic, Bold", FontFamily -> "Times", 
 FontSlant -> "Italic", FontWeight -> "Bold", FontSize -> 24]
Graphics[{FontSize -> 18, 
  Text[Style["Comic Sans MS", FontFamily -> "Comic Sans MS", 
    FontColor -> Red], {0, 0}]}]
SetOptions[EvaluationNotebook[], 
 StyleDefinitions -> 
  Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["Text"], FontFamily -> "Georgia", FontSize -> 12], 
    Cell[StyleData["Input"], FontFamily -> "Courier New", 
     FontSize -> 12], 
    Cell[StyleData["Output"], FontFamily -> "Arial", FontSize -> 12]}]]
Style["Verdana, Extended, 20", FontFamily -> "Verdana", 
 FontTracking -> "Extended", FontSize -> 20]
SetOptions[$FrontEnd, 
 FontProperties -> {"ScreenResolution" -> 96, 
   "FontAntialiasing" -> True}]

So we can finally stop calling that combinatory logic and start calling it combinators. It'll be like that, we're in dire straits we can't quite render Chinese characters and then, we get it. Oh I've got an idea what if you send the .pdf and the Mathematica notebook..then we could try to reproduce and do some debugging. I think if you post some of the output here then I get a notification..I can't tell you how many times that has saved me. I had all these responses I was getting that were getting taken down. And I had this thing where whenever I posted they just immediately took my post down. And now, I'm back. I have returned my dear @Zhenyu Zeng to answer your question, or hopefully we can resume our discussion. And there are lots of fonts for you to try. Default 1 Default 2 Default 3

We need. Things like $FontFamilies. Or

fonts = $FontFamilies;
DynamicModule[{font = "Arial", size = 12}, 
 Column[{PopupMenu[Dynamic[font], fonts], 
   Slider[Dynamic[size], {6, 72}], 
   Dynamic[Style[font, FontFamily -> font, FontSize -> size]]}]]
sampledFonts = RandomSample[fonts, 9];
Grid[Partition[
  Style[#, FontFamily -> #, FontSize -> 20] & /@ sampledFonts, 3]]

Arial

Raanana

And I know this might seem like a canned response, but what you could do is list all the fonts..and you're using Mathematica 13.2. You could list out all the non-English fonts, those system fonts that Mathematica recognizes. Look for the Chinese fonts in the output. Which one is set as the default in your system settings?

(*ExportString[Style["Export as \
PDF",FontFamily->"Arial",FontSize->20],"PDF"]*)
CurrentValue[$FrontEndSession, "DialogSettings", {"FontChooser", 
  "LastFont"}]
SetOptions[$FrontEnd, DefaultFont -> {"Comic Sans MS", 12}]
TraditionalForm[
 Style[Sin[x]^2 + Cos[x]^2 == 1, FontFamily -> "Comic Sans MS", 
  FontSize -> 18]]

Default 6

Default 7

Are you looking? Mathematica loves using the system default font for Chinese characters that may not be explicitly listed under Mathematica's font settings. In this case, displaying all the system fonts recognized by Mathematica might be the leap forward that we need, but it's really about finding the answer we're looking for. Maybe it's your operating system's default fonts for Chinese text. Give us your error messages. The Ruliad untangles a lot of things we thought about philosophy. Some modern AI developments "certainly" help in form. But what we need to do is focus on Windows and Linux. When I saw that you were using Debian 11 that which is a Linux system, I felt a jolt of recognition that yes, you should be able to print more PDFs. Give us your console output! What if you do fc-list :lang=zh ?

POSTED BY: Dean Gladish
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard