3

In my program I am reading a Bangla (Indic Language) text from a UTF-8 file and displaying in Text component of JavaFx. Though the characters are being displayed , they are not positioned properly.

In this type of complex script language some of the vowels should wrap around the letter both in the left and right side but in some of the computers it is showing in a wrong manner i.e. first the vowel and then the letter.

e.g. the words which contains the "split vowel" ো are not displayed correctly. https://bug686225.bugzilla.mozilla.org/attachment.cgi?id=559780

In the system it got fixed using http://www.tariquemahmud.net/?p=35 but in the JavaFx Program , the problem still continues.

Wrong display Wrong display

Correct Deisplay Correct Deisplay

You can check yourself if the following executable looks correct or wrong as per above screenshot in your computer

http://dl.dropbox.com/u/655237/share/BanglaTest.zip

I am using the following code

package banglatest;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.util.Scanner;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class BanglaTest extends Application {

    @Override
    public void start(Stage primaryStage) throws MalformedURLException {
        Text text = new Text();
        File file = new File("data.txt");
        StringBuffer sb = new StringBuffer();
        try {
            Scanner scanner = new Scanner(file,"UTF-8");
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                sb = sb.append(line);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        text.setText(sb.toString());
        Font font = Font.loadFont(new File("bangla.ttf").toURL().toExternalForm(), 20);
        text.setFont(font);
        StackPane root = new StackPane();
        root.getChildren().add(text);
        Scene scene = new Scene(root, 300, 250);
        primaryStage.setTitle("Hello World!");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
Neil
  • 5,919
  • 15
  • 58
  • 85
  • 1
    Ok if you think it is a bug, you can file it at JavaFX Jira. And your question is about workaround for it I guess? – Uluk Biy Nov 02 '12 at 12:59
  • Yes workaround would be great, I'll file Jira once it is confirmed to be a bug – Neil Nov 02 '12 at 13:31
  • 1
    Confirmation will be faster, more precise and accurate at Jira where the oracle tech guys take care of it. If it isn't a bug, issue will be closed as "Cannot reproduce", "Wrong test case" or v.s. – Uluk Biy Nov 02 '12 at 14:11
  • Added JIRA http://javafx-jira.kenai.com/browse/RT-26002 – Neil Nov 04 '12 at 14:57

1 Answers1

1

Finally this support came in JDK 8 (FX 8). Recompiled using the Developer preview of the same and it worked.

Neil
  • 5,919
  • 15
  • 58
  • 85