Q-1-2. I understand that fonts can be setup in the dtype.fls initialization file or directly through calls to D-Type. When using dtEngineIniViaStream or pdEngineIniViaStream, is it possible to run with an empty font list and set up fonts completely through code?
Of course. This can be done in two different ways:
a) Specify an empty font list in dtype.fls as illustrated below:
# *** D-TYPE INITIAL FONT LIST V7.5 ***
#
# This file contains a list of fonts that will be added to D-Type Engine's Font Catalog as
# soon as the corresponding D-Type Engine instance is initialized. Each row in this list
# consists of the following parameters:
#
# * font_format_id - Font Format ID. This is an ID that specifies the font format:
#
# 0 : D-Type font (.dtf)
# 3 : OpenType font (.ttf or .otf) and font collections (.ttc) with TrueType outlines
# 5 : OpenType font (.otf) and font collections (.ttc) with CFF outlines
# 8 : Adobe Type 1 font (.pfb or .pfa)
# 12 : Adobe Type 3 PostScript font (.ps)
# 16 : Bare CFF font (.cff)
#
# Other values are also supported. See the manual for details.
#
# * fuid - Unique Font Identifier
#
# This is an optional but recommended string that uniquely identifies the font.
# If not needed, set to NULL. Otherwise, the string must consist of precisely
# 16 ASCII characters.
#
# * fcnr - Font Collection Number
#
# When the font file is a font collection, this is the index of a font in that
# collection. Set to 0 to add the first font in the collection or if the font file
# is not a collection.
#
# * cmap_id - Reserved for future. Must be set to -1.
#
# * caching - Font Access and Caching. The following values are recommended:
#
# 0 : legacy method
# 128 : standard method
#
# * hinting - Font Hinting. This parameter can have one of the following values:
#
# 0 : disable hinting
# 1 : use native hinting when available; auto-hinting otherwise
# 2 : use auto-hinting exclusively
# 3 : use native hinting when available; compact auto-hinting otherwise
# 4 : use compact auto-hinting exclusively
#
# * nr_of_streams - Number of streams that will supply the font data.
#
# Most font formats contain all font data in a single stream (file). Therefore, this
# parameter is typically 1. Some font formats (e.g. Type 1) may supply additional
# font data via additional streams. In this case nr_of_streams will be greater than 1.
# See the manual for details on how those font formats utilize the additional streams.
#
# * stream_sequence - A sequence of nr_of_streams stream descriptors that supply font data.
#
# Each stream descriptor consists of the following two parameters:
#
# * stream_id - identifies the stream type:
#
# 0 : Default Stream Type. Same as File Stream.
# 1 : File Stream
# 2 : Memory Stream
# 3 : URL Stream
# 5 : FURL Stream (File-Backed URL Stream)
# 6 : MURL Stream (Memory-Backed URL Stream)
#
# * stream_locator - stream type specific locator (e.g. file path or URL).
#
# Regardless of the font format, the first stream descriptor in the array always
# supplies vital font data.
#
# * reserved - Reserved for future. Must be set to NULL.
#
# The parameters in each row must be separated by a single comma and specified in precisely
# the same order as listed above.
{
}
or
b) Remove the dtype.fls file altogether and specify the 'NONE' stream for the initial font list in the main dtype.inf initialization file. This is illustrated below:
# *** D-TYPE MAIN INITIALIZATION FILE VERSION 8.0 OR HIGHER ***
# A) OPTIONAL SECONDARY INITIALIZATION FILES
# 1. Stream descriptor for the initial font list
# (Use the 'NONE' stream if the initial font list is not needed)
#
# 2. Stream descriptor for the pattern catalog
# (Use the 'NONE' stream if the pattern catalog is not needed)
#
# 3. Stream descriptor for the custom gray-scale table
# (Use the 'NONE' stream for the default 256 levels of gray)
#
# Notes:
#
# * All stream descriptors must be specified as [Stream ID],[Stream Locator]
# (See the manual for a list of stream descriptors)
#
# * Any non-existent or inaccessible streams (e.g. due to lack of adequate
# read permissions) will be interpreted as 'NONE' streams.
{
-1,NONE
0,system\ini\dtype.pat
0,system\ini\gs256.gsl
}
Q-1-3. How can I identify D-Type functions?
D-Type functions have the dt, dtx, dts, pd, pdx, tx, lx or dc prefix. For example, dtEngineIniViaStream, dtGlyphDoOutput, dtxTextDoOutput, pdEngineIniViaStream, txTextIniViaStream are all D-Type functions. The dt, pd, tx, lx and dc functions are located inside D-Type's dynamic or static library files. The dtx functions are located inside the dtextras.cpp file. The dts functions are located inside the dtshapes.cpp file. The pdx functions are located inside the pdextras.cpp file.
Q-1-4. The dtEngineIniViaStream (or pdEngineIniViaStream) function returns 0. What is the problem?
When initializing using the dtEngineIniViaStream (or pdEngineIniViaStream) function, D-Type Engine will look for the main dtype.inf initialization file. In addition, dtype.inf also references several other secondary initialization files. If your initialization fails, here are some of the possible reasons for this:
a) your main dtype.inf file is corrupt or is not in the right location
b) some of the secondary initialization files are missing, not specified correctly or corrupt
c) font paths in the initial font list are not specified correctly
d) the amount of memory reserved for the bitmap and/or transformation cache in the dtype.inf file is excessively large and exceeds the amount of memory your operating system can allocate
Q-1-5. Can I create the dtype.inf file dynamically, prior to the initialization of D-Type Engine?
Yes, if necessary the dtype.inf file can be created dynamically, prior to the initialization of D-Type Engine. This file can be created either on disk or in memory. See this page for more information.
Q-1-6. Why is the tmp folder required? Will my program work if I remove this folder?
The tmp folder is a storage for any temporary resources that might be created during execution (e.g. font cache). Consequently, this folder must be configured to allow D-Type Font Engine to READ/WRITE/MODIFY/DELETE files in it.
While this directory does not have to exist, it is highly recommended. If the tmp directory does not exist, D-Type Font Engine will attempt to use RAM instead. You should remove the tmp directory only if you are certain that your application will run on a system with enough RAM to support all your fonts.
Q-1-7. The initialization of D-Type Font Engine fails if I try to run my application from the Windows Command Prompt. I am using the dtEngineIniViaStream (or pdEngineIniViaStream) function to initialize the engine.
The dtEngineIniViaStream (or pdEngineIniViaStream) function reads the configuration settings from the dtype.inf file, in which the initialization paths by default are relative to the application's current working directory. When you are running the program from the command line, the current working directory is not your application's directory but Windows/System32 (or something similar). As a result the engine cannot find the necessary initialization files and the initialization fails.
There a few different ways to solve this problem:
Modify all initialization paths inside the dtype.inf file to be absolute (and not relative to your application's working directory). In addition, if you are using the Initial Font List, you will also need to modify any relative paths in the dtype.fls file in the same way.
In some cases, it is not possible to know in advance where the application's working directory is going to be. So this must be obtained at runtime. Once the application's working directory is retrieved, the dtype.inf file (and dtype.fls if necessary) can be dynamically created by your application before calling the dtEngineIniViaStream function. All the paths in those dynamically created initialization files would be defined as absolute.
Probably the best option is to obtain your application's working directory at runtime and then use the Windows SetCurrentDirectory function to set your application's directory to be the current working directory. In this way, you can keep all paths in the dtype.inf and dtype.fls files relative and your program should work fine.
To understand this problem better, imagine your application must read some file from its working directory. You could attempt to open the file using a relative path (e.g. FILE* f=fopen("myfile.txt", "rb")) but this will likely fail when your application is called from the command line because the current working directory is Windows/System32. Therefore, your application must ensure the requested file can be found — either by using an absolute file path or by changing the current working directory using the SetCurrentDirectory function.