Skip to main content

How do I get font glyph geometry data?

4 replies [Last post]
qu0ll
Offline
Joined: 2006-12-09
Points: 0

For a given font, how can I get access to the rendering geometry used to actually render a particular glyph? By this I mean the curves and lines that are used to draw each glyph.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jtheory
Offline
Joined: 2004-10-17
Points: 0

Sorry for the late addition, but I just ran across this post.
You may want to use getPathIterator(null) instead of getPathIterator(null, 0).
You very likely do NOT want a FlatteningPathIterator, because this will flatten all of your curves into (tiny) straight lines.

I imagine you want the curves -- so do as described but avoid the flattening argument, and make a float[] that's 6 in length (because when getting curve info you have might get up to 3 pairs of x/y points).

qu0ll
Offline
Joined: 2006-12-09
Points: 0

Thanks, that's helpful info.

claudeabb
Offline
Joined: 2006-08-09
Points: 0

Hi

You should take a look to the method getOutline which returns a shape whose interior corresponds to the visual representation of the GlyphVector.

Afterwards you can use
FlatteningPathIterator path=(FlatteningPathIterator)shape.getPathIterator(null, 0);

float coords[]=new float[2];
while (!path.isDone()) {
path.currentSegment(coords);
-->> insert what you want to do here with the current coordonnees got
path.next();
}

qu0ll
Offline
Joined: 2006-12-09
Points: 0

Thanks very much - that's exactly what I was looking for.

-Qu0ll