Size mismatch between swing fonts and print fonts in Java

I have a panel showing a JTextPane backed by a StyledDocument. When I print a line of text like Arial 16, the text it prints is the same size as Arial 16 Word. However, Arial 16 in JTextPane turns out to be smaller than Arial 16 Word. Is there any flaw in translating Swing fonts to Windows system fonts or something that makes it difficult (or impossible) to print accurately?

I can get an approximation by reducing my font size before printing, but that never gives me the results I would like as it is impossible in all cases to reproduce things like the equivalent number of words on a line, etc.

Has anyone encountered this before?

+2


a source to share





All Articles