Open GoogleCodeExporter opened 9 years ago
I added JTextComponent and direct Java2D text rendering to the benchmark and
things
got even stranger on WinXP.
With System Properties -> Advanced -> Performance -> Settings -> [x] Smooth
edges of
screen fonts turned on, JLabel, JTextComponent, and JLabel via PSwing do not
antialias for any rendering hint values, whereas PText antialiases poorly for
all
hint values, and direct Java2D renders all the hint values appropriately.
Turn off that setting and JLabel, JTextComponent, and Java2D all render
correctly,
PText still antialiases poorly on all, and JLabel via PSwing renders OFF and
GASP
hints correctly with no antialiasing and renders the rest antialiased poorly.
There's now too much to show on one screen shot, so I have attached the
benchmark
code as a runnable jar. JDK 1.6+ only. Don't look at this stuff too long, for
all
the fuzzy text will make your eyes hurt.
Original comment by heue...@gmail.com
on 1 Aug 2009 at 6:15
Attachments:
Attaching new version of text-rendering-benchmark.jar with PHtmlView.
PHtmlView appears to have the same behaviour as PSwing described above.
Original comment by heue...@gmail.com
on 6 Aug 2009 at 6:38
Attachments:
Results on mac os x
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03-211)
Java HotSpot(TM) 64-Bit Server VM (build 11.3-b02-83, mixed mode)
Original comment by she...@gmail.com
on 12 Aug 2009 at 4:11
Attachments:
Source code is in svn at
http://dishevelled.svn.sourceforge.net/svnroot/dishevelled/trunk/text-rendering-
benchmark/
http://dishevelled.svn.sourceforge.net/viewvc/dishevelled/trunk/text-rendering-b
enchmark/
Original comment by heue...@gmail.com
on 9 Apr 2010 at 9:39
This is my most frustrating Piccolo2D issue. Can anyone else take a look at it?
Original comment by heue...@gmail.com
on 24 Aug 2010 at 3:04
Attaching current version of text-rendering-benchmark runnable jar, built with
Piccolo2D svn trunk.
Original comment by heue...@gmail.com
on 2 Mar 2011 at 5:32
Attachments:
Further analysis:
Swing text rendering is dependent on operating system and installed Look and
Feel. See jlabel-*, pswing-*, jtextcomponent-*, and phtmlview-* in the text
rendering benchmark.
Java2D text rendering using Graphics2D.drawSwing respects LCD_* text rendering
hints of the current graphics context on all platforms. See java2d-* in the
text rendering benchmark.
PText text rendering using java.awt.font.TextLayout.draw() ignores any text
rendering hints specified in the current graphics context. See ptext-* in the
text rendering benchmark.
TextLayout receives its text rendering hints from
PPaintContext.RENDER_QUALITY_HIGH_FRC passed to a
java.awt.font.LineBreakMeasurer ctr.
http://code.google.com/p/piccolo2d/source/browse/piccolo2d.java/trunk/core/src/m
ain/java/org/piccolo2d/nodes/PText.java#436
RENDER_QUALITY_HIGH_FRC is currently implemented as new FontRenderContext(null,
true, true)
http://code.google.com/p/piccolo2d/source/browse/piccolo2d.java/trunk/core/src/m
ain/java/org/piccolo2d/util/PPaintContext.java#63
http://download.java.net/jdk7/docs/api/java/awt/font/FontRenderContext.html#Font
RenderContext(java.awt.geom.AffineTransform,%20boolean,%20boolean)
It is not possible to modify the text rendering hints supplied to TextLayout or
LineBreakMeasurer after they have been constructed.
The javadoc for FontRenderContext reads
Typically, instances of FontRenderContext are obtained from a Graphics2D
object. A FontRenderContext which is directly constructed will most likely not
represent any actual graphics device, and may lead to unexpected or incorrect
results.
Incorrect results such as the poorly anti-aliased text shown in the text
rendering benchmark.
Looking forward, I see a few options
1) Attempt to instantiate a "better" FontRenderContext for
PPaintContext.RENDER_QUALITY_HIGH_FRC.
2) Re-implement PText to create a new instance of TextLayout with the current
text rendering hints from the graphics context every time PText.paintText is
called.
3) Re-implement PText to use the instance of TextLayout created with
PPaintContext.RENDER_QUALITY_HIGH_FRC only for layout purposes and render the
text in PText.paintText with Graphics2D.drawString.
4) Re-implement PText with the same pattern as PHtmlView, delegating text
rendering to a JLabel.
There are pros and cons to each, thought I should post this analysis and await
comment before proceeding.
Original comment by heue...@gmail.com
on 7 Mar 2011 at 10:46
Original comment by heue...@gmail.com
on 26 Nov 2013 at 11:22
Original issue reported on code.google.com by
heue...@gmail.com
on 31 Jul 2009 at 3:26Attachments: