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

Add tabSize property to Text and TextFlow

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P4
    • jfx14
    • 8u45
    • javafx
    • x86_64
    • windows_7

    Description

      A DESCRIPTION OF THE REQUEST :
      in PrismTextLayout,

      private float getTabAdvance() {
              float spaceAdvance = 0;
              if (spans != null) {
                  /* Rich text case - use the first font (for now) */
                  for (int i = 0; i < spans.length; i++) {
                      TextSpan span = spans[i];
                      PGFont font = (PGFont)span.getFont();
                      if (font != null) {
                          FontStrike strike = font.getStrike(IDENTITY);
                          spaceAdvance = strike.getCharAdvance(' ');
                          break;
                      }
                  }
              } else {
                  spaceAdvance = strike.getCharAdvance(' ');
              }
              return 8 * spaceAdvance;
          }


      note the 8 * spaceAdvance, unable to be changed in runtime.

      JUSTIFICATION :
      Many text editors run a 4 * (width of space) so this can cause unintended graphical mistranslations when trying to upgrade software into JavaFX.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Some method e.g. TextLayout.setTabWidth() that allows us to modify the width of the tab, in spaces.
      ACTUAL -
      No such method provided; locked into using 8-width tabs

      ---------- BEGIN SOURCE ----------

      TextFlow flow = new TextFlow();
      flow.getChildren().add(new Text(" There is a tab before this text.\n There are four spaces before this text.\n There are eight spaces before this text"));

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      n/a, security privileges prevent injecting code into the JRE. The only option is to render tabs by converting tabs into a series of spaces but this is difficult to implement.

      Attachments

        Issue Links

          Activity

            People

              swpalmer Scott Palmer
              webbuggrp Webbug Group
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: