2

I'm writing a Mac application that needs to be able to create, load, and use custom fonts at runtime using Cocoa. I've researched the NSFont class thoroughly, and all I can find is API's to load existing fonts and change simple parameters (E.G. size, weight, spacing, etc.).

I need to be able to create custom glyphs from scratch while my program is running, preferably using NSBezierPath, combine them into an NSFont object or something similar, and draw text to the screen using this font.

Is this possible? I'd imagine that font-creation applications must use this. If it is possible, how is it done?

exists-forall
  • 4,148
  • 4
  • 22
  • 29

1 Answers1

1

There is no API in Mac OS X that will allow you to directly build a font using drawing commands.

Unfortunately, you will have to do this from scratch, building a TrueType or Postscript font file by writing the font data out into the appropriate file format and then loading the font from that file using NSFont or one of the other font APIs.

You might get some hints by looking at the FontForge source, although it's not a Cocoa app so may be only of limited usefulness.

Rob Keniger
  • 45,830
  • 6
  • 101
  • 134
  • Thanks! It's nice to know what I'm dealing with. Are there any libraries I could use to create these font files to load? I know it's possible to draw bezier paths to a postscript file, but there must be extra data to handle. – exists-forall Apr 01 '12 at 03:04