Openpdf: Multilingual fonts not supported properly as typography rules not implemented.

Created on 16 Nov 2019  路  5Comments  路  Source: LibrePDF/OpenPDF

Most helpful comment

itext2 was used in more then 150 open source libraries, now these libraries can use OpenPDF. But all of them having this limitation. Itext was rewritten just add advanced typography, which is no longer compatible with other open source libraries. I'm working on improving OpenPDF to support advanced typography and got it working. I'll share pull request shortly.

All 5 comments

@codecracker2014 thanks for this issue but what would you mean? Any particular issue? Code to reproduce it?

Current output:
image

Expected output:
image

This is due to glyph substitutions not done as per TTF file.
Below is link to typography specs:
https://docs.microsoft.com/en-us/typography/opentype/spec/gsub

Below is code for creating simple PDF using TTF font :

`
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

import java.io.FileOutputStream;
import java.io.IOException;

/**

  • Created by gajendra.jatav on 11/20/2019.
    */
    public class HelloWorld {
public static void main(String[] args) {

    System.out.println("啶ㄠぎ啶膏啶む");

    FontFactory.register("C:\\Windows\\Fonts\\NIRMALA.TTF");
    // step 1: creation of a document-object
    Document document = new Document();
    try {
        // step 2:
        // we create a writer that listens to the document
        // and directs a PDF-stream to a file
        PdfWriter.getInstance(document,
                new FileOutputStream("D:\\workspace\\TMP\\out\\HelloWorld.pdf"));

        // step 3: we open the document
        document.open();
        // step 4: we add a paragraph to the document
        document.add(new Chunk(
                "啶ㄠぎ啶膏啶む",
                FontFactory.getFont("nirmala ui", "Identity-H",false,10,0,null)));
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
}

}

`

Just like in iText 5, OpenPDF only has a limited support for advanced typography.

itext2 was used in more then 150 open source libraries, now these libraries can use OpenPDF. But all of them having this limitation. Itext was rewritten just add advanced typography, which is no longer compatible with other open source libraries. I'm working on improving OpenPDF to support advanced typography and got it working. I'll share pull request shortly.

Pull requested created- #329

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelhugi picture michaelhugi  路  6Comments

bbottema picture bbottema  路  5Comments

fono picture fono  路  7Comments

mattymurphy picture mattymurphy  路  3Comments

sabraMa picture sabraMa  路  5Comments