-
Notifications
You must be signed in to change notification settings - Fork 576
Accents, DIN 91379, non Latin scripts
To process text containing letters composed of multiple Unicode glyphs e.g. letters with accents, it is necessary to compute the correct positioning of the glyphs and code this positions into the resulting PDF file.
OpenPDF can process such texts starting with release 1.3.24.
Internally OpenPDF uses Java2D builtin routines for glyph layout, reordering and substitution. For Java 9 and newer these routines rely on the HarfBuzz shaping library.
We tested this approach with letters conforming to "DIN 91379: Characters and defined character sequences in Unicode for the electronic processing of names and data exchange in Europe, with CD-ROM" (and the predecessor DIN SPEC 91379) which describes a subset of Unicode consisting mainly of Latin letters and diacritic signs. This standard will be mandatory for the data exchange of the German administration with citizens and businesses from Nov. 2024.
The processing of text in other languages and scripts using this approach should be possible, you are invited to try it and share the results.
import com.lowagie.text.pdf.LayoutProcessor;
...
LayoutProcessor.enable();
Optionally it is possible to provide a different text direction.
LayoutProcessor.enable(java.awt.Font.LAYOUT_RIGHT_TO_LEFT);
Provide a TrueType/OpenType font containing the necessary characters and positioning information, e.g. a font from the Google Noto fonts.
String fontFileName = "com/lowagie/examples/fonts/NotoSans-Regular.ttf";
FontFactory.register(fontFileName, "sans");
Font font = FontFactory.getFont("sans", BaseFont.IDENTITY_H, fontSize);
Process the document or form as usual.
GlyphLayoutDocumentDinSpec91379.java
GlyphLayoutFormDinSpec91379.java
- String.Latin+ 1.2 (extended and commented version of DIN SPEC 91379 in German)
- DIN SPEC 91379: Characters in Unicode for the electronic processing of names and data exchange in Europe (free download after registration)
- DIN 91379: Characters and defined character sequences in Unicode for the electronic processing of names and data exchange in Europe, with CD-ROM (Draft can be read after registration)
- DIN 91379:2021-07 - Draft: Characters and defined character sequences in Unicode for the electronic processing of names and data exchange in Europe, with CD-ROM
- Decision of IT Planungsrat 2019/53 (in German)
- Noto fonts, see Google, GitHub
- HarfBuzz text shaping library