Q-6-1. Do D-Type fonts offer any advantage over Windows .TTF fonts for smoother scaling to smaller sizes?
D-Type font engine handles TrueType, OpenType, Adobe Type 1, PostScript Type 3, Bare CFF and D-Type fonts equally well, and in most cases the results are identical in terms of quality and speed. Therefore, an application can use any of these formats, and the end-user will not notice any difference.
D-Type's .dtf format, however, offers some technological advantages over other font formats. One of the main advantages is better compression (especially when the font has many complex characters) and sophisticated automatic hinting. Non-hinted TrueType, OpenType, Type 1, Type 3 or CFF fonts can be stored in or converted to D-Type's hinted format using D-Type Font Converter.
Since D-Type fonts do not require manual hinting, any non-hinted TrueType, OpenType, Type 1, Type 3 and CFF fonts fonts will look better if they are converted to the .dtf format. This is very useful in production and delivery of custom made fonts, because tedious manual hinting can be omitted. These custom fonts can be designed using any popular font editing software (e.g. Fontographer), exported as TrueType and finally converted to D-Type. The resulting font will have the same quality as if the original TrueType font was hinted by an experienced typographer. This unique feature, however, must not be used to distribute already copyrightable TrueType, OpenType, Type 1, Type 3 or CFF fonts in D-Type format.
Note: For more information on converting fonts to D-Type format, please contact D-Type Solutions.
Q-6-2. When I add a new font to the Font Catalog, can I use it immediately?
Yes, once the font is successfully added to the Font Catalog, you can use it immediately. But if you are using multiple-master font instances, your may need to perform a few more steps:
If you do not want to use multiple-master font capabilities, or if you only use TrueType fonts, proceed to step 4.
Otherwise, obtain the number of design axes for this font by calling the dtFontGetMMAxisInfo function. If this number is 0, i.e. the font is a single-master font, proceed to step 4.
Optionally, add additional interpolated font instances to the Font Catalog by calling the dtFontAddAsMMInstance function.
Optionally, obtain other font information (e.g. font name, family name, font style etc.) by calling the dtFontGetStringValue function.
If you wish to render glyphs or text, use the DT_TYPE_ATTRIBS structure to specify typographical attributes of the font or multiple-master font instance in question. Therefore, set type by calling dtTypesetterSetTypeAttribs and finally draw glyphs or text by calling dtGlyphDoOutput, dtCharDoOutput, dtxGlyphsDoOutput, dtxCharsDoOutput.
Q-6-3. The vertical stem on the Times New Roman "h" out-rises the "T" and the "l" out-rises the "F".
Some small letters (typically h, d, f, h, k, l or b) in Times New Roman are really a little bit higher than the capital letters. The difference in height can be clearly noticed when the font size exceeds 14 points.
Q-6-4. How do I use multiple-master (or variable) fonts with D-Type?
Multiple-master font technology is an innovative and unprecedented font technology that allows two or more outline fonts, or base designs, to be incorporated into a single font file. This feature allows applications to create hundreds or thousands of additional font instances (or intermediate designs) from the base designs by applying D-Type's real-time interpolation capabilities. For example, an application can create intermediate designs that range from light to black, condensed to extended, sans serif to serif, wedge-serif to slab-serif etc.
In order to use this technology, you need multiple-master fonts. multiple-master fonts are available in Adobe Type 1, D-Type or Variable OpenType format.
Your application can simply add a multiple-master font to the Font Catalog by calling the dtFontAddViaStream function. To determine the number of design axes supported by the font, call the dtFontGetMMAxisInfo function. This function returns the number of design axes in the font, which for multiple-master fonts is always greater than 0. For single-master fonts, this number is 0.
In addition, the dtFontGetStringValue function can provide the name of each design axis, which is useful for interactive programs that allow users to create new font instances via the appropriate user interface. More information on both functions can be found in D-Type Standard Engine Manual.
Once this is done, applications can add additional font instances, or intermediate designs, to the Font Catalog using the dtFontAddAsMMInstance function. This function creates an interpolated font instance from the base designs in the font. To do this, your application must supply the contribution factor for each design axis, which is simply a percentage of its contribution in the final interpolated font. Naturally, the sum of all the base contributions must be 100%.
The return value of the dtFontAddAsMMInstance function is a font index which uniquely identifies the newly added font instance in the Font Catalog.
Q-6-5. Does D-Type automatically recognize fonts that are installed on the operating system or do we have to detect them in our code and then add them to D-Type's Font Catalog?
D-Type does not in any way recognize fonts that are installed on the operating system. You have to detect them in your code and then add them to the Font Catalog.
Q-6-6. We would like to add support for font subsetting so that our documents become more portable. Are there any separate API's for creating font subsets?
Creating subsetted fonts in D-Type format is very easy. See the dtFontSaveToStream function for details. However, there are no APIs for creating subsetted fonts in other formats (e.g. TrueType, Type 1 etc.).
Q-6-7. If we want to implement font subsetting do first have to convert each relevant font into a D-Type font or can we load a TrueType/OpenType/Type 1 font and just use dtFontSaveToStream to convert it to a subsetted D-Type font?
Simply load a TrueType/OpenType/Type 1 font and just use dtFontSaveToStream to convert it to a subsetted D-Type font. Thanks to D-Type's flexible stream system, you could also tell dtFontSaveToStream to save this subsetted D-Type font to a memory buffer. This allows you to subsequently copy the contents of the memory buffer directly to your structure or file, and/or start using the subsetted font directly from memory.
Q-6-8. If we subset the font are there any known limitations (e.g. why a font would not subset) apart from the font specifying that it cannot be subset/embedded?
No, there are no limitations at all. It is entirely up to you to decide whether you wish to respect TrueType font embedding licensing rights (see the dtFontGetNumericValue function in the manual for more info). Despite this flag, D-Type Font Engine will always let you subset any font.
Q-6-9. I understand that we can use dtFontSaveToStream to convert a font to D-Type format (if we want to subset it) and that we can decide via a callback if the glyph should be used or not. However, for this to work we need a list of glyph indexes that we can compare against. Is there any way to determine which glyphs have been used for a specific text document or maybe a string?
This depends on how you render your text.
a) If you use D-Type Standard Engine to render simple (i.e. non-complex) text:
You essentially render text using dtCharDoOutput so you know what characters appear in your text. Use dtFontGetGlyphIndex to convert these characters to glyph indexes. This is your list of glyphs that you want to keep in the subsetted font.
b) If you use D-Type Standard Engine with D-Type Text Layout Extension to render simple and complex text:
The lxLayoutApply function returns the glyph indexes via the DT_LX_GLYPH structure.
c) If you use D-Type Power Engine and/or D-Type Unicode Text Module:
See the pdDocSetGlyphCallback function.
Q-6-10. When adding fonts to D-Type we need to determine the value to pass as the font_format_id parameter. Can you suggest any resources that will help us with this?
As explained in Appendix — Predefined Font Factories and set up through dtype.inf, the values to pass as the font_format_id parameter are as follows:
Thus, if you know the font file's extension, you know what font_format_id values can be used to open this particular font format. For example, if a font file extension is .ttf, you can use either 1 or 3 as font_format_id. You will use 1 if you want to open the font using Apple Mac ASCII Encoding and 3 if you want to open the font using Windows Unicode Encoding. In other words the choice 1 or 3 is your decision. Obviously 3 will be the most flexible font_format_id for TrueType and OpenType fonts with a .ttf extension.
Q-6-11. Based on Q-6-11 all we really need to do is determine the font-type and specify if we want Unicode or ASCII naming.
Yes, Unicode or ASCII character encoding. ASCII is rather limited (up to 255 characters) so in modern applications it really only makes sense to use Unicode. So your list of font_format_id choices can be cut down in half.
Q-6-12. The text editor we will be building will require the ability for the end-user to change the font. This means that we will have to scan the fonts folder(s) on the computer to find all available fonts. Before we include the font in our fonts list we will obviously have to validate it which means adding it to D-Type and checking for any errors. What is the impact of adding several hundred fonts into D-Type? Could this cause a performance/memory issue if we do this every time the application starts up? If so, we will probably have to build some sort of cache so that only new/updated fonts get re-validated. Also, should we only add fonts that the user selects into D-Type rather than all of the fonts used on the computer?
Yes, if you are scanning hundreds of fonts, the process might take a few seconds. Also, a full font validation is not feasible in this case. Font activation (to level 1 or level 2) is OK and will also do the basic validation. Rest assured that D-Type Font Engine will do this as fast as possible (we have designed our font drivers specifically with this in mind; i.e. only the file header and the critical tables/structures inside the file will be accessed).
Anyway, maintaining some sort of cache so that only new/updated fonts get re-validated is a good idea. The other alternative, only adding fonts that the user selects into D-Type (rather than all of the fonts used on the computer), is also a good option. Allowing the user to manually add fonts is always going to be more flexible than relying on the computer code to auto-scan various font folder.
Finally, you can also provide both options: 1) auto-scan the font folders by default and 2) allow the user to add any additional fonts manually.
Q-6-13. If a font has a Unicode filename what is the best way to load it? Does dtFontAddViaStream accept UTF-8 filenames or should I do it another way?
dtFontAddViaStream (with a file based stream descriptor) uses the standard C/C++ fopen() function to open a file. So this function can open any file that fopen() can.
It's also possible to open fonts using a memory based stream descriptor (i.e. you load the font to memory and then pass the pointer to this memory to D-Type).
Q-6-14. If we use dtFontSaveToStream to subset a font can we still apply styling such as drop shadows, outlining etc.
Of course.
Q-6-15: Does D-Type Font Engine impose any limit on the number of fonts that can be loaded into a single D-Type Engine instance?
No. The only restriction D-Type Font Engine imposes on the number of fonts is the size of the Font Catalog. The theoretical capacity of the Font Catalog is 32,000 fonts. There are no other restrictions within D-Type Font Engine itself on the number of open files/fonts your application can load into a single D-Type Engine instance.
However, your operating system most likely imposes a limit on the maximum number of file handles your application (and thus D-Type Font Engine that is part of it) can have. Try increasing it. For example, on Windows the _setmaxstdio() function is typically used to increase this limit. On Unix (including macOS) the getrlimit() and setrlimit() functions can be used to manage these limits. See http://www.gnu.org/s/libc/manual/html_node/Opening-and-Closing-Files.html for details.