Last active
May 8, 2020 22:24
-
-
Save Koze/6a987981ae2d68a1d71d9d21cf77b0e6 to your computer and use it in GitHub Desktop.
Japanese font without Japanese character causes the clip at the bottom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct SmapleView: View { | |
let font = Font.custom("HiraginoSans-W3", size: 50) | |
let borderColor = Color(.systemBlue) | |
var body: some View { | |
VStack(spacing: 10) { | |
Text("Copy") | |
.font(font) | |
.border(borderColor) | |
Text("コピー Copy") | |
.font(font) | |
.border(borderColor) | |
} | |
} | |
} | |
struct SmapleView_Previews: PreviewProvider { | |
static var previews: some View { | |
SmapleView() | |
} | |
} |
Author
Koze
commented
May 8, 2020
- Japanese font causes clipping.
https://gist.github.com/Koze/6a987981ae2d68a1d71d9d21cf77b0e6 ← - Setting Text frame doesn't work.
https://gist.github.com/Koze/17050bcdab3e578aff993f193e27a45a - Using baselineOffset works.
https://gist.github.com/Koze/e32b833b2150313f4637414b2b76da0d - Using CTFont instead with Font and UIFont.
https://gist.github.com/Koze/52e7cce4dac069592fbcfdeca4d2ec97 - Using offset (or padding) for adjustment.
https://gist.github.com/Koze/376b0ff231107569f073f026eac2e688 - Refactor as extension.
https://gist.github.com/Koze/bd1285ab6471528e3e22cd8de3d64804
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment