问题
Possible Duplicate:
How to use glyph from Apple Symbols font?
I need to draw glyph with name "gid5002" from Apple Symbols font in NSImage. This glyph hasn't unicode representation, so it's seems impossible to construct string that contains it. I try:
NSFont* font = [NSFont fontWithName:@"Apple Symbols" size:12.0];
NSGlyph glyph = [font glyphWithName:@"gid5002"]
so, now I have that glyph. What next? I think I can't use NSLayoutManager because lack of unicode representation
回答1:
Construct an NSBezierPath
with the outline of the glyph, and then fill/stroke the path into your graphics context.
NSFont *font = [NSFont fontWithName:@"Apple Symbols" size:12.0];
NSBezierPath *path = [NSBezierPath bezierPath];
[path appendBezierPathWithGlyph:[font glyphWithName:@"gid5002"]
inFont:font];
// ...
[path stroke];
来源:https://stackoverflow.com/questions/8472791/how-to-draw-one-nsglyph-that-hasnt-unicode-representation