Kerning problems when drawing text character by character?

The answer by Lukas Baran solves the main problem that was probably causing your output to look bad. However, the more subtle problem that you can't replicate kerning in this way remains. How much of a problem this is may depend on the font you're using.To get the kerning right, too, you could do something like this: while (i!

= line.length()) { String c = line. Substring(i, I + 1); String d = line. Substring(0, I + 1); int cWidth = g.getFontMetrics().

StringWidth(c); int dWidth = g.getFontMetrics(). StringWidth(d); g. DrawString(c, xx + dWidth - cWidth, yy); i++; } That should place each character where the kerning would have placed it.

I'm not sure if I understood your problem correctly. However, I have tested your code and indeed some string characters overlapped each other. The problem was in a way you're incrementing xx value (you were incrementing it before drawing a character).

Here's corrected version of your code: public void myDrawString(Graphics g, String line, int xx, int yy) { int I = 0; while (i! = line.length()) { String c = line. Substring(i, I + 1); int cWidth = g.getFontMetrics().

StringWidth(c); g. DrawString(c, xx, yy); xx += cWidth; //xx += 2; i++; } } Uncomment and adjust xx += 2 line to increase space between characters.

The problem is that kerning defines the spacing of pairs of letters, and iterating over a string char-by-char gives the kerning system no chance to kick in. I think you'll have to use either a fixed-width font or rework your lighting effect so it works with full strings instead of single chars.

Problems with newline in Graphics2D. Problems with newline in Graphics2D.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions