10

If I create a UILabel, a UITextField, and a UITextView, then set them to have the same layout styles - eg, no background color, white text, and a Courier font at size 18 - the UILabel and UITextField look identical, whereas the UITextView looks different - the font looks thinner.

I took a screenshot of the problem, but I don't have enough reputation to put it inline here. So instead, click here to see my example in action

I'm pretty sure I read somewhere that UITextView uses a different rendering mechanism for fonts (CoreText, perhaps?), but whatever it is the controls definitely look different.

So, is there any way that UITextViews can be made to render their fonts like UITextFields/UILabels, or vice versa?

FizzBuzz
  • 764
  • 6
  • 16

3 Answers3

4

Fascinating issue. So far I haven't been able to reproduce it with anything but Courier, but it definitely occurs in Courier. I would open a defect at bugreporter.apple.com.

To help you move on, though, I recommend switching to Courier New, where I do not see this issue, and should be very close to your original goal.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Rats! You mean I just got unlucky with my font choice? :) I'll use Courier New for now and follow your bug report suggestion. Thank you! – FizzBuzz Feb 12 '12 at 19:49
  • 1
    Hmmm... I just tried changing the UILabel to Courier New, and it looked identical to the UITextView in Courier - almost like the UITextView refuses to use Courier and instead renders with Courier New! – FizzBuzz Feb 12 '12 at 19:56
0

I had similar problem with Raleway font. I was using Raleway-Bold.ttf (PostScript name: Raleway-Bold) and Raleway-Regular.ttf (PostScript name: Raleway) in my app. When two of those fonts were added to the project I was unable to draw Raleway-Bold in UITextView (either by setting font programmatically or in IB with FontReplacer). I was ending up with Raleway-Regular in UITextView, no problem with UILabel. When I have deleted Raleway-Regular there was no problem in both text view and label.

What I needed to do to draw Raleway-Bold on UITextView, but not resign from Regular, was to change PostScript name of Raleway-Regular, which was just Raleway to some other name. In my case it was Raleway-Reg. It was a fix :)

Maciek Czarnik
  • 5,950
  • 2
  • 37
  • 50
0

Try setting the font after setting the text. It will likely work for some people who find this thread.

UITextView style is being reset after setting text property

Community
  • 1
  • 1
user1122069
  • 1,767
  • 1
  • 24
  • 52