Tk Source Code

Attachment Details
Login
Overview

Artifact ID: 9a25db19795cf033c1adf774fd1377532fea04f609e36966162b23336f63830d
Ticket: 855049e799227e65982e14f49de1a0f503b5c494
Date: 2020-01-22 21:09:48
User: marc_culler
Artifact Attached: e0799b62e5f959f0b376fa141c6a3eb5def52d052c3a1eaff3909d636b886728
Filename:fontbug.m
Description:Objective C program to demonstrate this Apple bug.
Content:
/*
 * 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);
}