We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Getting kerning data from font
Page Index Toggle Pages: 1
Getting kerning data from font (Read 1336 times)
Getting kerning data from font
Apr 4th, 2009, 1:24am
 
Hi
I'm trying to do my own fancy text effects, such as warping text around curves etc, but because I have to put one character at a time onto the screen, I need to adust the spacing according to the kerning.

How do I access the kerning tables/info for the font used?  I noticed that there is a kern method listed in the development pages, but it doesn't support .vlw files  - that would have been handy!

Thanks for any help,
Glenn.
Re: Getting kerning data from font
Reply #1 - Apr 4th, 2009, 11:36am
 
VLW files have no kerning information. The best you can get from them is character width:
Code:
void setup()
{
size(500, 300);
noLoop();
background(#AAFFEE);

String msg = "Processing is awesome!";
int ml = msg.length();
PFont fi = loadFont("Impact-48.vlw");
textFont(fi);
char[] msgChars = new char[ml];
msg.getChars(0, ml, msgChars, 0);
float pos = 10;
for (int i = 0; i < ml; i++)
{
char c = msgChars[i];
fill(60, 90, map(i, 0, ml, 0, 255));
text(c, 10 + 18 * i, 100);

text(c, pos, 200);
pos += textWidth(c);
}
}
Re: Getting kerning data from font
Reply #2 - Apr 5th, 2009, 6:36am
 
that's just what I needed thanks!

-although the colour gradient was a bit too fancy Smiley
Re: Getting kerning data from font
Reply #3 - Apr 6th, 2009, 3:51am
 
glenn wrote on Apr 5th, 2009, 6:36am:
although the colour gradient was a bit too fancy Smiley
Grin
That's just one of the simplest effects to illustrate characters are drawn individually while keeping correct spacing.
Page Index Toggle Pages: 1