CrossManager  V2024.3
PDF 2d Font Substitution

Table Of Contents:

All configuration fields refer to [PDF CONF] section in the configuration file.


Font Substitution Prerequesites

If you want to use font substitution into PDF 2D Write, you first have to disable text rasterization by putting:

# Should we convert texts to polylines ?
# [1] -> Yes(Default), [0] -> No
RASTERIZE_TEXTS=0

... in the configuration file.
Disabling text rasterization makes mandatory to have one font used in last resort.
You can put the default font with TRUETYPE_FONT field:

# Font (TrueType or OpenType) used to display texts in PDF File if we don't rasterize them
# Please provide fullpath.
# If font is not found at the specified path, RASTERIZE_TEXTS will be activated.
# Arial Unicode MS: Standard Windows unicode font
# provided with MS Office
#TRUETYPE_FONT="C:\Windows\Fonts\ARIALUNI.TTF"
# QUIVIRA: Open source font with good unicode support
# Get it from http://www.quivira-font.com/
#TRUETYPE_FONT="C:\Windows\Fonts\Quivira.otf"
# GNU Unifont: UNICODE font with full support of
# unicode Basic Multilingual Plane (BMP).
# Get it from http://www.unifoundry.com/unifont.html
TRUETYPE_FONT="C:\Windows\Fonts\unifont-6.3.20140214.ttf"

As you can see, the configuration provides several font samples:

  • The first one is ARIALUNI.TTF, a windows standard unicode font.
    It can handle a wide set of unicode codepoints in the Basic Multilingual Plane (BMP).
    It's provided with MS Office.
  • The second one is QUIVIRA.
    It's an open source font with quite good unicode support.
  • The last one is the GNU Unifont.
    It's a GPL font providing a full support of the BMP but looks ugly - terminal style font -

You have to provide one font with full pathname file.
If the file doesn't exist or is not a valid TTF font file, the PDF 2D writer will switch automatically to RASTERIZE_TEXTS mode.


How to Use Font Substitution

To use font substitution, you basically have to use the TRUETYPE_FONTS_SUBSTITUTE_CSV_FILE field:

# This option lets you give a CSV file for font substitution
# the CSV format is given in the CSV file header if it doesn't exist.
TRUETYPE_FONTS_SUBSTITUTE_CSV_FILE="D:\TTFFontsSubstitute.csv"

The font substitution file is a CSV file with the following format:

Font Name + Bold/Italic/Bold Italic/etc;TTF or TTC Font FileName;TTC Font Index or 0 by Default;

Semi-colons ';' separate each parameter.
Each line is related to a font substitution. Here some samples:

Times New Roman Bold;C:\Windows\Fonts\ANTQUAB.TTF;0; #Substitute Times New Roman Bold as Book Antiqua Bold
Times New Roman Bold Italic;C:\Windows\Fonts\SCHLBKBI.TTF;0; #Substitute Times New Roman Bold Italic as Century Schoolbook Bold Italic
Times New Roman Italic;C:\Windows\Fonts\couri.ttf;0; #Substitute Times New Roman Italic as Courier New Italic
Times New Roman Regular;C:\Windows\Fonts\comic.ttf;0; #Substitute Times New Roman Regular as CComic sans MS Regular

How to Generate a Font Substitution File.

You can generate a font substitution file by enabling the DUMP_TRUETYPE_FONTS_SUBSTITUTE_CSV_FILE field:

# This option lets you give a CSV file for font substitution dumping.
# it's usefull to dump found font mapping if you have previously enabled FILL_SYSTEM_FONTS option
# the CSV format is given in the CSV file header
DUMP_TRUETYPE_FONTS_SUBSTITUTE_CSV_FILE="D:\DumpTTFFontsSubstitute.csv"

If the file doesn't exist previously, it will be generated with basic header section explaining file format.
You can alternatively generate a full font substitution file from you own system by also enabling the FILL_SYSTEM_FONTS field:

# This option enable parsing of system fonts on the processing computer.
FILL_SYSTEM_FONTS=0