Custom font that does not display diasis in capital letters

I have a subclass of UIButton that uses its own font. The problem is that the capital letters do not show diarrhea.

Below are images of the same button sample with and without a custom font. I set the background color of the title to red to see what happens.

No special font

without custom font

With custom font

with custom font

My subclass of UIButton overrides awakeFromNib

 - (void)awakeFromNib { [super awakeFromNib]; UIFont *font = [UIFont fontWithName:@"TitilliumText22L-Bold" size:self.titleLabel.font.pointSize]; self.titleLabel.font = font; } 

Can someone tell me what to do to show diasis on top of the capital letters?

Thanks.

+4
source share
4 answers

I solved this problem by following this answer to a question that Bob shares fooobar.com/questions/7740 / ...

The only thing you need to know about this solution (changing the "upstream" font file) is that the space between the lines on multi-line UILabels using this changed font will also change, so you can use NSAttributedString to change it in each case.

+3
source

I did some tests about this with Turkish characters, see the result:

3 Buttons and 1 UILabel with NeoSansPro font and capital TR chars

  • UILabels correctly display capital letters.
  • UIButton with the helvetica font displays characters correctly (third button), but the problem occurs with all members of the NeoSansPro family.
  • The problem occurs only in the top line of the title label (button 2)

Decision:

  • Label string names: 0
  • Set the name "\ nBUTTON TITLE" instead of "BUTTON NAME"
  • In IB or code, play with the content and title aligned until the title is displayed correctly. You have to push the title a little up if you want it in the middle.
+1
source

it seems that the text when cutting, try to reduce the font size or change the titleLable frame (UIButton property)

0
source

I had a similar problem when diarrhea was cut off over the header. I created a subclass of UIButton and used this code to fix the problem:

 -(void)layoutSubviews { [super layoutSubviews]; CGRect frame = self.titleLabel.frame; frame.size.height = self.bounds.size.height; frame.origin.y = self.titleEdgeInsets.top; self.titleLabel.frame = frame; } 
0
source

Source: https://habr.com/ru/post/1485784/


All Articles