< prev index next >

modules/javafx.graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -78,10 +78,11 @@
      private float layoutWidth, layoutHeight;
      private float wrapWidth, spacing;
      private LayoutCache layoutCache;
      private Shape shape;
      private int flags;
+     private int tabSize = DEFAULT_TAB_SIZE;
  
      public PrismTextLayout() {
          logicalBounds = new RectBounds();
          flags = ALIGN_LEFT;
      }

@@ -646,10 +647,22 @@
              shape = outline;
          }
          return outline;
      }
  
+     @Override
+     public boolean setTabSize(int spaces) {
+         if (spaces < 1)
+             spaces = 1;
+         if (tabSize != spaces) {
+             tabSize = spaces;
+             relayout();
+             return true;
+         }
+         return false;
+     }
+ 
      /***************************************************************************
       *                                                                         *
       *                     Text Layout Implementation                          *
       *                                                                         *
       **************************************************************************/

@@ -1002,11 +1015,11 @@
                  }
              }
          } else {
              spaceAdvance = strike.getCharAdvance(' ');
          }
-         return 8 * spaceAdvance;
+         return tabSize * spaceAdvance;
      }
  
      private void layout() {
          /* Try the cache */
          initCache();
< prev index next >