kiwicom / orbit-swiftui

Kiwi.com Orbit design system library
MIT License
132 stars 23 forks source link

Icons are not encoding properly #646

Closed matthewnaples closed 9 months ago

matthewnaples commented 1 year ago

Hello, when I run the storybook in the simulator (haven't checked on device), the icons don't seem to be encoded properly. This also happens when I attempt to use the icons in another project. Simulator Screenshot - iPhone 14 Pro - 2023-08-11 at 10 44 39

Is there something I need to update on my end to make sure they encode properly? Thanks!

PavelHolec commented 1 year ago

Hello, For Orbit icons to work, it is necessary to call Font.registerOrbitFonts() anywhere during the app start (or SwiftUI preview) once.

The following tutorial covers this part with the optional custom fonts used for Orbit text components.

https://kiwicom.github.io/orbit-swiftui/tutorials/orbit/01-01-hello_orbit

cameroncooke commented 9 months ago

Just to add to this, while this is correct the documentation also states:

If you omit this optional step, Orbit components will use default iOS system fonts.

If you're not licensed to use this font and would like to use custom or the system fonts you also don't get the icons as they are loaded as a font as part of the registerOrbitFonts() call.

How does one use default fonts and continue to use the bundled icons?

cameroncooke commented 9 months ago

I managed to work around this by manually calling the following in my app code:

        if let iconsFontURL = Bundle.orbit.url(forResource: "Icons.ttf", withExtension: nil) {
            _ = Font.registerFont(at: iconsFontURL)
        }

But I think it would help if the loading of the icons was decoupled from the loading of the licensed fonts.

PavelHolec commented 9 months ago

Thanks for pointing that out.

The original assumption was that Orbit Icons would be mostly suitable in combination with matching Orbit fonts (otherwise, SF Symbols might be a better choice). But it indeed makes sense to decouple it.

Created https://github.com/kiwicom/orbit-swiftui/issues/753