changeset 11212:bf9eac8eebef 13+2

8208076: display INVISIBLE_GLYPH_ID as square box on Windows Reviewed-by: kcr, prr Contributed-by: nakajima.akira@nttcom.co.jp
author kcr
date Thu, 14 Mar 2019 01:25:19 -0700
parents e687603602c1
children 32cf81a3bd8b
files modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWGraphics.java tests/manual/text/INVISIBLE_GLYPH_IDTest.java tests/manual/text/INVISIBLE_GLYPH_IDTest_Expected.png
diffstat 3 files changed, 83 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWGraphics.java	Tue Mar 12 17:56:10 2019 -0700
+++ b/modules/javafx.graphics/src/main/java/com/sun/prism/sw/SWGraphics.java	Thu Mar 14 01:25:19 2019 -0700
@@ -62,6 +62,7 @@
 import com.sun.prism.paint.Color;
 import com.sun.prism.paint.ImagePattern;
 import com.sun.prism.paint.Paint;
+import com.sun.javafx.font.CharToGlyphMapper;
 
 final class SWGraphics implements ReadbackGraphics {
 
@@ -632,8 +633,10 @@
     private void drawGlyph(FontStrike strike, GlyphList gl, int idx, BaseTransform glyphTx,
                            boolean drawAsMasks, float x, float y)
     {
-
         final Glyph g = strike.getGlyph(gl.getGlyphCode(idx));
+        if (g.getGlyphCode() == CharToGlyphMapper.INVISIBLE_GLYPH_ID) {
+            return;
+        }
         if (drawAsMasks) {
             final Point2D pt = new Point2D((float)(x + tx.getMxt() + gl.getPosX(idx)),
                                            (float)(y + tx.getMyt() + gl.getPosY(idx)));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/manual/text/INVISIBLE_GLYPH_IDTest.java	Thu Mar 14 01:25:19 2019 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 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
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javafx.application.Application;
+import static javafx.application.Application.launch;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Font;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+
+public class INVISIBLE_GLYPH_IDTest extends Application {
+
+    private static String OS = System.getProperty("os.name").toLowerCase();
+
+    public void start(Stage stage) {
+        if (OS.indexOf("win") < 0) {
+            System.err.println("# You need to run on Windows");
+            System.exit(0);
+        }
+
+        final String fontName = "ipaexm.ttf";
+        // download from https://ipafont.ipa.go.jp/node26#en
+        // and place in {user.home}/fonts/
+
+        String userHome = System.getProperty("user.home");
+        userHome = userHome.replace("\\", "/");
+        final String base = userHome+"/fonts/";
+        Font font = Font.loadFont("file:"+base+fontName, 48);
+        if (font == null || !"IPAexMincho".equals(font.getName())) {
+            System.err.println("# You need to place "+fontName+" in "+base);
+            System.exit(0);
+        }
+
+        stage.setWidth(140);
+        stage.setHeight(260);
+        Group g = new Group();
+        final Scene scene = new Scene(new Group());
+        VBox box = new VBox();
+        ((Group)scene.getRoot()).getChildren().add(box);
+        stage.setScene(scene);
+
+        Text txt = new Text("\ud869\ude1a"); // U+2A61A (surrogate pair)
+        txt.setFont(font);
+        box.getChildren().add(txt);
+
+        Image img = new Image("INVISIBLE_GLYPH_IDTest_Expected.png");
+        ImageView iv = new ImageView();
+        iv.setImage(img);
+        box.getChildren().add(iv);
+
+        stage.show();
+    }
+}
Binary file tests/manual/text/INVISIBLE_GLYPH_IDTest_Expected.png has changed