nodejs 借助 nodobjc 模块
https://github.com/TooTallNate/NodObjC
demo:
var $ = require('nodobjc')
$.framework('Foundation')
$.framework('AppKit')
var pool = $.NSAutoreleasePool('alloc')('init')
var string = $.NSString('stringWithUTF8String', 'Hello')
// var string1 = $.NSString('stringWithUTF8String', 'Hello')
// var compare = string('compare',string1,'options','NSLiteralSearch|NSCaseInsensitiveSearch')
// console.log(compare)
var size = $.NSMakeSize(8, 'MAXFLOAT');
var font = $.NSFont('systemFontOfSize', 20.0);
var attributes = $.NSMutableDictionary('alloc')('init');
attributes('setObject',font,'forKey',$('NSFontAttributeName'));
var rect = string('boundingRectWithSize', size, 'options', 'NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading','attributes',attributes,'context',null);
console.log(rect);
pool('drain')