[Drawkit] changing font
Graham Cox
graham.cox at bigpond.com
Thu Jun 26 18:04:14 PDT 2008
On 27 Jun 2008, at 7:19 am, James Maxwell wrote:
> Okay, false alarm... I found the problem. Kind of strange, though.
> I had set the font variable in my init code using a simple
> assignment. When I changed this to using the actual accessor -
> setGlyphFont: it worked properly. Does anybody understand why that
> would be? I'm glad I solved the problem, but it's a little
> disconcerting that I don't actually know *why* my solution worked. :-\
I assume this is a method you wrote, since it's not part of Cocoa nor
DrawKit. So without seeing that code, I have no idea.
> My best guess is that some super class uses Helvetica as a default
> (maybe NSObject holds a reference to some system font, somewhere?).
> Anyway, problem solved, for now.
No, NSObject doesn't. But certainly some styles in DK do have text and
font attributes that use Helvetica as a default (though usually at
18pt). However unless you are using these on purpose I'm not sure why
they would interfere with the normal process of creating shapes and so
on.
>
> On another note, I'm trying to refine this process of using glyphs
> for objects - these are all music notation objects, taken from a
> free music font - and I have one big question. Does anyone know if
> there's a simple way to have a DKDrawableShape adopt the bounds of a
> glyph? I'm finding I'm tweaking around a lot with these glyphs,
> trying to get them to draw properly, and to fit within the selection
> bounds of my DKDrawableShape, but it seems like there must be an
> easier way.
Once you have a glyph as a bezier path, it is simply a path, with no
special properties that link it to a font or other textual
information. If you create the shape with that path (there are
convenience constructors to do this, for example
+drawableShapeWithBezierPath:) the bounds of the shape will be set up
as needed. Normally you don't have to fiddle about to get this to
work, so it sounds like you're doing too much or perhaps not
constructing the shape in the most straightforward manner. Again it's
hard to advise without seeing the code in question.
cheers, Graham
More information about the Drawkit
mailing list