Why does the same text using the same font look different on different platforms? Is there any way to force it to look the same?

John Zukowski

Fonts are dealt with in points from Java. How the Java runtime translates points to pixels is up to the implementor of the runtime. You have no control over this as a developer besides finding a point size that looks reasonably good on all the implementations you test with. Short of creating your own Java runtime implementation, and convincing people why it is required, you have no way to force the issue.

[FAQ Manager Note] If you always use layout managers to size and position your components in a GUI, it should never be necessary to worry about how text will look. Depending on the layout manager, you use, it can size the component based on its preferred size, which in turn is based on its font size and text to display.

See http://developer.java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/index.html for details on layout management and which take preferred size into account.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
By using this site, you agree to the Privacy Policy