How to draw one NSGlyph, that hasn't unicode representation? [duplicate]

会有一股神秘感。 提交于 2019-12-29 09:32:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!