3

The Unicode character U+1d134 is the musical symbol for "common time"; it looks like a capital 'C'.

But using Python 3.6, when I specify '\U0001d134' I get a glyph that seems to indicate an unknown symbol. On my Mac, it looks like a square with a question-mark in it.

Is the inability to display the corresponding glyph simply a font limitation, or is it something else? (Like maybe something I'm doing wrong....)

For clarity, I want to use this and other such symbols in an app I'm writing, and would like to find out if there's a way to do this.

wchlm
  • 365
  • 1
  • 11
  • Are you running this in your terminal? – user1767754 Jan 02 '18 at 05:19
  • 3
    Yep, that’s probably a font limitation. Try copying the square and pasting it somewhere sans-serif. – Ry- Jan 02 '18 at 05:21
  • @user1767754 Yes. – wchlm Jan 02 '18 at 05:24
  • @Ryan Thanks. I tried TextEdit in RTF mode with Helvetica and Google Docs with Ariel, and still get the unknown-character symbol, though in the Google doc it's just an empty square. I have to say that at http://xahlee.info/comp/unicode_music_symbols.html, this symbol and many others are also shown as empty squares. – wchlm Jan 02 '18 at 05:37
  • 1
    If the glyph is not a common one, it may simply be that your computer has no way to represent it, since it's not in any of the fonts you have available. My computer apparently does have a font that can handle it, but I have no idea what font it's using. It seems my browser can also render it: `'foo\U0001d134bar'` appears as `'foobar'` (with the C between the last o and the b) both in Python and in Firefox. – Blckknght Jan 02 '18 at 05:41
  • No need for further replies, unless someone has a revelation. But I just thought I'd mention that (using the xahlee.info URL I gave in an earlier comment), this symbol is displayed as unknown on my system (MacBook Air 2013, MacOS 10.13.2), using Chrome, Firefox and Safari. Though I didn't search exhaustively, the same symbols (i.e., not just this one) seem to be undisplayable in all three browsers. – wchlm Jan 02 '18 at 06:26

1 Answers1

3

The problem lies not in your code but in your local system. You don't have any font installed that contains the character "MUSICAL SYMBOL COMMON TIME".

That is also the reason none of your browsers can display it. Usually, browsers are quite good in hunting down any font that can display a certain character. Reason they all fail is what's in the paragraph above.

But – as it happened,

>>> print ('\U0001d134')

worked for me, displaying this:

musical symbol common time printed in Python

I pasted it into UnicodeChecker, which helpfully listed 'all' fonts that contain this character: only one, Bravura. It's an Open Source font so go ahead and download it. (Be careful to follow proper procedures if you want to distribute it along with your app.)

To think that I only had that font installed because of an earlier SO question.

Jongware
  • 22,200
  • 8
  • 54
  • 100
  • 1
    I realize that I'm not supposed to say "Thank you" in a comment, but what the hell if I'm docked a few points. Thank you, then, to all that helped, not least for confirming each others' responses. And, @usr2564301, thanks as well for putting the comments together into an answer, and for mentioning the UnicodeChecker, the Bravura music font, and the "earlier SO question" whose response went beyond my current problem to illuminate a few complications of using OpenType for musical notation. (Which fortunately is not what I'm planning to do. :-) ) – wchlm Jan 03 '18 at 03:27