1
$\begingroup$

People are saying u1D378 is the unicode for

https://upload.wikimedia.org/wikipedia/commons/1/1d/Tally_marks-Five-bar_Gate.svg

How do i create such a tally mark character in mathematica front end. If there is another way please also suggest that.

| improve this question | | | | |
$\endgroup$
  • $\begingroup$ According to unicode.org/alloc/Pipeline.html, the Tally Mark Five character was finally published in Unicode 11, on June 5 2018. Since no version of Mathematica is newer than that, I don't believe the built-in font has support for these characters (my OSX system font also doesn't have support for these characters). Related: stackoverflow.com/questions/3557276/… mathematica.stackexchange.com/questions/159178/… $\endgroup$ – Carl Lange Jan 8 '19 at 16:04
  • $\begingroup$ I believe Mathematica implements only UTF-16 Unicode characters, so the characters that look like u plus 5 hex digits can't be used in M. See FromCharacterCode[] and try FromCharacterCode[16^^1D378]. $\endgroup$ – Michael E2 Jan 8 '19 at 16:40
  • $\begingroup$ I think version 12 will support emoji, so perhaps support for higher-register UTF characters will come via that 💩 $\endgroup$ – Carl Lange Jan 8 '19 at 16:44
2
$\begingroup$

While it seems impossible to get the true unicode character to display in Mathematica (see comments), you can create a graphics expression that behaves like a character in terms of display (code at the end of the answer):

enter image description here

You can copy this object into a string, and it will adapt to font color and size (copy & paste the result from above to where the <> is):

Style["This is like a character: <>",Red,FontSize->30]

enter image description here

This is achieved by wrapping the graphics expression in Dynamic (to get the dynamic color/size) and Deploy (to prevent accidental editing). The color is set to CurrentValue@"Color", the size is set using CurrentValue@FontSize. Similarly, other properties of the object could be adapted to the surrounding text. I got the graphics expression itself by printing the SVG file to a PDF and importing that into Mathematica.

Code to generate expression

Dynamic@Deploy@Graphics[
  {
  CurrentValue["Color"],
  FilledCurve[
    {{{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{0,1,0}}},
    {{{191/2,2771/5},{479/5,2732/5},{961/10,2693/5},{963/10,2654/5},
    {967/10,2596/5},{969/10,2538/5},{971/10,496},{461/5,2463/5},
    {92,2521/5},{459/5,5157/10},{457/5,5273/10},{456/5,5351/10},
    {909/10,543},{453/5,2754/5},{191/2,2771/5}}}
  ],
  FilledCurve[
    {{{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{0,1,0}}},
    {{{847/10,2771/5},{85,2732/5},{426/5,2693/5},{171/2,2654/5},
    {859/10,2596/5},{861/10,2538/5},{863/10,496},{407/5,2463/5},
    {406/5,2521/5},{81,5157/10},{403/5,5273/10},{803/10,5351/10},{80,543},
    {399/5,2754/5},{847/10,2771/5}}}
  ],
  FilledCurve[
    {{{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{0,1,0}}},
    {{{739/10,2771/5},{741/10,2732/5},{372/5,2693/5},{747/10,2654/5},
    {751/10,2596/5},{753/10,2538/5},{151/2,496},{353/5,2463/5},
    {352/5,2521/5},{701/10,5157/10},{349/5,5273/10},{139/2,5351/10},
    {346/5,543},{69,2754/5},{739/10,2771/5}}}
  ],
  FilledCurve[
    {{{1,4,3},{1,3,3},{0,1,0},{1,3,3},{1,3,3},{0,1,0}}},
    {{{631/10,2771/5},{633/10,2732/5},{318/5,2693/5},{639/10,2654/5},
    {321/5,2596/5},{129/2,2538/5},{647/10,496},{597/10,2463/5},
    {119/2,2521/5},{593/10,5157/10},{589/10,5273/10},{587/10,5351/10},
    {292/5,543},{581/10,2754/5},{631/10,2771/5}}}
  ],
  FilledCurve[
    {{{1,4,3},{1,3,3},{1,3,3},{1,3,3},{0,1,0},{1,3,3},
    {1,3,3},{1,3,3},{1,3,3},{0,1,0}}},
    {{{246/5,2729/5},{272/5,543},{60,2697/5},{326/5,2681/5},{153/2,5293/10},
    {439/5,522},{99,5147/10},{516/5,5121/10},{1073/10,5093/10},
    {557/5,2532/5},{561/5,2529/5},{113,5053/10},{1137/10,2524/5},
    {548/5,2503/5},{1089/10,2506/5},{1081/10,5017/10},{537/5,2511/5},
    {1033/10,5051/10},{991/10,5079/10},{95,2553/5},{837/10,2589/5},
    {145/2,5251/10},{611/10,532},{557/10,5353/10},{50,5383/10},{449/10,2712/5},{246/5,2729/5}}}
  ]
  },
  ImageSize->{Automatic,CurrentValue[FontSize]},
  BaselinePosition->Scaled[1/10]
]
| improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Although i used FontVariations->{"StrikeThrough"->True}] to achieve a slightly poor effect but this is brilliant. Can this be used to convert any image data into a character to be used in the frontend? $\endgroup$ – user13892 Jan 8 '19 at 18:35
  • $\begingroup$ @user13892 In principle, you can insert anything into strings, yes. Dynamic styling is also pretty straightforward - just wrap the expression in dynamic and use CurrentValue[…] to get the correct values (the are many others besides "Color" and FontSize, just play around with it - see also this post) $\endgroup$ – Lukas Lang Jan 8 '19 at 19:28

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.