Status: Accepted
Owner: [email protected]
Labels: Type-Defect Effort-Low OpSys-Linux Priority-Medium OpSys-Windows Toolkit-Piccolo2D.Java Component-Extras Usability

New issue 191 by [email protected]: Disabling FRACTIONAL_METRICS on Windows yields incorrect bounds for text PSwing components
http://code.google.com/p/piccolo2d/issues/detail?id=191

What steps will reproduce the problem?
1. Run PSwingExample1 on Windows
2. Continuously zoom until the "This is a growable TextArea." text exceeds the rightmost bounds of the blue boundary.

What is the expected output? What do you see instead?

The PSwing text shouldn't exceed its bounds. In other applications, this causes the edge of some PSwing components to fall behind other components, clipping it so that the rightmost part of the PSwing is hidden.

Note that the problem disappears when commenting out line 474 of PSwing:
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);

This line was presumably added to make sure that PSwings on Mac do not render with ellipses "...". However, when we added that workaround we did not know it would cause incorrect layout for text PSwings on Windows (and possibly Linux?)

In my working copy, I have applied the change to detect whether the OS is Mac, and to disable fractional metrics if and only if the OS is mac:

//Disable Fractional Metrics on Mac OS because when FRACTIONAL_METRICS are enabled on Mac OS, spurious ellipses // are renderer on PSwing text components. Disabling this property on Windows causes incorrect rendering of
        // adjacent text PSwing nodes.
if (System.getProperty("os.name").toLowerCase().indexOf("mac") >= 0) { g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
        }

What do others think of this solution? Could leaving fractional metrics enabled in Windows and Linux cause any other buggy behavior? It would also be nice to confirm why this workaround was added in the first place.

--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to