1

If we went and bought a font for use in our app, is it possible to bundle the font and use it inside the app? We're creating apps that need to generate buttons on the fly and need to use a specific font for it.

Cheers

w://

2 Answers2

18

Put your fonts into a directory in your project root (same level as Info.plist) and list the files in Info.plist:

<key>UIAppFonts</key>
<array>
   <string>Fonts/Quicksand_Bold.otf</string>
   <string>Fonts/Quicksand_Book.otf</string>
</array>

Then add the files in MonoDevelop to your project and set the build action to "Content". After that you can use the font:

UILabel title = new UILabel (new RectangleF (80, 190, 160, 60));
title.Font = UIFont.FromName("QuicksandBook-Regular", 20);
title.SetTitle ("Font Demo");

If you have problems determining the right font name you can use this code snipped to retrive a list of all installed fonts:

String fonts = "";
List<String> fontFamilies = new List<String> (UIFont.FamilyNames);
fontFamilies.Sort ();
foreach (String familyName in fontFamilies) {
  foreach (String fontName in UIFont.FontNamesForFamilyName (familyName)) {
    fonts += fontName + "\n";
  }
  fonts += "\n";
}
Console.WriteLine (fonts);          
Falko
  • 17,076
  • 13
  • 60
  • 105
Rodja
  • 7,998
  • 8
  • 48
  • 55
  • 2
    Great answer, just wanted to add that for the current version of MonoTouch you should put the fonts in the Resources folder and set the build action to "BundleResource". – Dave Wolfe Apr 01 '13 at 18:50
0

There no Monotouch library out there from what I know, but you could try porting this one:

Community
  • 1
  • 1
Chris S
  • 64,770
  • 52
  • 221
  • 239