简体   繁体   中英

Displaying Musical Unicode Symbols in iOS UI with Swift

I am currently developing an iOS app that works a lot with musical symbols. the symbols I would like to use are found on this page:

http://unicode-table.com/en/blocks/musical-symbols/

I am trying out a few examples like assigning the text directly to the label. So this is what I see in Xcode's interface builder:

在界面生成器中看到的标签

And this is what I see in the simulator:

在界面生成器中看到的标签

I also tried assigning it programatically (Swift code):

label.text = "\u{1D15D}"

But no luck that way either. However, if I send this to the console with println() the note character is correctly printed in the console.

Just in case I tried with a few system fonts and the result was the same (Default, Arial, Verdana and Times New Roman)

So my question/questions would be: Am I doing something wrong? Are these characters not supported by iOS' interface elements like UILabels? Or maybe the problem is in the font?

I would appreciate some help here :) let me know if you need more information than what I provided here.

This is a problem with the font. Very few fonts contain the musical symbols of Unicode. The “UFO” symbols that you see are probably generic symbols for “strange” characters not present in the font. You may need to find a suitable free font and try to bundle it with your application.

A few fonts contain at least some of the musical symbols. The most commonly known of them, FreeSerif, Quivira, and Symbola are listed (with samples) at the Fileformat.info site on page MUSICAL SYMBOL WHOLE NOTE (U+1D15D) Font Support . There is also the Musica font downloadable from the page Unicode Fonts for Ancient Scripts . (The common musical symbols aren't that ancient, but the font contains also Byzantine musical symbols.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM