Re: Screen trash with some fonts
Re: Screen trash with some fonts
- Subject: Re: Screen trash with some fonts
- From: Scott Thompson <email@hidden>
- Date: Fri, 14 May 2004 13:31:01 -0500
So the solution is to discover the real bounding rectangle. :-) Off
the top of my head the way that I'd do this is to get the position of
the each character with NSLayoutManager's locationForGlyphAtIndex, and
create an NSBezierPath containing them by moving to that position and
then using appendBezierPathWithGlyph. One potential gotcha here is
the font-fixing feature of Cocoa whereby the layout management system
automatically adds font attributes for glyphs that don't exist in the
selected font, so you need to do this one character at a time reading
the font attribute. The bounding box of the bezier will be the real
bounding box.
That was the only solution I could reasonably figure out as well. My
best guess would be that the font is not reporting the correct bounding
rectangles for the glyphs it contains and so the system (wishing to
avoid the expense of calculating the bounding box of the bezier curves)
simply takes the font's data "at it's word" and doesn't handle the
characters correctly.
A little experimentation in TextEdit revealed that it has the same
problem. If you enter the word "Zapfino" in the Zapfino font at about
24 points (so you get the lovely Zapfino ligature) then resize the text
edit window you will see that the swashes in the text appear and they
appear outside of the selection rectangle. Then if you paste in
something boring (like "Blah" in Helvetica 24 pt) you will see that
the swashes on the Zapfino remain behind as screen trash.
I think this is most likely a bug in the Zapfino font itself more than
anything else, but I really can't verify that without digging farther
into the font itself... Unfortunately, I disavowed any residual
knowledge I knew of font internals upon leaving the FreeHand team.
Scott
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.