How to use custom fonts in attributed text in labels in Storyboard?

ios
xamarin

#1

I am doing Xamarin native iOS (and Android) development, but the same question might be true for native iOS development without Xamarin.

I am using a custom font in my Xcode Storyboard in attributed text labels. This works fine with builds coming from my development machine, but the builds from Bitrise are using the default iOS font (although the coloring and text style (bold/italic) is applied).

Simple plain text labels that use a custom font work fine. Attributed text from code (NSAttributedString) also work fine.

I have installed the custom font on my development machine, but the Bitrise environment doesn’t have these fonts installed. When I remove the custom font from my development machine, I get the same behavior as the builds from Bitrise.

Could the fact that these fonts are not installed on the Bitrise build host be the cause of my problem? And how do I get these fonts available during build time on Bitrise?


#2

Hi @JoostOuweland,

Thanks for asking this here! :wink:

Based on

I’d say yes, definitely. There’s absolutely no magic in the bitrise.io VMs, these are clean macOS installs with a couple of preinstalled tools, that’s all.

Well, how do you make it available on your Mac? :wink:


#3

To answer this question, you can install the font the same way you would on your Mac using the Terminal. This is true for any install/command; you can do the same what you would in your Mac Terminal, using a Script step.

Related docs: http://devcenter.bitrise.io/tips-and-tricks/install-additional-tools/


In case of Font files, it seems it’s as simple as copying the font files into the /Library/Fonts or ~/Library/Fonts dirs (source: https://apple.stackexchange.com/questions/240381/installing-fonts-from-terminal-instead-of-font-book)

If you’d have any questions just let us know!


#4

Yes this seems to resolve the problem. Thanks for your quick response @viktorbenei!


#5

No problem at all, we’re always happy to help, thanks for creating the thread here, I’m sure this will help others in the future! :slight_smile: