Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add motivations to add FOP #584

Closed
Marco-Sulla opened this issue Aug 4, 2021 · 9 comments · Fixed by #585
Closed

Add motivations to add FOP #584

Marco-Sulla opened this issue Aug 4, 2021 · 9 comments · Fixed by #585

Comments

@Marco-Sulla
Copy link

Currently, in the README there's no explanation why someone should consider to add FOP too.
PS: and I'm curious :D

@codecracker2014
Copy link
Contributor

Fop is required to process gsub table for TTF fonts. Without this glyph substitution doesn't work properly.
Ex: #297

Without FOP output[Incorrect]:
image

With FOP output[Correct]:
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();
  ```
  
  
      
        
      
  
        
      
  
      
    
  }
  }

`

gsub processing using FOP was added in #329.

@codecracker2014
Copy link
Contributor

Adding above to wiki as well.

@codecracker2014
Copy link
Contributor

Wiki link: https://github.com/LibrePDF/OpenPDF/wiki/Multi-byte-character-language-support-with-TTF-fonts

@codecracker2014
Copy link
Contributor

updating main page with #585

@Marco-Sulla
Copy link
Author

Is it only for this? I read also for ligatures.

@codecracker2014
Copy link
Contributor

Yes

@vk-github18
Copy link
Contributor

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:
image

Maybe we should also add a reference to LayoutProcessor to the README-file.

@asturio
Copy link
Member

asturio commented Oct 12, 2021

The PR is merged, can we close this?
@vk-github18

@vk-github18
Copy link
Contributor

@asturio thanks, we can close this.

@asturio asturio closed this as completed Oct 12, 2021
@asturio asturio linked a pull request Mar 5, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants