[Openmcl-devel] glyphs in Cocoa
Arthur Cater
arthur.cater at ucd.ie
Mon Feb 27 13:42:22 PST 2023
Thanks, I will look at those. I’m converting character outlines to SVG Polylines to drive a laser cutter that doesn’t properly understand <text> tags.
> On 27 Feb 2023, at 21:22, R. Matthew Emerson <rme at acm.org> wrote:
>
>
>
>> On Feb 27, 2023, at 12:54 PM, Arthur Cater <arthur.cater at ucd.ie> wrote:
>>
>> Kindly indulge any rambling. I’m frustrated by glyphs on mac os x. So many Objective-C methods are deprecated. And I’m so ignorant.
>>
>> NSGlyphs seem to be integers, in my experience with a Menlo-Regular font the glyph is 29 less than the ascii character code.
>> So I wondered (but this isn’t the main thrust of this message) when I came across this in cocoa-editor.lisp whether the use of (char-code #\space) was going to give the appropriate result.
>>
>> (defun size-of-char-in-font (f)
>> (let* ((sf (#/screenFont f))
>> (screen-p *use-screen-fonts*))
>> (if (%null-ptr-p sf) (setq sf f screen-p nil))
>> (let* ((layout (#/autorelease (#/init (#/alloc ns:ns-layout-manager)))))
>> (#/setUsesScreenFonts: layout screen-p)
>> (values (fround (#/defaultLineHeightForFont: layout sf))
>> (fround (ns:ns-size-width (#/advancementForGlyph: sf (char-code #\space))))))))
>>
>> Also, like so many, #/advancementForGlyph is a deprecated method.
>>
>> So is #/appendBezierPathWithGlyph:inFont: which is what I’ve found to almost-work for what I want to do. I say almost-work because whenever I’ve used it, and then I quit ccl with cmd-Q, I get the distinctly odd dialog telling me that CCL has unexpectedly quit.
>>
>> From Apple docs I have the feeling I should be using appendBezierPathWithCGGlyph:inFont: (note the CG). but #/appendBezierPathWithCGGlyph:inFont: doesn’t seem to name a function. Is there something special about CG?
>>
>> Any help appreciated.
>
> I’m not sure what you’re trying to do, but perhaps you could operate more easily at the
> Core Text level.
>
> Take a look at CTFontGetGlyphWithName and CTFontCreatePathForGlyph.
>
> (#_CTFontCreateWithName #@"LucidaGrande" (cg:cgfloat 8) +null-ptr+)
>
>
More information about the Openmcl-devel
mailing list