Possible Duplicate:
How to use glyph from Apple Symbols font?
我需要从 NSImage 中的 Apple Symbols 字体中绘制名称为“gid5002”的字形。该字形没有 unicode 表示形式,因此似乎不可能构造包含它的字符串。 我尝试:
NSFont* font = [NSFont fontWithName:@"Apple Symbols" size:12.0];
NSGlyph glyph = [font glyphWithName:@"gid5002"]
所以,现在我有了那个字形。接下来是什么?我想我不能使用 NSLayoutManager 因为缺乏 unicode 表示
最佳答案
使用字形轮廓构造一个 NSBezierPath
,然后将路径填充/描边到图形上下文中。
NSFont *font = [NSFont fontWithName:@"Apple Symbols" size:12.0];
NSBezierPath *path = [NSBezierPath bezierPath];
[path appendBezierPathWithGlyph:[font glyphWithName:@"gid5002"]
inFont:font];
// ...
[path stroke];
关于objective-c - 如何绘制一个没有 unicode 表示的 NSGlyph?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8472791/