nbonwit
nbonwit

Reputation: 305

How do I create a font in Monotouch?

How do I create a font in Monotouch?

I want to specify the font family, size, and style (e.g., Courier, bold, 25).

Upvotes: 2

Views: 962

Answers (2)

jonathanpeppers
jonathanpeppers

Reputation: 26495

If I have a UIButton named _woot:

_woot.Font = UIFont.FromName ("Courier-Bold", 25);

If you can figure out a font name, use this code to print them all out:

            string fonts = "--------------------------------------\n";
            var fontFamilies = new List<String> (UIFont.FamilyNames);
            fontFamilies.Sort ();
            foreach (var familyName in fontFamilies) {
                foreach (var fontName in UIFont.FontNamesForFamilyName (familyName)) {
                    fonts += familyName;
                    fonts += "\t";
                    fonts += fontName;
                    fonts += "\n";
                }
                fonts += "--------------------------------------\n";
            }
            Console.WriteLine (fonts);

Upvotes: 3

Jason
Jason

Reputation: 89117

In code, Use the UIFont class. Or do it using Interface Builder. Those are the Apple docs - there aren't a lot of MT specific examples of using fonts, although this might be useful.

Upvotes: 1

Related Questions