TheDraw Fonts (TDF)
TheDraw fonts or tdf for short, are packages of graphical fonts created for use with TheDraw, an ANSI art program for MSDOS.
Synchronet can natively use these font packages in menus and other files without the need for an external program.
The .tdf files may contain a single and multiple fonts. They can be accessed by index number. If a font with a given index doesn't exist then the first font found will be used. Upto 34 fonts can exist in a single .tdf file but, in reality, that's not usually the case.
Examples
Please keep in mind the interface may to the library may change since this is a new feature.
'use strict'; // Load the tdf library var tdf = load({}, "tdfonts_lib.js"); // Set various options (explained below) opt = { justify: tdf.LEFT_JUSTIFY, width: tdf.DEFAULT_WIDTH, color: tdf.COLOR_ANSI, // Default to ANSI encoding: tdf.ENC_ANSI, // Default to ANSI random: false, info: false, index: 3 }; // Choose the font file // These are installed in ctrl/tdfonts fontfile = "voidx.tdf"; // Load in the font from the fontfile var font = tdf.loadfont(fontfile); // You can read the output into a variable to // be manipulated later. You can pass a static // string or a variable, of course. var fontstr = tdf.output("TEST", font); writeln(fontstr); // Or you can just write out your text // directly. // tdf.output(mystr, font);
Options
You can pass several options to tdfonts using the opt object.
justify | Determine the position of the text on the screen. You can use LEFT_JUTIFY RIGHT_JUSTIFY or CENTER_JUSTIFY | LEFT_JUSTIFY |
width | Define the screen width | 80 |
color | Determines if output should be ANSI color characters or mIRC escape codes. Options are COLOR_ANSI or COLOR_MIRC | COLOR_ANSI |
encoding | Whether output encoding should be ANSI or Unicode. Options are ENC_ANSI or ENC_UNICDE | ENC_ANSI |
info | Print information about the font such as its name and available characters | none |
random | Use a random font. A fontname need to be specified when using random. | none |
index | 0 based index of the font within the font file. | 0 |