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
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);
}
}