< prev index next >

modules/graphics/src/test/java/test/com/sun/javafx/text/TextLayoutTest.java

Print this page




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.com.sun.javafx.text;
  27 
  28 import javafx.scene.text.Font;
  29 
  30 import com.sun.javafx.font.PGFont;
  31 import com.sun.javafx.geom.RectBounds;
  32 import com.sun.javafx.scene.text.GlyphList;
  33 import com.sun.javafx.scene.text.TextSpan;
  34 import com.sun.javafx.scene.text.TextLine;

  35 import com.sun.javafx.text.PrismTextLayout;
  36 import com.sun.javafx.text.PrismTextLayout;
  37 
  38 import org.junit.Ignore;
  39 import org.junit.Test;
  40 
  41 import sun.font.CharToGlyphMapper;
  42 import static org.junit.Assert.*;
  43 
  44 public class TextLayoutTest {
  45     private String J = "\u3041";  //Japanese not complex
  46     private String D = "\u0907"; //Devanagari complex
  47     private String T = "\u0E34"; //Devanagari complex
  48 
  49     class TestSpan implements TextSpan {
  50         String text;
  51         Object font;
  52         TestSpan(Object text, Object font) {
  53             this.text = (String)text;
  54             this.font = font;


  83         GlyphList[] runs = layout.getRuns();
  84         assertEquals("runCount", runCount, runs.length);
  85         assertEquals("runCount", runCount, glyphCount.length);
  86         for (int i = 0; i < runs.length; i++) {
  87             assertEquals("run " +i, glyphCount[i], runs[i].getGlyphCount());
  88         }
  89     }
  90 
  91     private void verifyComplex(PrismTextLayout layout, boolean... complex) {
  92         GlyphList[] runs = layout.getRuns();
  93         for (int i = 0; i < runs.length; i++) {
  94             assertEquals("run " +i, complex[i], runs[i].isComplex());
  95         }
  96     }
  97 
  98     @SuppressWarnings("deprecation")
  99     @Ignore("RT-31357")
 100     @Test public void buildRuns() {
 101 
 102         PrismTextLayout layout = new PrismTextLayout();
 103         PGFont font = (PGFont)Font.font("Monaco", 12).impl_getNativeFont();
 104         PGFont font2 = (PGFont)Font.font("Tahoma", 12).impl_getNativeFont();
 105 
 106         /* simple case */
 107         layout.setContent("hello", font);
 108         verifyLayout(layout, 1, 1, 5);
 109 
 110         /* simple case, two workd*/
 111         layout.setContent("hello world", font);
 112         verifyLayout(layout, 1, 1, 11);
 113 
 114         /* empty string */
 115         layout.setContent("", font);
 116         verifyLayout(layout, 1, 1, 0);
 117 
 118         /* line break */
 119         layout.setContent("\n", font); //first line has the line break (glyphCount=0),
 120         verifyLayout(layout, 2, 2, 0,0);
 121         layout.setContent("\r", font);
 122         verifyLayout(layout, 2, 2, 0,0);
 123         layout.setContent("\r\n", font);
 124         verifyLayout(layout, 2, 2, 0,0);




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.com.sun.javafx.text;
  27 
  28 import javafx.scene.text.Font;
  29 
  30 import com.sun.javafx.font.PGFont;
  31 import com.sun.javafx.geom.RectBounds;
  32 import com.sun.javafx.scene.text.GlyphList;
  33 import com.sun.javafx.scene.text.TextSpan;
  34 import com.sun.javafx.scene.text.TextLine;
  35 import com.sun.javafx.text.FontHelper;
  36 import com.sun.javafx.text.PrismTextLayout;
  37 import com.sun.javafx.text.PrismTextLayout;
  38 
  39 import org.junit.Ignore;
  40 import org.junit.Test;
  41 
  42 import sun.font.CharToGlyphMapper;
  43 import static org.junit.Assert.*;
  44 
  45 public class TextLayoutTest {
  46     private String J = "\u3041";  //Japanese not complex
  47     private String D = "\u0907"; //Devanagari complex
  48     private String T = "\u0E34"; //Devanagari complex
  49 
  50     class TestSpan implements TextSpan {
  51         String text;
  52         Object font;
  53         TestSpan(Object text, Object font) {
  54             this.text = (String)text;
  55             this.font = font;


  84         GlyphList[] runs = layout.getRuns();
  85         assertEquals("runCount", runCount, runs.length);
  86         assertEquals("runCount", runCount, glyphCount.length);
  87         for (int i = 0; i < runs.length; i++) {
  88             assertEquals("run " +i, glyphCount[i], runs[i].getGlyphCount());
  89         }
  90     }
  91 
  92     private void verifyComplex(PrismTextLayout layout, boolean... complex) {
  93         GlyphList[] runs = layout.getRuns();
  94         for (int i = 0; i < runs.length; i++) {
  95             assertEquals("run " +i, complex[i], runs[i].isComplex());
  96         }
  97     }
  98 
  99     @SuppressWarnings("deprecation")
 100     @Ignore("RT-31357")
 101     @Test public void buildRuns() {
 102 
 103         PrismTextLayout layout = new PrismTextLayout();
 104         PGFont font = (PGFont) FontHelper.getNativeFont(Font.font("Monaco", 12));
 105         PGFont font2 = (PGFont) FontHelper.getNativeFont(Font.font("Tahoma", 12));
 106 
 107         /* simple case */
 108         layout.setContent("hello", font);
 109         verifyLayout(layout, 1, 1, 5);
 110 
 111         /* simple case, two workd*/
 112         layout.setContent("hello world", font);
 113         verifyLayout(layout, 1, 1, 11);
 114 
 115         /* empty string */
 116         layout.setContent("", font);
 117         verifyLayout(layout, 1, 1, 0);
 118 
 119         /* line break */
 120         layout.setContent("\n", font); //first line has the line break (glyphCount=0),
 121         verifyLayout(layout, 2, 2, 0,0);
 122         layout.setContent("\r", font);
 123         verifyLayout(layout, 2, 2, 0,0);
 124         layout.setContent("\r\n", font);
 125         verifyLayout(layout, 2, 2, 0,0);


< prev index next >