views:

131

answers:

1

has anyone ever successfully used the java.awt.font.LineBreakMeasurer to draw word-wrapping text that has java.awt.font.TextAttribute.TRACKING (also known as letter spacing) set on the font?

i create the font by:

Map<TextAttribute, Object> map = new HashMap<TextAttribute, Object> ();
map.put(TextAttribute.SIZE, 18);
map.put(TextAttribute.TRACKING, .04);
Font f = Font.createFont(Font.TRUETYPE_FONT, new File ("C:/arialbd.ttf"));
f = f.deriveFont(map);

everything looks good when rendered to an image and tracking is 0. but when the tracking is set > 0 everything is drawn correctly but the line breaks do not change. the text just disappears off the side of the image.

A: 

I've never tried it with anything but the default Font, but the old Multi Line Text tech tip shows one way to use the LineBreakMeasurer. Since you didn't post your code I can't tell if your code is the same or different.

Next time posting your SSCCE would be helpful so we can see what your are doing.

camickr
i'm using the example straight out of the java doc which is similar to the Multi4 example in the link you posted. if you replace the font creation (3rd line in the constructor) with the code i posted above you'll see the effect.
lindy
I don't have access to the font file. You seem to think the problem is with the Tracking attribute. So is it a problem with all fonts or only that font or a combination of both? Anyway, I have nothing further to offer, sorry.
camickr