Created
January 19, 2016 03:40
-
-
Save Nyoho/a2d8c97a15983a5b6a4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Cocoa | |
//let s = String.fromCString(C_ARGV[0]) | |
let s = "謹賀新年s㎃p" | |
var path = NSBezierPath() | |
//let font = NSFont.systemFontOfSize(24.0) | |
let font = NSFont(name: "HiraKakuStdN-W8", size: 24.0)! | |
let attr = [NSFontAttributeName: font] | |
let textStorage = NSTextStorage(string: s, attributes: attr) | |
let layoutManager = NSLayoutManager() | |
let textContainer = NSTextContainer() | |
var range: NSRange | |
layoutManager.addTextContainer(textContainer) | |
textStorage.addLayoutManager(layoutManager) | |
range = layoutManager.glyphRangeForTextContainer(textContainer) | |
let glyphArray = UnsafeMutablePointer<NSGlyph>.alloc(range.length) | |
let glyphLength = layoutManager.getGlyphs(glyphArray, range: range) | |
path.moveToPoint(NSPoint(x: 0, y: 0)) | |
path.appendBezierPathWithGlyphs(glyphArray, count:glyphLength, inFont:font) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment