Skip to content

Instantly share code, notes, and snippets.

@Koze
Created May 8, 2020 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Koze/52e7cce4dac069592fbcfdeca4d2ec97 to your computer and use it in GitHub Desktop.
Save Koze/52e7cce4dac069592fbcfdeca4d2ec97 to your computer and use it in GitHub Desktop.
Japanese font without Japanese character causes the clip at the bottom. A refactored quick workaround.
import SwiftUI
struct SmapleView: View {
let ctFont = CTFontCreateWithName("HiraginoSans-W3" as CFString, 50, nil)
var ctFontDescender: CGFloat {
CTFontGetDescent(ctFont)
}
let borderColor = Color(.systemBlue)
var body: some View {
HStack(spacing: 10) {
Text("Copy")
.font(.init(ctFont))
.border(borderColor)
Text("Copy")
.font(.init(ctFont))
.baselineOffset(ctFontDescender)
.border(borderColor)
}
}
}
struct SmapleView_Previews: PreviewProvider {
static var previews: some View {
SmapleView()
}
}
@Koze
Copy link
Author

Koze commented May 8, 2020

Screenshot 2020-05-09 2 02 14

@Koze
Copy link
Author

Koze commented May 8, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment