SignDoc SDK (C)
5.0.1.32
|
For inserting text into PDF documents (e.g., for creating the appearance of DigSig signatures or filling in PDF text fields), suitable fonts are required. If the PDF document is not PDF/A-compliant and only characters covered by WinAnsiEncoding are used, standard fonts can be used. For PDF/A-compliant documents, all fonts must be embedded, for all other documents, it's recommended to embed all fonts. To embed a font which is not already embedded, you need two things: The font file (in TrueType or OpenType format) and a font configuration file.
For interactive fields (e.g., text fields), it is recommended to specify a standard font (such as "Helvetica") and let the font configuration use other fonts when needed (e.g., for embedding). That way, for later changes to the values of the fields, such substitutions can be done again even if the font is subsetted and lacks glyphs for the new value. On the other hand, if you specify a non-standard font for a text field, later changes to the value of that field may be restricted to the characters for which glyphs are already embedded.
Font files may also be required for rendering pages that use fonts which are neither standard fonts nor embedded. Use a font configuration file to load those fonts files. It is not recommended to create PDF documents that need external fonts for rendering. Standard fonts should not be substituted for rendering. Usually, you don't need substitutions in font configuration files used for rendering.
The two types of font configuration files mentioned above use the same syntax. However, as they usually substitute standard fonts, font configuration files for inserting text into documents should not be used as font configuration files for rendering.
A font configuration file is an XML document specifying the pathnames of font files and font substitution rules. See Using SignDoc SDK in Windows Store apps for restrictions on pathnames in Windows Store apps.
Note that SignDoc SDK ignores the fsType entry in the OS/2 table of OpenType fonts. In consequence, fonts can be embedded and subsetted even if the font copyright owner prohibits embedding and/or subsetting.
See SPFontConfig.dtd for the Document Type Definition for font configuration files.
Example:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">c:\fonts\LinLibertine_*.ttf</FontFiles> <FontFiles embed="subset">c:\fonts\DejaVu*.ttf</FontFiles> <Substitution type="forced"> <FontName>Times Roman</FontName> <FontName>Linux Libertine</FontName> </Substitution> <Substitution> <FontName>Helv</FontName> <FontName>DejaVu Sans</FontName> </Substitution> <Substitution> <FontName>Helvetica</FontName> <FontName>DejaVu Sans</FontName> </Substitution> <Substitution> <FontName>Arial</FontName> <FontName>DejaVu Sans</FontName> </Substitution> </SPFontConfig>
This is equivalent to the following font configuration:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">c:\fonts\LinLibertine_*.ttf</FontFiles> <FontFiles embed="subset">c:\fonts\DejaVu*.ttf</FontFiles> <Substitution type="forced"> <FontName>Times Roman</FontName> <FontName>Linux Libertine</FontName> </Substitution> <Substitution> <FontName>Helv</FontName> <FontName>Helvetica</FontName> <FontName>Arial</FontName> <Script></Script> <FontName>DejaVu Sans</FontName> </Substitution> </SPFontConfig>
The fonts referenced by this font configuration files can be obtained from http://dejavu-fonts.org and http://linuxlibertine.sourceforge.net .
Here is an example for a font configuration that uses scripts:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">*.ttf</FontFiles> <Substitution> <FontName>*Courier*</FontName> <FontName>*Garamond*</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> </SPFontConfig>
This font configuration can also be written in a more verbose way (which is not recommended but explains how those multiple font names and scripts are interpreted):
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">*.ttf</FontFiles> <Substitution> <FontName>*Courier*</FontName> <Script>latn</Script> <FontName>NotoSerif</FontName> </Substitution> <Substitution> <FontName>*Garamond*</FontName> <Script>latn</Script> <FontName>NotoSerif</FontName> </Substitution> <Substitution> <FontName>*Courier*</FontName> <Script>cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> <Substitution> <FontName>*Garamond*</FontName> <Script>cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> </SPFontConfig>
Here is another way to formulate that font configuration:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">*.ttf</FontFiles> <Flag name="Serif"> <FontName>*Garamond*</FontName> <FontName>*Times*</FontName> </Flag> <Substitution flags="Serif"> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> </SPFontConfig>
Using flags is useful to avoid repeating font names over and over. The following font configuration maps Garamond-Bold to NotoSerif-Bold and Garamond to NotoSerif:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">*.ttf</FontFiles> <Flag name="Serif"> <FontName>*Garamond*</FontName> <FontName>*Times*</FontName> </Flag> <Substitution flags="Serif"> <FontName>*Bold</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif-Bold</FontName> </Substitution> <Substitution flags="Serif"> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> </SPFontConfig>
If you are mapping many fonts, multiple flags can simplify things:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE SPFontConfig SYSTEM "SPFontConfig.dtd"> <SPFontConfig> <FontFiles embed="subset">*.ttf</FontFiles> <Flag name="Bold"> <FontName>*Bold</FontName> </Flag> <Flag name="Serif"> <FontName>*Garamond*</FontName> <FontName>*Times*</FontName> </Flag> <Substitution flags="Serif,Bold"> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif-Bold</FontName> </Substitution> <Substitution flags="Serif"> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSerif</FontName> </Substitution> <Substitution flags="Bold"> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSans-Bold</FontName> </Substitution> <Substitution> <FontName>*</FontName> <Script>latn cyrl</Script> <FontName>NotoSans</FontName> </Substitution> </SPFontConfig>
Font configuration file SPFontConfig-Noto.xml maps all fonts (using fallback substitution rules) to the Google Noto Fonts which can be obtained from https://www.google.com/get/noto/ . There are a couple of shortcomings: For instance, there is no monospaced serif font and no monospaced bold font. Noto Color Emoji cannot be used.