discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's wrong with this NSBezierPath/NSGlyph code??


From: Fred Kiefer
Subject: Re: What's wrong with this NSBezierPath/NSGlyph code??
Date: Mon, 09 Jun 2003 01:53:15 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021204

Hi Jonathon,

nothing is wrong with your code. It is NSBezierPath that is failing you. The method you are calling is basically empty, or rather calling an empty method itself. I already had a bit of a discussion with Alexander M. on a possible implementation a few weeks ago on this list. If both of us ever find the time to work on this, you will get a working solution at least for the art backend. Maybe someone will even extend it to the xgps backend for the XFt font handling, I don't see any way to get it working with standard X fonts. If you keep on lobbying for this, we might hurry to get this done. At the moment I am still struggling to get GNUstep fully working on my new computer, but most of the work will be Alexanders anyway.

Alexander:
You suggested to implement this method by handing on the font, instead of packed glyphs only. If we do this, why don't we go the full length and make this a method on the GSFontInfo? Something like:
GSFontInfo -appendBezierPathWithGlyphs: (NSGlyph *)glyphs
        count: (int)count
        toBezierPath: (NSBezierPath *)path;

Cheers
Fred


jonathon wrote:
Can someone tell me what is wrong here?

This method is part of a class derived from NSView, and is called from
drawRect.

Everything else I am drawing works: lines, regular text, etc.  But I
cannot get a glyph to show up after being appended to an
NSBezierPath!!

It draws a tiny line segment as a test, then draws a rectangle around
where the glyph would go.  The rectangle comes out different sizes,
depending on the font size I select.  But no glyph appears inside!!

thanks,
jonathon

- (void) drawYLabels
{
  NSString *label = @"Y axis";
  NSFont *f = [NSFont userFontOfSize: 64];

  NSTextStorage *ts;
  ts = [[NSTextStorage alloc] initWithString: label];

  NSLayoutManager *lm = [[NSLayoutManager alloc] init];
  [ts addLayoutManager: lm];

  NSRange r;
  r.location = 0;
  r.length = [label length];

  NSGlyph g[r.length];
  unsigned l = [lm getGlyphs: g range: r];

  [[NSColor greenColor] set];

  // draw rectangle for first glyph
  NSRect grect = [f boundingRectForGlyph: g[0]];
  grect.origin.x = 100;
  grect.origin.y = 100;
  [[NSBezierPath bezierPathWithRect: grect] stroke];

  // test line draw
  NSBezierPath *bp = [NSBezierPath bezierPath];
  [bp moveToPoint: NSMakePoint(80, 80)];
  [bp lineToPoint: NSMakePoint(90, 90)];
  [bp moveToPoint: NSMakePoint(100, 100)];
  [bp appendBezierPathWithGlyphs: g count: l inFont: f];
  [bp fill];

  NSLog(@"path: %@\n", [bp description]);
  NSLog(@"# chars: %d glyphs: %c\n", l, g[0]);
  NSLog(@"font: %@\n", [f description]);
}






reply via email to

[Prev in Thread] Current Thread [Next in Thread]