Closed Marco-Sulla closed 3 years ago
Fop is required to process gsub table for TTF fonts. Without this glyph substitution doesn't work properly. Ex: #297
Without FOP output[Incorrect]:
With FOP output[Correct]:
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(); ``` } }
`
gsub processing using FOP was added in #329.
Adding above to wiki as well.
updating main page with #585
Is it only for this? I read also for ligatures.
Yes
It is also possible to render texts needing glyph positioning, substitution and reordering using LayoutProcessor. See https://github.com/LibrePDF/OpenPDF/wiki/Accents,-DIN-91379,-non-Latin-scripts The result for the example is:
Maybe we should also add a reference to LayoutProcessor to the README-file.
The PR is merged, can we close this? @vk-github18
@asturio thanks, we can close this.
Currently, in the README there's no explanation why someone should consider to add FOP too. PS: and I'm curious :D