https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
c

Christian Gaisl

12/14/2023, 10:31 AM
Hi, I'm trying different ways to use Compose Multiplatform views as components inside SwiftUI views. I'm not trying to replace a whole screen, but only some components, like buttons or list items. My eventual goal is to have a UI library written in Compose that I can use in SwiftUI. One problem that I ran into was Text Rendering. Most components I'm trying to build contain some form of text. However, text rendered in Compose looks different that native SwiftUI text, even when using the same size and color. Could someone explain to me why that is and how to get around that? I'd also appreciate input as to whether my goal is a supported use case, to begin with.
k

Konstantin Tskhovrebov

12/14/2023, 2:09 PM
could you share a small sample project with the problem?
I don't see any significant difference
c

Christian Gaisl

12/15/2023, 11:27 AM
Thank you so much for your reply and the example. I'm going to experiment a little bit more and then come back to you 🙂
j

Jonathan

12/15/2023, 2:14 PM
Without seeing you’re code, could it be an issue of you not using the same Font family?
c

Christian Gaisl

12/15/2023, 3:12 PM
I experimented a bit and it looks like this is a non-issue when using custom fonts. The rendering is almost identical. When turning up the font size in accessibility settings there are some minor differences (see attached). The default font of compose on iOS is also not quite identical. How does that work under the hood? Does Compose use a custom font that resembles the current iOS system font or does it have direct access to it? When I initially asked this question, I had my Text Composeable wrapped in a Material Theme -.-
e

Elijah Semyonov

12/17/2023, 4:00 PM
Font size won’t scale using the same rules as iOS, non-linear scaling like in iOS will break the design of material widgets with multiple font sizes used.
6 Views