Re: Drawing NSGlyphs
Re: Drawing NSGlyphs
- Subject: Re: Drawing NSGlyphs
- From: Aki Inoue <email@hidden>
- Date: Thu, 19 Sep 2002 11:46:43 -0700
There is a known bug in this area, although I am not certain of the
details.
Yes, this is a known issue in Jaguar, and causing problems everywhere.
In order to workaround, you need to advance the glyphs manually.
- (void)_appendBezierPathWithPackedGlyphs:(const char *)packedGlyphs
length:(int)length forFont:(NSFont *)font {
const uint16_t *glyphs = (const uint16_t *)packedGlyphs; // We
always use native short packing
NSPoint point = [self currentPoint];
NSSize advance;
NSGlyph glyph;
length /= sizeof(uint16_t);
while (length > 0) {
glyph = (NSGlyph)*(glyphs++);
[self appendBezierPathWithGlyph:glyph inFont:font];
advance = [font advancementForGlyph:glyph];
point.x += advance.width;
point.y += advance.height;
[self moveToPoint:point];
--length;
}
}
Aki
On 2002.9.19, at 09:44 AM, Douglas Davidson wrote:
On Thursday, September 19, 2002, at 08:11 AM, Vladimir Pilipyuk wrote:
That does not seem to me as a correct behavior of the -[NSBezierPath
appendBezierPathWithGlyphs:count:inFont:] method that all the glyphs
overlay each other at one point which is not shifted according to
NSFont metrics for each glyph in the array.
Is this a bug?
There is a known bug in this area, although I am not certain of the
details.
Another problem is with foreign encodings, NSLayoutManager does not
return NSGlyphs array good enough for NSBezierPath to draw them with
the same font. Though it works for English language and some special
foreign fonts. However NSTextView can show these foreign glyphs in
the normal fonts as Times or Helvetica for instance. I must be
missing something in glyphs encoding but cannot figure out what it >> is.
Let me explain how this works. NSTextStorage actually manages the
font substitution during its attribute fixing phase. This is done
automatically, so whenever you ask for the font attribute in an
NSTextStorage, you will get a font that can actually display the
specified character--but you must ask the text storage what the font
is, you cannot simply use the font that you set on it to begin with.
NSGlyphs only have significance with respect to a particular font, so
you cannot use the glyphs from layout manager with an arbitrary font;
you must use a given glyph with the font that the NSTextStorage has
assigned to the relevant character(s). That is how NSTextView does > it.
Douglas Davidson
_______________________________________________
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.
_______________________________________________
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.