There is another reference from earlier years,
but the situation didn't change much, as Toolkit and Java2D.
   (seach getScreenResolution)
   http://www.dickbaldwin.com/java/Java304.htm

>From that and FAQ below, I conclude that Java sticks
firmly to 72 DPI "user space" and does not attempt to
adjust the geometry/font to screel-pixel ratio on its own.

Java provides the getScreenResolution, but it's inconsistent
and from all the source code of JDK 1.4 I found only one place
where it's actually used: in XP LAF implementor to identify
the size of a image for a GUI control (like checkbox).

It follows that it's up to the developer what to do with
getScreenResolution, but the adjustments need to be consistent:
not just font. Otherwise the text will fall out from GUI
and from graphics, like in Linux (before adjustment).
One solution, which author above gives, is to apply AffineTransform
for Java2D, then both geometry and fonts will adjust uniformly.
But that's something for the future.


--- Eric Iverson <[EMAIL PROTECTED]> wrote:

> Oleg,
> I finally found a web reference that might explain why I am happy with 
> my Linux fonts and you are unhappy with yours.
> 
> http://java.sun.com/products/java-media/2D/reference/faqs/index.html
> 
> The relevant section is:
> ***
> Q: Why does (eg) a 10 pt font in Java applications appear to have a 
> different size from the same font at 10pt in a native application?
> 
> A: Conversion from the size in points into device pixels depends on 
> device resolution as reported by the platform APIs. Java 2D defaults to 
> assuming 72 dpi. Platform defaults vary. Mac OS also uses 72 dpi. Linux 
> desktops based on GTK (Gnome) or Qt (KDE) typically default to 96 dpi 
> and let the end-user customise what they want to use. Windows defaults 
> to 96 dpi (VGA resolution) and also offers 120 dpi (large fonts size) 
> and lets users further specify a custom resolution. So a couple of 
> things can now be seen
> 
> The DPI reported by platform APIs likely has no correspondence to the 
> true DPI of the display device
> 
> Its unlikely that Java 2D's default matches the platform default.
> 
> So a typical results is that for Window's default 96 DPI that a 10 pt 
> font in a Java application is 72/96 of the size of the native 
> counterpart.
> 
> Note that Swing's Windows and GTK L&Fs do scale fonts based on the 
> system DPI to match the desktop. If you want to do the same in your 
> application you can call java.awt.Toolkit.getScreenResolution() and use 
> this to apply a simple scale to the size you specify for fonts.
> ***
> 
> On my Suse 9.1 out of the box with KDE the result of
> dpi=Toolkit.getDefaultToolkit().getScreenResolution();
> is 100.
> 
> I don't know where the 100 comes except that I definitely never set it 
> myself. But it means my J system scales point size by 100%72 (almost the 
> same as 96%72) and my fonts look good.
> 
> Previously you pointed out Mac size font problems and pointed at 96%72 
> as the reason. I added code that changed the dpi to 96 if the host was 
> Mac (ismacosx) and the dpi from getScreenResolution() was 72.
> 
> My guess is that if you do wd'qscreen' on your linux system you will see 
> that it has a dpi of 72. This is the value reported by 
> getScreenResolution().
> 
> On Mac wd'qscreen' resssult reflects the fact that the 72 from 
> getScreenResolution() has been changed to be 96.
> 
> If your linux font problem is because you have a dpi of 72 then the fix 
> I need to apply is to simply remove the test for ismacosx and always jam 
> a 72 dpi up to be 96 dpi.
> 
> Note that on various platforms in various ways the user can adjust the 
> result from getScreenResolution and have desired or undestired effects.
> 
> I will build a new wbeta linux now with this change and put it at the 
> web site for you to test. 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to