RFR: 8286867: Update #getGlyphCode return a negative number

Tomator duke at openjdk.java.net
Wed May 18 21:16:12 UTC 2022


On Mon, 16 May 2022 08:12:54 GMT, Tomator <duke at openjdk.java.net> wrote:

>> 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)
>> `
>
>> 
> 
> 
> 
>> 
> 
> thanks,I'll wait for the bug

> @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](https://github.com/openjdk/jfx/blob/master/CONTRIBUTING.md) guidelines, in particular the [Before submitting a pull request](https://github.com/openjdk/jfx/blob/master/CONTRIBUTING.md#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](https://bugreport.java.com/)

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

-------------

PR: https://git.openjdk.java.net/jfx/pull/795


More information about the openjfx-dev mailing list