[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Drawing strings on a line
From: |
Fred Kiefer |
Subject: |
Re: Drawing strings on a line |
Date: |
Wed, 03 Jun 2009 23:58:33 +0200 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
Andreas Höschler wrote:
> Hello all,
>
> I am developing a mapping application where I need to draw labels in a
> view. Currently I am using (as a first approach)
>
> [_name drawAtPoint:labelPoint withAttributes:nil];
>
> This works: However, it does not exactly has the desired effect, since
> the labels are always drawn horizontally. The labels are actually street
> names and the streets are drawn with NSBezierPath stroke. Ideally I
> would like the street label to be exactly drawn on the NSBezierPath
> which is a connected list of points, but at least to be drawn with the
> same angle as the NSBezierPath segment. There is this NSBezierPath
>
> - (void)*appendBezierPathWithGlyphs:*(NSGlyph *)/glyphs/
> *count:*(int)/count/ *inFont:*(NSFont *)/fontObj/
>
> method that might be of interest in conjunction with
>
> NSBezierPath *bezierPath = [NSBezierPath bezierPath];
> NSAffineTransform *transform = [NSAffineTransform transform];
>
> [bezierPath moveToPoint: NSMakePoint(0.0, 0.0)];
> [bezierPath lineToPoint: NSMakePoint(100.0, 100.0)];
>
> [transform translateXBy: 10.0 yBy: 10.0];
> [bezierPath transformUsingAffineTransform: transform];
>
> but this means to manually find the glyphs for each character in the
> label ([NSFont glyphWithName:]). This probably works on MacOSX, but does
> it also work under GNUstep? I am wondering if there is even an easier
> approach for accomplishing this!?
I don't think that appendBezierPathWithGlyphs: will help you on your
specific problem. (Although the method itself should work) That way you
would get a path with all the outlines of the string, again you could
only transform the whole of it, but as I understand you, you would like
to transform each single glyph.
In the cairo mailing list this is a subject that comes up from time to
time. The last time was November last year and the subject was " render
text along path" it should be easy to google for that. Here are some of
the hints that came up at that discussion.
Pycairo comes with the example examples/warpedtext.py which draws text
along a path.
http://svn.gnome.org/viewvc/pango/trunk/examples/cairotwisted.c?view=markup
http://www.flickr.com/photos/behdad/3058628981/sizes/o/
Hope this helps
Fred