jfx icon indicating copy to clipboard operation
jfx copied to clipboard

8286867: Update #getGlyphCode return a negative number

Open Tomator01 opened this issue 3 years ago • 13 comments

When I used BlueJ, I found a problem with Chinese display. /javafx.graphics/com/sun/javafx/font/CompositeGlyphMapper.java#getGlyphCode may return a negative number when no font library is specified in Linux,and this could cause java.lang.ArrayIndexOutOfBoundsException error.So javafx.graphics/com/sun/prism/impl/GlyphCache.java#getCachedGlyph shou check the glyphCode. The crash demo like this: `import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.layout.BorderPane; import javafx.stage.Stage;

public class MenuExample extends Application { public static void main(String[] args) {
launch(args);
}

@Override  
public void start(Stage primaryStage) throws Exception {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root,200,300);
    MenuBar menubar = new MenuBar();
    Menu FileMenu = new Menu("文本");
    MenuItem filemenu1=new MenuItem("新建");
    MenuItem filemenu2=new MenuItem("Save");  
    MenuItem filemenu3=new MenuItem("Exit");  
    Menu EditMenu=new Menu("Edit");  
    MenuItem EditMenu1=new MenuItem("Cut");  
    MenuItem EditMenu2=new MenuItem("Copy");  
    MenuItem EditMenu3=new MenuItem("Paste");  
    EditMenu.getItems().addAll(EditMenu1,EditMenu2,EditMenu3);  
    root.setTop(menubar);  
    FileMenu.getItems().addAll(filemenu1,filemenu2,filemenu3);  
    menubar.getMenus().addAll(FileMenu,EditMenu);  
    primaryStage.setScene(scene);  
    primaryStage.setTitle("TEST");
    primaryStage.show();  
      
}     

} `

the error: java.lang.ArrayIndexOutOfBoundsException: Index -25 out of bounds for length 32 at com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:332) at com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148) at com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101) at com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312) at com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270) at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479) at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328) at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Integration blocker

 ⚠️ Title mismatch between PR and JBS for issue JDK-8286867

Issue

  • JDK-8286867: CompositeGlyphMapper.java#getGlyphCode return a negative number ⚠️ Title mismatch between PR and JBS.

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx pull/795/head:pull/795
$ git checkout pull/795

Update a local copy of the PR:
$ git checkout pull/795
$ git pull https://git.openjdk.org/jfx pull/795/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 795

View PR using the GUI difftool:
$ git pr show -t 795

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/795.diff

Tomator01 avatar May 13 '22 05:05 Tomator01

Hi @Tomator01, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user Tomator01" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

bridgekeeper[bot] avatar May 13 '22 05:05 bridgekeeper[bot]

The crash demo like this: `import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.layout.BorderPane; import javafx.stage.Stage;

public class MenuExample extends Application { public static void main(String[] args) {
launch(args);
}

@Override  
public void start(Stage primaryStage) throws Exception {
    BorderPane root = new BorderPane();
    Scene scene = new Scene(root,200,300);
    MenuBar menubar = new MenuBar();
    Menu FileMenu = new Menu("文本");
    MenuItem filemenu1=new MenuItem("新建");
    MenuItem filemenu2=new MenuItem("Save");  
    MenuItem filemenu3=new MenuItem("Exit");  
    Menu EditMenu=new Menu("Edit");  
    MenuItem EditMenu1=new MenuItem("Cut");  
    MenuItem EditMenu2=new MenuItem("Copy");  
    MenuItem EditMenu3=new MenuItem("Paste");  
    EditMenu.getItems().addAll(EditMenu1,EditMenu2,EditMenu3);  
    root.setTop(menubar);  
    FileMenu.getItems().addAll(filemenu1,filemenu2,filemenu3);  
    menubar.getMenus().addAll(FileMenu,EditMenu);  
    primaryStage.setScene(scene);  
    primaryStage.setTitle("TEST");
    primaryStage.show();  
      
}     

}
`

Tomator01 avatar May 13 '22 05:05 Tomator01

@Tomator01 thank you for your interest in contributing to the OpenJFX project.

In order for any comments that you add to this (or any other) PR to be retained, you will need to accept the OpenJDK Terms of Use as shown above. This is a one-time step.

Please read the CONTRIBUTING guidelines, in particular the Before submitting a pull request section, for steps needed to advance this pull request, including:

  • Sign and submit the OCA, then indicate that you have done so with the /signed command
  • Submit a bug report with a test case at bugreport.java.com

kevinrushforth avatar May 13 '22 12:05 kevinrushforth

I see that you already have submitted a bug report. You should get an email when it is made public.

kevinrushforth avatar May 13 '22 12:05 kevinrushforth

thanks,I'll wait for the bug

Tomator01 avatar May 16 '22 08:05 Tomator01

/signed

Tomator01 avatar May 17 '22 13:05 Tomator01

Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

bridgekeeper[bot] avatar May 17 '22 13:05 bridgekeeper[bot]

@Tomator01 thank you for your interest in contributing to the OpenJFX project.

In order for any comments that you add to this (or any other) PR to be retained, you will need to accept the OpenJDK Terms of Use as shown above. This is a one-time step.

Please read the CONTRIBUTING guidelines, in particular the Before submitting a pull request section, for steps needed to advance this pull request, including:

  • Sign and submit the OCA, then indicate that you have done so with the /signed command
  • Submit a bug report with a test case at bugreport.java.com

Hello,i have signed oca ,and pull /signed command ,so I'm just wait for OCA to pass?

Tomator01 avatar May 17 '22 13:05 Tomator01

Reading the author's description of this PR, one wonders why the added condition is not "glyphCode < 0".

if (glyphCode <= 0) {return null;}

yososs avatar May 17 '22 13:05 yososs

Reading the author's description of this PR, one wonders why the added condition is not "glyphCode < 0".

if (glyphCode <= 0) {return null;}

Your suggestion is right

Tomator01 avatar May 17 '22 13:05 Tomator01

Hello,i have signed oca ,and pull /signed command ,so I'm just wait for OCA to pass?

Yes, at this point you wait for your OCA to be processed.

kevinrushforth avatar May 17 '22 17:05 kevinrushforth

Webrevs

mlbridge[bot] avatar May 18 '22 21:05 mlbridge[bot]

I can repeated this issue on uos when the linux doesn't have /usr/share/fonts/wps-office/FZSongS_20100603.TTF file ,openjfx version 11,method getGlyphCode will return a negative number

Tomator01 avatar May 26 '22 06:05 Tomator01

@Tomator01 This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Mar 31 '23 23:03 bridgekeeper[bot]

@Tomator01 This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar Apr 29 '23 02:04 bridgekeeper[bot]