JDK-8090413 : Need new hints to control how Text node is rendered
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: fx1.3
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2009-11-09
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
We need to add one or two new knobs to the Text node API to allow for more control over how text is rendered.

The following API suggestions are just meant to demonstrate at a high level what is desired (not worrying about wording or naming)...

1) The first knob would control rendering performance/quality:

   public var renderHint:TextRenderHint = <DEFAULT, QUALITY, SPEED>

I'm very hesitant to use these names.  What I really mean here is:
 DEFAULT == what we have now, which is good perf/quality for non-animating text
 QUALITY == use text outline when rendering, good for large animating/scaling text
 SPEED   == scale glyph images, quality will suffer when the scale factor gets
            too big or too small, but should be very fast for fast moving animations
            where quality isn't noticeable

2) The second knob might interact with the first, and would control antialiasing behavior (no aa, grayscale aa, lcd aa).  I'm less sure about what is needed here; only including it here because it came up in a related discussion I had with Phil.

Comments
I think RT-20449 is a duplicate of this issue, basically
26-07-2013

It would be nice if we could solve these problems by adding only one API, so I guess you want to add it to Node right next to cache and cache hint. Questions 1) What RenderingHint would be needed for ImageView (RT-11486) ? 2) What ANIMATION_QUALITY/ANIMATION_SPEED mean for Shapes (!= Text) ? or Regions ? 3) What ANIMATION_QUALITY means for Text ? -> Draw as outline ? 4) What ANIMATION_SPEED means for Text ? -> Draw as bitmap ? How does that relate to cache=true/hint=speed ?
04-06-2013

Do we want to use the same API on ImageView? See RT-11486. It seems like we should have one enum, even if the properties are copy/pasted (otherwise we'd have to move rendering hint up to Node. I'm not sure if that makes sense.)
03-06-2013

OK, so here is a rough first stab at API and semantics. I think "renderingHint" is not really the right name for this because there are many rendering hints (AA algorithm to use, etc), but lacking a better name I used it. RenderingHint.java public enum RenderingHint { STATIC_QUALITY, ANIMATION_QUALITY, ANIMATION_SPEED } Shape.java /** * Provides a way to give the rendering system a hint as to how a specific Shape is intended to be used in the program, * such that the rendering system can choose the best approach to rendering. A value of null results in the same behavior * as that exhibited by STATIC_QUALITY */ private ObjectProperty<RenderingHint> renderingHint = new SimpleObjectProperty<>(this, "renderingHint", RenderingHint.STATIC_QUALITY); public final RenderingHint getRenderingHint() { ... } public final void setRenderingHint(RenderingHint value) { ... } public final ObjectProperty<RenderingHint> renderingHintProperty() { ... }
03-06-2013

I support a new API setTextRenderingHint() on text and think that we should use STATIC_QUALITY, ANIMATION_QUALITY and ANIMATION_SPEED. This captures exactly the cases we are trying to solve and makes explicit the trade offs for the programmer. It is tempting to try and reused the enum and names from setCacheHint() because they are dealing with the same concept however, text rendering is not bitmap caching. wrt. ANIMATION_QUALITY vs ANIMATION_SMOOTH: If there is a distinction in the future, we can add the enum. The idea here is to give the programmer a simple choice between quality and speed.
03-06-2013

I'm not picky with the names but we really need to decided if we want to make it a generic API (shapes, maybe Node) or specific for Text. I would think that we got Shapes covered already: cache cacheHint smooth -- maybe I'm missing something but would we ever need to do anything else for shapes ? For that reason I would focus on Text only, I preference is textRenderMode (or hint) with the following names: default outline speed default and outline are pretty obvious. Speed would be something along the lines what MS did with that A8 mode. By the way, running the MS sample, when you switch to A8 the quality drops (blurry, but no jitter) and FPS goes thru the roof (from 100-150FPS to over 3000FPS). So, outline should be used when you want the text to look as good as possible during animation and FPS is not (much of) a concern. speed when the quality of text doesn't matter as much but FPS does.
01-06-2013

Looking at my last suggestion for a general rendering hint on Shape, it occurs to me that "ANIMATION_QUALITY" might seem ambiguous since, for some, quality in terms of animation could be any of fastest fps, most consistent fps, least jitter, least lag, etc. And some of those may be at odds with each other. How about: STATIC_QUALITY ANIMATION_SMOOTH(NESS) ANIMATION_SPEED Where SMOOTH is only those qualities that relate to the accuracy or consistency of the trajectory even if they hurt raw fps, but SPEED means best fps even if sacrificing some minor amounts of smoothness or resolution. As examples: SMOOTH might be done with outlines for text, but not for SPEED? Scaling and sub-pixel interpolation of images may be considered for SPEED, but not SMOOTH?
01-06-2013

I don't think you want to use a generic name because we may add a "render hint" to the parent class (Shape). How do you want the line of code to read? text.setTextRenderHint(LEGIBILITY) text.setTextRenderHint(ANIMATION_QUALITY) text.setTextRenderHint(ANIMATION_SPEED) text.setTextRenderHint(LEGIBLE) text.setTextRenderHint(ANIMATION_SMOOTH) text.setTextRenderHint(ANIMATION_SMOOTHNESS) text.setTextRenderHint(ANIMATION_FAST) If it were moved up to Shape, how about: STATIC_QUALITY ANIMATION_QUALITY ANIMATION_SPEED And the best quality static text is simply "legible"?
01-06-2013

OK, after more discussion I don't think cache / cacheHint is sufficient (could be useful in some situations, but not all). Looking at http://msdn.microsoft.com/en-us/library/windows/desktop/dd756767(v=vs.85).aspx Microsoft has 3 rendering methods: - Default: this is equivalent to what we do today, which is optimized for drawing lots of readable text very quickly - Outline: slower but beautiful when animated, this is of course simply treating the text as shapes - A8: using shaders and masks. This sounds exactly like what we do for our Default. They may use different layout rules for A8 mode, I'm not sure. I like the name of the property proposed here: renderHint, which is an enum of type TextRenderHint. I don't really have a problem with the given names (DEFAULT, QUALITY, SPEED) although Chris & Phil & Jim have expressed reservations, particularly with the name "QUALITY", because QUALITY doesn't capture whether we're talking about large amounts of legible text, or larger text rendering that we're animating and want really smooth. Jim suggested "ANIMATED" as an enumerated value which would basically say "do what it takes to make this text look great while I animate it". But I don't think that's quite right either. The problem is that there are two modes when you are animating: animating + quality (outlines) and animating + speed (scaled images). If I had it to all do over again, I might have just used this new enum and mashed in the AA algorithm (LCD / Grayscale) as well, but anyway that's neither here nor there (and might have been wrong anyway). So what if the names were: public enum TextRenderHint { LEGIBLE, ANIMATED_QUALITY, ANIMATED_SPEED } The names are kind of odd (well, I've not seen an API of this kind use these names before) but seem to be quite to the point. "I want this text to be highly legible". "I want this text to have super high quality while I animate it". "I want this text to be super fast while I animate it".
01-06-2013

Note that we have a way to control antialiasing behavior in FX now, so that part isn't needed for this issue. We also have cache and cacheHint which do, I think, what is required by #1. So I think this issue can be closed.
29-05-2013