Why is the text cut to the bottom in a UITextField?

I use my own font in my text fields and labels in my application. My font name is "digital-7.ttf". Now the problem is that the text in my shortcuts is good, but in UITextFields it cuts the text from the bottom. when the text field is edited, the text is good, but when editing is done, it cuts the text again. eg enter image description here

so I set its font style [txtFld setFont:[UIFont fontWithName:@"digital-7" size:25.0]];

and the font has been added to info.plist

Please help me

+6
source share
5 answers

this problem is in Xcode 3.2.5. In earlier versions, the same code works well. :)

-1
source

I had a similar problem with custom font in UITextField, but in my case it disabled my umlauts from above.

I opened the font with FontForge and adjusted the HHead Slope in the element โ†’ OS / 2 โ†’ Metrics with the same value as Win Offset Offset

in your case it is probably HHHead Offset Offset . try changing this value

+5
source

I ran into the same issue with the same Digital-7 font (albeit italic). To build JeanLuc's answer, the only sensible way to do this is to change the metrics in the font editor. I also used FontForge, but the steps I took were slightly different. I opened the font, went to Element> Font Info ...> OS / 2> Metrics, and changed the value of HHead Descent (represents the line spacing on the Mac) to a negative value of Win Descent (line spacing on Windows). See below:

Image

Also make sure that the win values โ€‹โ€‹of Win Ascent and HHead Ascent match. You can also change the name of the changed font. After you have made your changes, click "OK", then "File", "Create Fonts ...", select the ttf format and save.

+2
source

Editing a font file seems a bit difficult.

Have you tried Malcolm's offer? I use my own font and a custom subclass that accepts UIEdgeInset

InsetTextField.h

 #import <UIKit/UIKit.h> @interface InsetTextField : UITextField @property (assign, nonatomic) UIEdgeInsets insets; @end 

InsetTextField.m

 #import "InsetTextField.h" @implementation InsetTextField - (CGRect) textRectForBounds:(CGRect)bounds { return UIEdgeInsetsInsetRect([super textRectForBounds:bounds], self.insets); } - (CGRect)editingRectForBounds:(CGRect)bounds { return UIEdgeInsetsInsetRect([super editingRectForBounds:bounds], self.insets); } @end 

If Digital-7 is still misbehaving, I think you will have no other option but to change the font file .: - /

+2
source

You must increase the text box frame height to solve your problem or reduce the text font size

-1
source

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


All Articles