I'm developing a table like html output which needs pagination for printing. But the content of each line is unknown. To prevent the break in line during pagination, I need to know the exact width of each character and then do new-line. According to new-lines' amount, I can calculate what's the height of this html:tr.
I'm stuck by the algorithm of character's width. Is it possible to get it from Java GUI components likes AWT or Swing?
I'm looking forward to your reply.
Best regards, Leon
Ernest Friedman-Hill
author and iconoclast
Marshal
Sounds like you could use java.awt.font.LineBreakMeasurer. Also be aware that the width of a String does not usually equal the sum of the widths of its characters, because of kerning: some chararacters are smooshed together the "ff" in "off", or "Aw" in "Away", especially in italics and certain fonts.