0
votes

I am writing an app that requires labels w/ musical accidental symbols, called sharp and flat (♯ and ♭, respectively). Specifically, I need a label that says c♯. It is irrelevant to the question what these two symbols mean within a musical context. My app's main font is Open Sans. However, because Open Sans doesn't specify a character for the sharp and flat symbols, it uses a generic sharp and flat symbol that I find unattractive. However, I know that Helvetica Neue (or the iOS system font) has some well made symbols for sharp and flat, so I decided to change the label's text to an attributed string so I could make the c Open Sans, and the ♯ Helvetica Neue (both size 24). I did this through the interface builder. Even though everything looks exactly the way I want in the storyboard, when I launch it in the iOS Simulator, the labels with attributed strings are significantly shrunken from the other labels. I should note that the label has 3 AutoLayout constraints, though these contrasts are positionally related only, not size related.

Things I have tried (unsuccessfuly):

  • Using only one font
  • Doubling the font size (was too big)
  • Removing autolayout constraints

I would greatly appreciate it if someone could explain how to correctly create these labels. I am happy to provide any more information that is needed.

Thank you

1
I added Open Sans in to the files and added it to the .plist. It works on the generic labels and is in the storyboard as a selectable font.ericmarkmartin
Okay, excellent. Can you put a screenshot somewhere or post an example project on github? There need to be enough info so that others can see and reproduce the problem...matt
Why did using one font not work, what was the problem?zaph
It sounds like you are using several labels next to each other to achieve your result, is that so? As matt stated please provide more information, add it to your question..zaph
No, I understood perfectly. Read again what I asked you to do, please. Do you want help or not?matt

1 Answers

4
votes

I discovered that the problem is that NSAttributedString does not (yet) support custom fonts through Interface builder. It looks like I will have to subclass. This question essentially boils down to be the same as this one: Attributed string with custom fonts in storyboard does not load correctly