Hi Dian,
Thanks a lot for the mail. Yes I am using Java to generate JPEG's from text file. Please see the abstract of the code below.
Also I tried an online applet (
which basically is an online Khmer keyboard. There it is possible to open an UTF-8 document and also paste the khmer text. I tried it and there also i am getting the same issue. I read that from Java v 1.6 khmer is supported and I run v 1.6.
Also if you see in this conversion site (
for decimal NCR (ថៃ្ងសម្រាក

we get the corresponding text as ?????????? If I copy this text and paste to the online applet described above, I still get the issue where the subscript is removed from the parent.
Does this have to with my font settings in the java lib directory? or is this incompatibility of the font?
############Code############################
public class Khmer {
public Khmer(BufferedImage image, String ttxt, String file_name, float font_size, Color font_color, String ext) throws Exception {
drawText(image, ttxt, font_size, font_color);
save(image, file_name, ext);
}
private void drawText(BufferedImage image, String text2, float size, Color font_color) throws Exception {
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
File f = new File("Kh-System.ttf");
FileInputStream in = new FileInputStream(f);
Font dynamicFont = Font.createFont(Font.TRUETYPE_FONT, in);
Font dynamicFont32Pt = dynamicFont.deriveFont(size);
Font font = dynamicFont32Pt;
g2.setFont(font);
FontRenderContext frc = g2.getFontRenderContext();
float width = (float) font.getStringBounds(text2, frc).getWidth();
LineMetrics lm = font.getLineMetrics(text2, frc);
float height = lm.getAscent() + lm.getDescent();
float x = (image.getWidth() - width) / 2f;
float y = (image.getHeight() + height) / 2f - lm.getDescent();
g2.setPaint(font_color);
g2.drawString(text2, x, y);
g2.dispose();
}
private void save(BufferedImage image, String file_name, String ext) throws Exception {
File file = new File(file_name + "." + ext);
try {
ImageIO.write(image, ext, file);
System.out.println(print_out);
} catch (IOException e) {
System.out.println("write error: " + e.getMessage());
}
}
public static void main(String[] args) throws Exception {
File file = new File(file_name_arg);
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file_name_arg), "UTF8"));
while ((strLine = br.readLine()) != null) {
toSend = "";
temp_file_data = strLine.split(cc_delimiter);
file_name = temp_file_data[0];
m = MY_PATTERN.matcher(file_name);
while (m.find()) {
file_name = m.group(1);
}
for (int li = 1; li < temp_file_data.length; li++) {
if(li > 1 )
toSend = toSend+cc_delimit_const+temp_file_data[li];
else
toSend = toSend+temp_file_data[li];
}
File file3 = new File("blank.jpg");
BufferedImage image = ImageIO.read(file3);
hei_wid = widthandheight(image, toSend, fnt_sze);
graphics2D = image2.createGraphics();
graphics2D.setColor(Color.WHITE);
graphics2D.fillRect(0, 0, x1, y1);
new Khmer(image2, toSend, file_name, fnt_sze, pass_fnt_color, cc_imgtype);
}
Thanks,
Subin