# Mathematica 10.4 crashes when using too many font sizes

While working on How to make the digits of π go around in a spiral like this? I encountered a problem that Mathematica would crash at regular intervals with an internal self-test error, either NoteFont2 or winFont. After lots of trial and error (and restarting Mathematica dozens of times) I have managed to break it down to a minimal (not-)working example:

Graphics[
MapIndexed[
Style[
Text[#],
FontSize -> 20.1*0.999^(#2[[1]])
] &,
RandomInteger[9, 4000]
]
]


My theory is that Mathematica crashes once it had to use too many different font sizes in the same session. This is because you can also provoke the crash by reducing the 4000 to a smaller number and running the code multiple times with different values for 20.1, whereas if you run it over and over for 1000 samples say but without changing the 20.1, the error will not occur. Interestingly, when you use 20 instead of 20.1, 4000 samples won't suffice for a crash (but increasing the 4000 will).

I'm fairly confident this is a bug, and I doubt much can be done about it except waiting for the devs to fix it. But my question is, how can I work around this? I'd love to provide a complete answer for the linked question, but it will need many different font sizes to fill in the spiral completely. Can I accomplish that without provoking this crash? I tried using ScalingTransform instead of Style[..., FontSize->...] but that doesn't seem to affect the size of the characters at all (but only their position instead).

• Personally, I would wrap the rhs of FontSize with Round. There is probably not going to be a huge visual difference between FontSize specs of 20.0799 and 20. – ihojnicki Mar 14 '16 at 15:28
• @ihojnicki Unfortunately for my use case (the linked question) it is actually quite noticeable, even with Scaled[Round[..., 0.01]] because you're expecting a very smooth gradient of font sizes (and when I round to 0.001 I get the error again). – Martin Ender Mar 14 '16 at 15:31
• How much RAM do you have? MMA 10.0.2 on Linux doesn't crash in my computer when running your code even with 100000 random numbers, it just gets slow. For the Pi-question I can complete the circle with more than 2000 digits without crashing. – Gypaets Mar 14 '16 at 15:33
• 10.1 runs 4000 but hangs at 10k. (32GB windows). Its throwing internal self test error in the message window (flashing by too fast for me to capture the exact message ) – george2079 Mar 14 '16 at 15:39
• @MartinBüttner Ah Scaled[], that is especially hard on the Windows FrontEnd. In that case, you are probably better off importing the text as primitives and transforming them as needed. – ihojnicki Mar 14 '16 at 15:53