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

[win] Negative glyph_id causes ArrayIndexOutOfBoundsException

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Also all Windows

      # NOTICE
      Now Windows API provide glyphIndices as UINT16.
      Exsample)
      https://msdn.microsoft.com/en-us/library/windows/desktop/dd316625%28v=vs.85%29.aspx

      But originally, Windows API should provide as UINT32.
      Because CMAP Format 8,12,13 have UINT32.
      https://docs.microsoft.com/en-us/typography/opentype/spec/cmap
      https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html

      A DESCRIPTION OF THE PROBLEM :
      When display particular glyph (glyphID is larger than 32767 and complex char),
       Java errors ArrayIndexOutOfBoundsException.

      This bug occurs only when all of the following conditions are satisfied.
       1. on Windows
       2. font has glyphID larger than 32767 (max value of signed short)
       3. font has complex character. (isComplexCharCode() return true)


      Now I doing pull request.
      https://github.com/javafxports/openjdk-jfx/pull/125

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Please run following BigGlyphIDTest.java

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Display glyphs without errors.
      https://drive.google.com/open?id=1b9xmr7dJcbI52FRY6In2BNxkqpNyfprt
      ACTUAL -
      java.lang.ArrayIndexOutOfBoundsException: Index 255 out of bounds for length 10
              at javafx.graphics/com.sun.javafx.font.CompositeStrike.getStrikeSlot(CompositeStrike.java:120)
              at javafx.graphics/com.sun.javafx.font.CompositeStrike.getGlyph(CompositeStrike.java:163)
              at javafx.graphics/com.sun.prism.sw.SWGraphics.drawGlyph(SWGraphics.java:632)
              at javafx.graphics/com.sun.prism.sw.SWGraphics.drawString(SWGraphics.java:617)
              at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
              at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
              at javafx.graphics/com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
              at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
              at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
              at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
              at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
              at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
              at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
              at javafx.graphics/com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:142)
              at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
              at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
              at javafx.graphics/com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
              at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
              at java.base/java.lang.Thread.run(Thread.java:834)

      ---------- BEGIN SOURCE ----------
      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 BigGlyphIDTest 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 family = "Unifont";
              // download GNU Unifont and install
              // http://www.unifoundry.com/unifont.html
              // http://unifoundry.com/pub/unifont-11.0.01/font-builds/unifont-11.0.01.ttf

              Font font = Font.font(family, 48.0);
              if (font == null || !family.equals(font.getFamily())) {
                  System.err.println("# You need to install font "+family);
                  System.exit(0);
              }

              stage.setWidth(100);
              stage.setHeight(100);
              Group g = new Group();
              final Scene scene = new Scene(new Group());
              VBox box = new VBox();
              ((Group)scene.getRoot()).getChildren().add(box);
              stage.setScene(scene);

                                                   // Unicode(GlyphID)
              Text txt = new Text("\u8002\u0362"); // U+8002(32773) + U+0362(869)
              txt.setFont(font);
              box.getChildren().add(txt);

              stage.show();
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              prr Philip Race
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: