如何画一个NSGlyph,没有unicode表示? [英] How to draw one NSGlyph, that hasn't unicode representation?

查看:405
本文介绍了如何画一个NSGlyph,没有unicode表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何使用Apple Symbol字体使用字形?

我需要从NSImage中的Apple Symbols字体中输入名称为gid5002的字形。这个字形没有unicode表示,所以似乎不可能构造包含它的字符串。
我尝试:

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"]

那个字形。接下来是什么?我想我不能使用NSLayoutManager因为缺乏unicode表示

so, now I have that glyph. What next? I think I can't use NSLayoutManager because lack of unicode representation

推荐答案

构造一个 NSBezierPath 与字形的轮廓,然后填充/描边到你的图形上下文的路径。

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];

这篇关于如何画一个NSGlyph,没有unicode表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆