/*
 * This program demonstrates a bug in NSFontManager which causes it not
 * to recognize the name of the default monospaced system font.
 *
 * Save this file as fontbug.m and compile with the command:
 * clang -o fontbug fontbug.m -framework Cocoa
 *
 * Run the demo by typing: ./fontbug 
 */

#import <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
#include <stdio.h>

int main(int argc, char** argv) {
  NSFontManager *manager = [NSFontManager sharedFontManager];
  NSFont *nsFont, *systemFont;

  printf("Creating a monospaced system font ... \n");
  systemFont = [NSFont monospacedSystemFontOfSize:11 weight:NSFontWeightRegular];
  printf("Created a font with familyName: %s\n", [systemFont familyName].UTF8String);

  printf("Requesting a font with the same familyName from the font manager ...\n\n");
  nsFont = [manager fontWithFamily:[systemFont familyName]
			     traits:NSFixedPitchFontMask
			     weight:5
			       size:11];
  printf("\nReceived the font: %s\n", [nsFont displayName].UTF8String);
}
