My app uses a custom font. I want to use this font in the LaunchScreen storyboard too. Anyone know how to do this?
I’ve got this far…
- I created a LaunchScreen storyboard in Xcode, using my custom font, and stored the storyboard file in my project repo.
- In CMake, I have the following to get the LaunchScreen.storyboard into Xcode. (I’m using Qt which provides support via a custom property.)
set_target_properties(MyTarget PROPERTIES
QT_IOS_LAUNCH_SCREEN "${CMAKE_CURRENT_SOURCE_DIR}/LaunchScreen.storyboard"
)
- In CMake, I copy the font to the Resources folder
target_sources(MyTarget PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/MyFont.ttf")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/MyFont.ttf" PROPERTIES
MACOSX_PACKAGE_LOCATION Resources
)
- In Info.plist, I add the font
<key>UIAppFonts</key>
<array>
<string>MyFont.ttf</string>
</array>
The only step that doesn’t work is step 3. Whereas this approach works fine for adding, say, an image to the built Resources folder, my font file doesn’t show up.
NB: When I originally added the font to Xcode to create the LaunchScreen storyboard, I followed these instructions from Apple. The first step adds the font file to Resources and adds it to MyTarget. Obviously every time I run CMake it recreates the Xcode project and so this font is lost, which is why I need to include it via CMake.