Drawing Glyphs one by one
Drawing Glyphs one by one
- Subject: Drawing Glyphs one by one
- From: Bruno Blondeau <email@hidden>
- Date: Thu, 18 Oct 2001 21:34:22 +0200
I am trying to draw glyphs one by one, somewhat like what the CircleView
sample project is doing, but with a different transform.
So I tried to reuse some of its code, but it doesn't seem to work well when
I have text with something else than the default font size, the characters
spacing remaining the same whatever the size is.
I was wondering what was going wrong in my code, and eventually tried to
remove the transform from the CircleView sample by doing something like
this:
for (glyphIndex = glyphRange.location; glyphIndex < NSMaxRange(glyphRange);
glyphIndex++)
{
NSRect lineFragmentRect = [layoutmanager
lineFragmentRectForGlyphAtIndex:glyphIndex effectiveRange:NULL];
NSPoint layoutLocation = [layoutmanager
locationForGlyphAtIndex:glyphIndex];
// Here layoutLocation is the location (in container coordinates) where
the glyph was laid out.
layoutLocation.x += lineFragmentRect.origin.x;
layoutLocation.y += lineFragmentRect.origin.y;
[layoutmanager drawGlyphsForGlyphRange:NSMakeRange(glyphIndex, 1)
atPoint:NSMakePoint(layoutLocation.x, layoutLocation.y)];
}
and then I noticed that character spacing was very strange (way too large).
Is this normal? How can I modify this to obtain normal a correct layout?
Bruno