I have a custom font that I'm using in my app, Cassandra-Personal. It's a signature style font. Whenever I use it inside of a Text("someText")
the font is clipped on the top and bottom due to ascenders and descenders present in the font. A couple of fixes that I've attempted are to change the .frame()
, .baselineOffset()
, and I also attempted to play around with the kerning/tracking to no avail. In short the text, regardless of the frame, is clipped. Whenever I .baselineOffset()
it fixes the one side or the other, but not both sides. For obvious reasons I can't offset both sides simultaneously.
The View
struct GroupListHeaderView: View {
let headerTitle: String
var body: some View {
ZStack(alignment: .center) {
Rectangle().fill(Color(UIColor.yellow))
Text(headerTitle)
.font(Fonts.header)
.frame(height: 100)
}.frame(height: 100)
}
}
Addt'l Supplementary Code
struct Fonts {
// Other fonts removed, not relevant.
static let header = Font.custom(FontName.cassandra.rawValue, size: 30)
}
public enum FontName: String {
// Other cases removed, not relevant.
case cassandra = "CassandraPersonalUse-Regular"
}
Example #1
- Baseline Offset of
30
Example #2
- Baseline Offset of
-30
Example #3
- Frame
height: 100