Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8107292

Text scaling is not smooth

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Incomplete
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
      None
    • Environment:

      JDK 6u12, JavaFX 1.1 and 1.5 (graphics-scrum #112), Vista

      Description

      Scaling text does not look smooth, as demonstrated by the code below. A good-looking workaround is to throw a Blur on things.

      The following are copied from http://monaco.sfbay.sun.com/detail.jsf?cr=6661083
      ---
      Out of curiousity, I tried scaling very large text way down, as well as scaling small text up, but the non-smoothness shows up in both cases - particularly when the text is small.

      I think conceptually the smoothness is limited by having to eventually render into pixels, and this limitation becomes all the more pronounced at smaller sizes. If there are only, say, two pixels between letters, when an extra pixel of space is added, that amounts to 33% more space, and the eye can easily spot this. The same is true for the thickness of the characters.

      Watching the text being scaled at very low speed, each individual size looks good on its own, so the text scaling routines appear sound.

      This is an area where High DPI should make a lot of difference, but for now I don't know that there's much that can be done.
      *** (#1 of 2): 2008-02-13 17:19:31 PST bchristi

      In JDK 6u14 we added the ability to disable hinting which makes the scaling
      smoother (removes hinting effects).
      Maybe scenario can be updated to use that.
      *** (#2 of 2): 2009-03-06 09:03:00 PST prr

      --test case:--
      import javafx.animation.Interpolator;
      import javafx.animation.KeyFrame;
      import javafx.animation.Timeline;
      import javafx.scene.effect.GaussianBlur;
      import javafx.scene.Scene;
      import javafx.scene.text.Font;
      import javafx.scene.text.FontWeight;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      /**
       * @author bchristi
       */

      var scale = 1.0;

      var stage = Stage {
          width: 800
          height: 200
          scene: Scene {
              content: [
                  Text {
                      content: "Is text scaling smooth?"
                      font: Font.font("Serif", 72)
                      translateX: 10
                      translateY: 75
                      scaleX: bind scale
                      scaleY: bind scale
                      // Interesting: looks quite smooth w/ even a small blur:
                      /*effect: GaussianBlur{
                          radius: 1.0
                      }*/
                  },
                  Text {
                      content: "Is bold text smooth?"
                      font: Font.font("Serif", FontWeight.BOLD, 72)
                      translateX: 10
                      translateY: 150
                      scaleX: bind scale
                      scaleY: bind scale
                      // Interesting: looks quite smooth w/ even a small blur:
                      /*effect: GaussianBlur{
                          radius: 1.0
                      }*/
                  },
              ]
          }
      }

      var tl: Timeline = Timeline {
          repeatCount: Timeline.INDEFINITE
          autoReverse: true
          keyFrames: [
              KeyFrame {
                  time: 3s
                  values: [
                      scale => 0.25 tween Interpolator.LINEAR
                  ]
              }
          ]
      }

      tl.playFromStart();

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              prr Philip Race
              Reporter:
              bchristi Brent Christian
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: