1 | initial version |
To include a font in your Xcode project through CMake, follow these steps:
Create a new directory in your project called Fonts and place your font file (.ttf, .otf, etc.) in that directory.
In your CMakeLists.txt, create a variable that holds the path to your Fonts directory:
set(FONT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Fonts")
# Copy font to app bundle
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND
${CMAKE_COMMAND} -E copy_directory ${FONT_DIR} ${APP_BUNDLE}/Contents/Resources)
In your Xcode project, go to your app target and add the font file to the project by selecting "Add Files to [App Name]" from the File menu.
Select the font file and set the target membership to your app target.
In your app's Info.plist, add a new entry for the font file with the name of the file and the relative path to the Fonts directory:
<key>UIAppFonts</key>
<array>
<string>MyFont.ttf</string>
</array>