Ttfautohint Werner Lemberg Version 1.8.3 Introductionttfautohint is a library written in C that takes a TrueType font as the input, removes its bytecode instructions (if any), and returns a new font where all glyphs are bytecode hinted using the information given by FreeType’s auto-hinting module. The idea is to provide the excellent quality of the auto-hinter on platforms that don’t use FreeType.The library has a central API function, TTFautohint, which is described.Bundled with the library there are two front-end programs, being a command line program and an application with a Graphics User Interface (GUI), respectively. What exactly are hints?To cite:Font hinting (also known as instructing) is the use of mathematical instructions to adjust the display of an outline font so that it lines up with a rasterized grid. At low screen resolutions, hinting is critical for producing a clear, legible text. It can be accompanied by antialiasing and (on liquid crystal displays) subpixel rendering for further clarity.and Apple’s:For optimal results, a font instructor should follow these guidelines:.At small sizes, chance effects should not be allowed to magnify small differences in the original outline design of a glyph.At large sizes, the subtlety of the original design should emerge.In general, there are three possible ways to hint a glyph.The font contains hints (in the original sense of this word) to guide the rasterizer, telling it which shapes of the glyphs need special consideration. The hinting logic is partly in the font and partly in the rasterizer.
More sophisticated rasterizers are able to produce better rendering results.This is how PostScript Type 1 and CFF hints work.The font contains exact instructions (also called bytecode) on how to move the points of its outlines, depending on the resolution of the output device, and which intentionally distort the (outline) shape to produce a well-rasterized result. The hinting logic is in the font; ideally, all rasterizers simply process these instructions to get the same result on all platforms.This is how TrueType hints work.The font gets auto-hinted (at run-time). The hinting logic is completely in the rasterizer. No hints in the font are used or needed; instead, the rasterizer scans and analyzes the glyphs to apply corrections by itself.This is how FreeType’s auto-hinter works; see for more.What problems can arise with TrueType hinting?While it is relatively easy to specify PostScript hints (either manually or by an auto-hinter that works at font creation time), creating TrueType hints is far more difficult. There are at least two reasons:.TrueType instructions form a programming language, operating at a very low level. They are comparable to assembler code, thus lacking all high-level concepts to make programming more comfortable.Here an example how such code looks like: SVTCA0PUSHB /.
Regular Script 3; Rounded 32; Gothic (sans-serif. Is a soft, feministic font free for download. This font was designed based on the story of the “Snow White and the 7 Dwarfs”: the hiragana Mincho (serif) Rounded. Togalite Togalite (トガリテ) is a display style free Japanese font which comes with 6 font weight. The font was.
3 values pushed./18 1 0CALL PUSHB /. 2 values pushed./15 4MIRP01001PUSHB /. 3 values pushed./7 3 0CALL Another major obstacle is the fact that font designers usually aren’t programmers.It is very time consuming to manually hint glyphs.
Given that the number of specialists for TrueType hinting is very limited, hinting a large set of glyphs for a font or font family can become very expensive.Why ttfautohint?The ttfautohint library brings the excellent quality of FreeType rendering to platforms that don’t use FreeType, yet require hinting for text to look good – like Microsoft Windows. Roughly speaking, it converts the glyph analysis done by FreeType’s auto-hinting module to TrueType bytecode. Internally, the auto-hinter’s algorithm resembles PostScript hinting methods; it thus combines all three hinting methods discussed.The simple interface of the front-ends (both on the command line and with the GUI) allows quick hinting of a whole font with a few mouse clicks or a single command on the prompt. As a result, you get better rendering results with web browsers, for example.Across Windows rendering environments today, fonts processed with ttfautohint look best with ClearType enabled. This is the default for Windows 7 and higher.
Good visual results are also seen in recent MacOS X versions and GNU/Linux systems (including Android, ChromeOS, and other mobile operating systems) that use FreeType for rendering glyphs. ‘Smooth’ hintingFundamentally, there are two approaches to hinting. The older approach, let’s call it ‘sharp’, popular when text was rendered in pure black-and-white, was to make all stems round to full pixels so that in a text line, all stems would be either one pixel or (at a larger point size) two pixels. When grayscale antialiasing came about, this approach actually started harming the rendering rather than helping it, because the horizontal and vertical stems would render very dark but round or diagonal stems would render very light.So a new approach was developed, let’s call it ‘fuzzy’, where all stems and other elements are equalized so that in grayscale (or ClearType) rendering, they all are of roughly equal color.
This means that stems are not rounded to full pixels but in fact to fractions of a pixel. However, with black-and-white renderers, this approach yields poor results because in black-and-white you cannot render a fraction of a pixel, so some stems become one pixel and some become two.The TrueType auto-hinters in and, to name two well-known font editors, take the ‘sharp’ approach, while the TrueType auto-hinter in ttfautohint takes the ‘fuzzy’ approach.In theory, a hybrid approach is possible, using TrueType conditional hints: If the rasterizer is black-and-white, ‘sharp’ rendering could happen, while if the rasterizer is ClearType, the ‘fuzzy’ rendering could be used. It is not intended to add black-and-white auto-hinting to ttfautohint. However, it is planned to develop an interface so that ttfautohint can cooperate with font editors, providing this hybrid hinting.
Ttfautohint and ttfautohintGUIOn all supported platforms (GNU/Linux, Windows, and Mac OS X), the GUI looks quite similar; the used toolkit is, which in turn uses the platform’s native widgets. TtfautohintGUI on GNU/Linux running KDEBoth the GUI and console version share the same features, to be discussed in the next subsection.Warning: ttfautohint cannot always process a font a second time. If the font contains composite glyphs, and option is used, reprocessing with ttfautohint will fail. For this reason it is strongly recommended to not delete the original, unhinted font so that you can always rerun ttfautohint. Calling ttfautohint ttfautohint OPTION. IN-FILE OUT-FILEThe command-line binary, ttfautohint, works like a Unix filter, this is, it reads data from standard input if no input file name is given, and it sends its output to standard output if no output file name is specified.A typical call looks like the following.
Ttfautohint -v -t -m foo-control.txt foo.ttf foo-autohinted.ttfFor demonstration purposes, here the same using a pipe and redirection. Note that Windows’s default command line interpreter, cmd.exe, doesn’t support piping with binary files, unfortunately.
Cat foo.ttf ttfautohint -v -t -m foo-control.txt foo-autohinted.ttf Calling ttfautohintGUI ttfautohintGUI OPTION.ttfautohintGUI doesn’t send any output to a console; however, it accepts (almost) the same command line options as ttfautohint to provide customized default values of the GUI.The following command line options are not available in ttfautohintGUI:,. Note, however, that the corresponding functionality can be selected interactively.Two options, namely -ttfa-info and -debug, emit information at standard output and standard error, respectively; they are thus not available in ttfautohintGUI, too, and there is no corresponding GUI functionality either.
OptionsLong options can be given with one or two dashes, and with and without an equal sign between option and argument. This means that the following forms are acceptable: -foo= bar, -foo= bar, -foo bar, and -foo bar.Below, the section title refers to the command’s label in the GUI (if applicable), then comes the name of the corresponding long command line option and its short equivalent, followed by a description.Background and technical details on the meaning of the various options are given. Control Instructions File -control-file= file, -m fileSpecify the name of a control instructions file to manually tweak the hinting process. This feature can be used to correct glitches in ttfautohint’s hinting algorithm. The syntax used in a control instructions file is given.ttfautohintGUI doesn’t have this command line option. Blue Zone Reference Font -reference= file, -R fileDerive all blue zones from the given font, which can either be a normal TrueType font or a TrueType collection – for the latter you can select the face index with a.Use this to harmonize font families, avoiding ugly height differences at small sizes. Fira Regular and Bold (version 4.106), auto-hinted with ttfautohint and displayed at 16px using Internet Explorer 11 under Windows 8.1.
The bold series shown on the right side uses the regular variant as the reference font.To make this work the reference font must obviously be similar enough to the font to be hinted; in particular, it must have proper blue zone characters so that ttfautohint can derive blue zones at all.ttfautohintGUI doesn’t have this command line option. Hint Set Range Minimum, Hint Set Range MaximumSee ‘’ for a definition and explanation.hinting-range-min= n, -l n The minimum PPEM value (in pixels) at which hint sets are created.
The default value for n is 8.-hinting-range-max= n, -r n The maximum PPEM value (in pixels) at which hint sets are created. The default value for n is 50.Increasing the range given by -l and -r normally makes the font’s bytecode larger. Default Script -default-script= s, -D s Set default script to tag s, which is a string consisting of four lowercase characters like latn or dflt. It is needed to specify the OpenType default script: After applying all features that are handled specially (like small caps or superscript), ttfautohint uses this value for the remaining features. The default value is latn. See for more details.Fallback Script -fallback-script= s, -f s Set fallback script to tag s, which is a string consisting of four characters like latn or dflt. It gets used for all glyphs that can’t be assigned to a script automatically.
The default value is none. See for more details.-fallback-scaling, -S Use scaling for glyphs covered by the fallback script, not hinting. See for more details.Hinting Limit -hinting-limit= n, -G nThe hinting limit is the PPEM value (in pixels) where hinting gets switched off (using the INSTCTRL bytecode instruction, not the gasp table data); it does not influence the file size.
The default value for n is 200, which means that the font is not hinted for PPEM values larger than 200.Note that hinting in the range ‘hinting-range-max’ up to ‘hinting-limit’ uses the hinting configuration for ‘hinting-range-max’.To omit a hinting limit, use -hinting-limit=0 (or check the ‘No Hinting Limit’ box in the GUI). Since this causes internal math overflow in the rasterizer for large pixel values ( 1500px approx.) it is strongly recommended to not use this except for testing purposes.
X Height Increase Limit -increase-x-height= n, -x nNormally, ttfautohint rounds the x height to the pixel grid, with a slight preference for rounding up (to use the terminology of TrueType’s ‘Super Round’ bytecode instruction, the threshold is 5/8px). If this flag is set, values in the PPEM range 6 to n are much more often rounded up (setting the threshold to 13/16px). The default value for n is 14. Use this flag to increase the legibility of small sizes if necessary; you might get weird rendering results otherwise for glyphs like ‘a’ or ‘e’, depending on the font design.To switch off this feature, use -increase-x-height=0 (or check the ‘No x Height Increase’ box in the GUI). To switch off rounding the x height to the pixel grid in general, either partially or completely, see ‘’.The following FontForge snapshot images use the font ‘’ from Vernon Adams.
This image shows different versions of glyph ‘g’ of the font as displayed with the ‘ftgrid’ demo program of FreeType. Top left is unhinted, top right is hinted using ttfautohint natural stem width mode. Bottom left and right uses the quantized and strong stem width modes, respectively.strong-stem-width= string, -w stringThis option is deprecated and has been replaced with the more versatile option. The table below shows the corresponding arguments.w-a'qqqgsqqGqsqDqqsgGssqgDsqsGDqssgGDsssMiscellaneous Watch input files ( ttfautohintGUI only)If this checkbox is set, automatically regenerate the output file as soon as an input file (either the font, the control instructions file, or the reference font) gets modified.Pressing the ‘Run’ button starts watching. If an error occurs, watching stops and must be restarted with the ‘Run’ button.ignore-restrictions, -iBy default, fonts that have bit 1 set in the ‘fsType’ field of the OS/2 table are rejected. If you have a permission of the font’s legal owner to modify the font, specify this command line option.If this option is not set, ttfautohintGUI shows a dialogue to handle such fonts if necessary.help, -h On the console, print a brief documentation on standard output and exit.
This doesn’t work with ttfautohintGUI on MS Windows.-version, -v On the console, print version information on standard output and exit. This doesn’t work with ttfautohintGUI on MS Windows.-ttfa-info, -T (not in ttfautohintGUI) Print of the input font on standard output if present, then exit.-debug (not in ttfautohintGUI)Print a lot of debugging information on standard error while processing a font (you should redirect stderr to a file).To reduce the amount of debug data it is recommended to restrict the hinting process to a single PPEM value, e.g., ttfautohint -debug -l 15 -r 15. debug.txt 2&1 Background and Technical Detailsis a scholarly paper that describes FreeType’s auto-hinter in some detail. Regarding the described data structures it is slightly out of date, but the algorithm itself hasn’t changed in general.The next few subsections are mainly based on this article, introducing some important concepts. Note that ttfautohint only does hinting along the vertical direction (modifying y coordinates only). Segments and EdgesA glyph consists of one or more contours (this is, closed curves). For example, glyph ‘O’ consists of two contours, while glyph ‘I’ has only one.
This image shows the relevant glyph terms for vertical blue zone positions. Grid FittingAligning outlines along the grid lines is called grid fitting. It doesn’t necessarily mean that the outlines are positioned exactly on the grid, however, especially if you want a smooth appearance at different sizes. This is the central routine of the auto-hinter; its actions are highly dependent on the used writing system.
Currently, only one writing system is available (latin), providing support for scripts like Latin or Greek.Align edges linked to blue zones.Fit edges to the pixel grid.Align serif edges.Handle remaining ‘strong’ points. Such points are not part of an edge but are still important for defining the shape. This roughly corresponds to the IP TrueType instruction.Everything else (the ‘weak’ points) is handled with an ‘IUP’ instruction.The following images illustrate the hinting process, using glyph ‘a’ from the freely available font ‘’. The manual hints were added by, the used application to create the hinting debug snapshots was. After hinting, using ttfautohint. Note that the hinting process doesn’t change horizontal positions. Hint SetsIn ttfautohint terminology, a hint set is the optimal configuration for a given PPEM (pixel per EM) value.In the range given by the -hinting-range-min and -hinting-range-max options, ttfautohint creates hint sets for every PPEM value.
For each glyph, ttfautohint automatically determines whether a new set should be emitted for a PPEM value if it finds that it differs from a previous one. For some glyphs it is possible that one set covers, say, the range 8px-1000px, while other glyphs need 10 or more such sets.In the PPEM range below -hinting-range-min, ttfautohint always uses just one set, in the PPEM range between -hinting-range-max and -hinting-limit, it also uses just one set.One of the hinting configuration parameters is the decision which segments form an edge. For example, let us assume that two segments get aligned on a single horizontal edge at 11px, while two edges are used at 12px. This change makes ttfautohint emit a new hint set to accomodate this situation. The next images illustrate this, using a Cyrillic letter (glyph ‘afii10108’) from the ‘Ubuntu book’ font, processed with ttfautohint. After hinting, size 12px.
The segments are not aligned. While segments 43-27-28 and 20-21 now have almost the same horizontal position, they don’t form an edge because the outlines passing through the segments point into different directions.Obviously, the more hint sets get emitted, the larger the bytecode ttfautohint adds to the output font. To find a good value n for -hinting-range-max, some experimentation is necessary since n depends on the glyph shapes in the input font. If the value is too low, the hint set created for the PPEM value n (this hint set gets used for all larger PPEM values) might distort the outlines too much in the PPEM range given by n and the value set by -hinting-limit (at which hinting gets switched off). If the value is too high, the font size increases due to more hint sets without any noticeable hinting effects.Similar arguments hold for -hinting-range-min except that there is no lower limit at which hinting is switched off.An example. Let’s assume that we have a hinting range 10. It shows that you have to do the following steps.Add blue zone character data to the file lib/tablue.dat.Add the proper Unicode ranges to lib/taranges.c, following the structure of similar entries.Similarly, the files lib/tastyles.h and lib/ttfautohint-script.h must be updated.
The latter holds the information on the used default character or characters; it also references the corresponding script tag HBSCRIPTXXX as used by the HarfBuzz library.If there are any questions, please contact the for help. Note that the script data in ttfautohint are hold in sync with FreeType’s auto-hinter.
Control InstructionsAn entry in a control instructions file has various syntax forms, which are discussed here. Brackets indicate optional elements. Common Syntax Elementsfont‑idx gives the index of the font in a TrueType Collection, starting with value 0. If missing, it is set to zero. For normal TrueType fonts, only value zero is valid. A font index can be specified in decimal, octal, or hexadecimal format, the latter two indicated by the prefixes 0 and 0x, respectively.glyph‑id is either a glyph’s name as listed in the font’s post SFNT table or a glyph index. A glyph name consists of characters from the set ‘ A-Za-z0-9.’ only and does not start with a digit or period, with the exceptions of the names ‘.notdef’ and ‘.null’.
A glyph index starts with value 0 can be specified in decimal, octal, or hexadecimal format, the latter two indicated by the prefixes 0 and 0x, respectively. Glyph names are internally converted to glyph indices.points are number ranges, see ‘’ for the syntax.Similar to the Bourne shell ( sh or bash), a comment starts with character ‘ #’; the rest of the line is ignored.
An empty line is ignored also. Both the newline character and ‘;’ can be used as a separator between exception entries. A trailing ‘ ’ at the end of a line continues the current line on the next one.A control instructions file is parsed line by line; later entries override earlier entries (in case there is something to override). Style AdjustmentsThis syntax form makes it possible to override the style assignment algorithm of ttfautohint; see ‘’ and ‘’ for more details. font-idx script feature @ glyph-idsscript is a four-letter name of one of the scripts supported by ttfautohint.
Feature is one of the four-letter names of features supported by ttfautohint.The elements of glyph-ids are a list of comma separated glyph-id values or value ranges. Note that is not necessary that elements are specified in increasing order.Assuming that a font contains superscript digits ‘zero.sups’ to ‘nine.sups’ together with the glyphs ‘a.sups’ and ‘o.sups’, use a line cyrl sups @ zero.sups-nine.sups, a.sups, o.supsto add those glyphs to the style handling Cyrillic superscript glyphs.
However, it is still necessary that the selected script contains proper, otherwise those glyphs aren’t handled at all.Use the -debug command line option to see how ttfautohint assigns glyph indices of a font to styles. Stem Width AdjustmentsUse the following syntax form to adjust stem width values for a given style, overriding ttfautohint’s algorithm; see ‘’ and ‘’ for more details. This adjustment doesn’t change the glyph shapes; it only influences the hinting process. font-idx script feature width stem-widthsscript and feature are the same as with style adjustments; see above. However, script can additionally be the wildcard character ‘.’, which indicates ‘any script’. Parameter width can be abbreviated as ‘ w’.stem-widths is an unsorted list of comma separated integer stem width values (in font units); the first value gives the style’s default stem width.The effect of this adjustment depends. For smooth stem width positioning, only the first (i.e., the default) value is used; it gets a higher preference than other discrete stem width choices. For strong stem width positioning, the stem widths are snapped to the provided values (if not differing too much) before rounding to an integer pixel value.
For natural stem width positioning, this adjustment is ignored.A typical example is to reduce the default stem width of an extra-bold font, which gets better hinted if a stem width of, say, 100 is used instead of the default value 150. Let’s also assume that the font further contains latin subscript and superscript characters that are hinted best with a stem width set to 80 font units.
We can achieve this with the following lines in a control instructions file. dflt width 100latb dflt width 80latp dflt width 80Without the adjustment chances are very high that the ‘eyes’ in glyphs ‘e’ or ‘a’ of extra-bold fonts are filled at smaller PPEM values.Use the -debug command line option to see how ttfautohint assigns stem widths to styles by default. Glyph AdjustmentsThe following syntax forms allows adjustments of a glyph’s hinting process. Change Direction of Points, Artificial Segments font‑idx glyph‑id l eft r ight points ( left‑offset, right‑offset ) The mutually exclusive parameters left and right (which can be abbreviated as ‘ l’ and ‘ r’, respectively) indicate that the following points have left or right ‘out’ direction, respectively, overriding ttfautohint’s algorithm for setting point directions. The ‘out direction’ of a point is the direction of the outline leaving the point (or passing the control point). If the specified direction is identical to what ttfautohint computes, nothing special happens. Otherwise, a one-point segment with the specified direction gets created, see.
By default, its length is zero. Setting left‑offset and right‑offset, you can change the segment’s horizontal start and end position relative to the point position. Left‑offset and right‑offset are integers measured in font units.The following five images, displaying glyphs ‘O’ and ‘Q’ from the font, demonstrate how to use direction changes.
Using only ttfautohint’s ‘ -a sss’ parameter to force strong stem width and positioning, the hinting of glyph ‘Q’ is really bad, making the glyph vertically two pixels larger! Reason is that this glyph doesn’t contain a horizontal segment at the baseline blue zone ( y = 1; this corresponds to the segment 13-14 in the ‘O’ glyph). Normally, segment 1-2 would form a ‘stem’ with the baseline segment (as segment 7-8 does in glyph ‘O’).
Instead, it forms a stem with segment 19-20, which gets moved down ( y = −1) because the whole glyph appears to be stretched. To fix the problem, we change the direction of point 38 to ‘left’ by writing a line ‘ Q left 38’ (without the quotes) to a control description file Halant-Regular.txt. Adding option ‘ -m Halant-Regular.txt’ to ttfautohint, we get the shown image as a result, which is much better: Segment 1-2 now properly forms a stem with our artificial one-point segment 38, and the ‘O’-like shape is properly positioned. However, there is still room for improvement: Segment 19-20 is also positioned at the baseline, making the connection between the ‘O’ shape and the tail too thin. By giving the one-point segment 38 a horizontal width, we can prevent that segment 19-20 gets positioned at the baseline: Replace the line in the previous image description with ‘ Q left 38 (−70,20)’, making the segment extend 70 font units to the left and 20 to the right of point 38.
The exact offset values don’t matter; it’s only important to start left of point 19. Another solution to the problem is to artificially change the direction of segment 19-20 by adding a second line ‘ Q right 19-20’ to the control instructions file; for our ‘Q’ glyph, this produces almost exactly the same hinting results. Note that such direction changes only influence the hinting process; an outline’s direction won’t be changed at all. Unset Direction of Points font‑idx glyph‑id n odir pointsParameter nodir (or ‘ n’) sets the ‘out’ direction of the following points to ‘no direction’, this is, neither left nor right. If the specified direction is identical to what ttfautohint computes, nothing special happens.
Otherwise, ttfautohint no longer considers those points as part of horizontal segments, thus treating them as points.Modifying or adding segments doesn’t directly modify the outlines; it only influences the hinting process. Delta Exceptions font‑idx glyph‑id t ouch p oint points x shift x‑shift y shift y‑shift @ ppemsThe mutually exclusive parameters touch and point (which can be abbreviated as ‘ t’ and ‘ p’, respectively) make ttfautohint apply delta exceptions for the given points, shifting them by the given values. Delta exceptions entered with touch are applied before the final ‘IUP’ ( interpolate untouched points) instructions in a glyph’s bytecode, exceptions entered with point after ‘IUP’ (please consult Greg Hitchcock’s for more on pre-IUP and post-IUP delta hints). Additionally, the touch parameter makes the bytecode touch the affected points; such points are no longer affected by ‘IUP’ at all. Note that in ClearType mode all deltas along the x axis are discarded, and deltas along the y axis are only executed for touched points. As a consequence, vertical delta exceptions entered with point should not be used in ClearType mode.ppems, similar to points, are number ranges, see ‘’ for the syntax.x‑shift and y‑shift represent real numbers that get rounded to multiples of 1/8 pixels.
The entries for xshift (‘ x’) and yshift (‘ y’) are optional; if missing, the corresponding value is set to zero. If both values are zero, the delta exception entry is ignored as a whole.Values for x‑shift and y‑shift must be in the range −1.0;1.0. Values for ppems must be in the range 6;53. Values for points are limited by the number of points in the glyph.Note that only character ‘.’ is recognized as a decimal point, and a thousands separator is not accepted.As an example for delta instructions, let’s assume that you want to shift points 2, 3, and 4 in glyph ‘Aacute’ at PPEM sizes 12 and 13 by a vertical amount of 0.25 pixels. This corresponds to the line Aacute touch 2-4 yshift 0.25 @ 12, 13in a control instructions file.
Since we use touch and not point, points 2, 3, and 4 are no longer subject to the final ‘IUP’ instruction, which interpolates weak, untouched point positions between strong, touched ones, cf. The description.
The ttfautohint APIThis section documents the public functions of the ttfautohint library together with its callback functions. All information has been directly extracted from the ttfautohint.h header file. Preprocessor Macros, Typedefs, and EnumsSome default values. Typedef void(.TAFreeFunc)( void.ptr); Callback: TAProgressFuncA callback function to get progress information. Curridx gives the currently processed glyph index; if it is negative, an error has occurred. Numglyphs holds the total number of glyphs in the font (this value can’t be larger than 65535).currsfnt gives the current subfont within a TrueType Collection (TTC), and numsfnts the total number of subfonts.If the return value is non-zero, TTFautohint aborts with TAErrCanceled.
Use this for a ‘Cancel’ button or similar features in interactive use.progressdata is a void pointer to user-supplied data. Typedef int(.TAProgressFunc)( long curridx,long numglyphs,long currsfnt,long numsfnts,void. progressdata); Callback: TAErrorFuncA callback function to get error information.error is the value TTFautohint returns. See file ttfautohint-errors.h for a list. Error codes not in this list are directly taken from FreeType; see the FreeType header file fterrdef.h for more.errorstring, if non-NULL, is a pointer to an error message that represents error.The next three parameters help identify the origin of text string parsing errors. Linenum, if non-zero, contains the line number. Line, if non-NULL, is a pointer to the input line that can’t be processed.
Errpos, if non-NULL, holds a pointer to the position in line where the problem occurs.errordata is a void pointer to user-supplied data. Typedef void(.TAErrorFunc)(TAError error,const char. errorstring,unsigned int linenum,const char. line,const char. errpos,void. errordata); Callback: TAInfoFuncA callback function to access or modify strings in the name table; it is called in a loop that iterates over all name table entries. If defined, gets executed after this loop so that the collected data can be written back to the name table.platformid, encodingid, languageid, and nameid are the identifiers of a name table entry pointed to by str with a length pointed to by strlen (in bytes; the string has no trailing NULL byte).
Please refer to the for a detailed description of the various parameters, in particular which encoding is used for a given platform and encoding ID.The string str is allocated with the function specified by the alloc-func field of; the application should reallocate the data if necessary, ensuring that the string length doesn’t exceed 0xFFFF.infodata is a void pointer to user-supplied data.If an error occurs, return a non-zero value and don’t modify str and strlen (such errors are handled as non-fatal). Typedef int(.TAInfoFunc)( unsigned short platformid,unsigned short encodingid,unsigned short languageid,unsigned short nameid,unsigned short. strlen,unsigned char. str,void. infodata); Callback: TAInfoPostFuncA callback function, giving the application the possibility to access or modify strings in the name table after has iterated over all name table entries.It is expected that TAInfoFunc stores pointers to the name table entries it wants to access or modify; the only parameter is thus infodata, which is a void pointer to the user-supplied data already provided to TAInfoFunc. Obviously, calling TAInfoPostFunc with TAInfoFunc undefined has no effect.The name table strings are allocated with the function specified by the alloc-func field of; the application should reallocate the data if necessary, ensuring that no string length exceeds 0xFFFF.If an error occurs, return a non-zero value and don’t modify the affected string and string length (such errors are handled as non-fatal). Typedef int(.TAInfoPostFunc)( void.
infodata); Function: TTFautohintRead a TrueType font, remove existing bytecode (in the SFNT tables prep, fpgm, cvt, and glyf), and write a new TrueType font with new bytecode based on the autohinting of the FreeType library, optionally using a reference font to derive blue zones.It expects a format string options and a variable number of arguments, depending on the fields in options. The fields are comma separated; whitespace within the format string is not significant, a trailing comma is ignored. Fields are parsed from left to right; if a field occurs multiple times, the last field’s argument wins. The same is true for fields that are mutually exclusive.
Depending on the field, zero or one argument is expected.Note that fields marked as ‘not implemented yet’ are subject to change. Memory ManagementThe next two fields are necessary on some platforms if ttfautohint is compiled as a shared library, and the application uses a different runtime library. This can happen, for example, on the MS Windows platform if your program is written in Python and communicates via with the ttfautohint DLL. Alloc-func A pointer of type specifying a memory allocation function. It gets used to allocate the buffer given by the out-buffer field and the data exposed by the callback.
If not set or set to NULL, or if out-buffer is not set or set to NULL, standard C’s malloc function is used.free-func A pointer of type specifying a memory deallocation function. It gets called to free the data exposed by the callback after it has been used. If not set or set to NULL, or if outbuffer is not set or set to NULL, standard C’s free function is used.I/O in-file A pointer of type FILE. to the data stream of the input font, opened for binary reading.
Mutually exclusive with in-buffer.in-buffer A pointer of type const char. to a buffer that contains the input font.
Needs in-buffer-len. Mutually exclusive with in-file.in-buffer-len A value of type sizet, giving the length of the input buffer.
Needs in-buffer.out-file A pointer of type FILE. to the data stream of the output font, opened for binary writing. Mutually exclusive with out-buffer.out-buffer A pointer of type char. to a buffer that contains the output font. Needs out-buffer-len. Mutually exclusive with out-file. The application should deallocate the memory with the function given by free-func.out-buffer-len A pointer of type sizet.
to a value giving the length of the output buffer. Needs out-buffer.control-fileA pointer of type FILE. to the data stream of control instructions. Mutually exclusive with control-buffer.See ‘’ for the syntax used in such a file or buffer.
Control-buffer A pointer of type const char. to a buffer that contains control instructions. Needs control-buffer-len.
Mutually exclusive with control-file.control-buffer-len A value of type sizet, giving the length of the control instructions buffer. Needs control-buffer.reference-file A pointer of type FILE. to the data stream of the reference font, opened for binary reading. Mutually exclusive with reference-buffer.reference-buffer A pointer of type const char. to a buffer that contains the reference font. Needs reference-buffer-len.
Mutually exclusive with reference-file.reference-buffer-len A value of type sizet, giving the length of the reference buffer. Needs reference-buffer.reference-index The face index to be used in the reference font. The default value is 0.reference-name A string that specifies the name of the reference font. It is only used to emit a sensible value for the TTFA table if TTFA-info is set.Messages and Callbacks progress-callback A pointer of type, specifying a callback function for progress reports. This function gets called after a single glyph has been processed. If this field is not set or set to NULL, no progress callback function is used.progress-callback-data A pointer of type void.
to user data that is passed to the progress callback function.error-string A pointer of type unsigned char. to a string (in UTF-8 encoding) that verbally describes the error code. You must not change the returned value.error-callbackA pointer of type, specifying a callback function for error messages. This function gets called right before TTFautohint exits. If this field is not set or set to NULL, no error callback function is used.Use it as a more sophisticated alternative to error-string. Error-callback-data A point of type void.
to user data that is passed to the error callback function.info-callback A pointer of type, specifying a callback function for manipulating the name table. This function gets called for each name table entry. If not set or set to NULL, TAInfoFunc is not called.info-post-callback A pointer of type, specifying a callback function for manipulating the name table. It is called after the function specified with info-callback has iterated over all name table entries. If not set or set to NULL, TAInfoPostFunc is not called.info-callback-data A pointer of type void.
to user data that is passed to the info callback functions.debug If this integer is set to 1, lots of debugging information is print to stderr. The default value is 0.General Hinting Options hinting-range-min An integer (which must be larger than or equal to 2) giving the lowest PPEM value used for autohinting. If this field is not set, it defaults to.hinting-range-max An integer (which must be larger than or equal to the value of hinting-range-min) giving the highest PPEM value used for autohinting. If this field is not set, it defaults to.hinting-limit An integer (which must be larger than or equal to the value of hinting-range-max) that gives the largest PPEM value at which hinting is applied.
For larger values, hinting is switched off. If this field is not set, it defaults to. If it is set to 0, no hinting limit is added to the bytecode.hint-composites If this integer is set to 1, composite glyphs get separate hints.
This implies adding a special glyph to the font called. Setting it to 0 (which is the default), the hints of the composite glyphs’ components are used. Adding hints for composite glyphs increases the size of the resulting bytecode a lot, but it might deliver better hinting results.
However, this depends on the processed font and must be checked by inspection.adjust-subglyphsAn integer (1 for ‘on’ and 0 for ‘off’, which is the default) to specify whether native TrueType hinting of the input font shall be applied to all glyphs before passing them to the (internal) autohinter. The used resolution is the em-size in font units; for most fonts this is 2048ppem. Use this only if the old hints move or scale subglyphs independently of the output resolution, for example some exotic CJK fonts.pre-hinting is a deprecated alias name for this option. Hinting Algorithmsttfautohint provides three different algorithms for computing horizontal stem widths and the positioning of blue zones.TASTEMWIDTHMODENATURAL: No adjustments to stem widths, discrete blue zone positioning. This is what FreeType uses for its ‘light’ (auto-)hinting mode.TASTEMWIDTHMODEQUANTIZED: Both stem widths and blue zone positions are slightly quantized to take discrete values. For example, stem values 50, 51, 72, 76, and 100 would become 50, 74, and 100 (or something similar).TASTEMWIDTHMODESTRONG: If active, stem widths and blue zones are snapped and positioned to integer pixel values as much as possible.These values are arguments to ttfautohint’s three different hinting mode options.
Gray-stem-width-mode Specify the stem width algorithm for grayscale rendering. Possible integer values are TASTEMWIDTHMODENATURAL, TASTEMWIDTHMODEQUANTIZED (the default), and TASTEMWIDTHMODESTRONG, as discussed above.gdi-cleartype-stem-width-mode Specify the stem width algorithm for GDI ClearType rendering, this is, the rasterizer version (as returned by the GETINFO bytecode instruction) is in the range 36 = 38, ClearType is enabled, and subpixel positioning is enabled also. Possible integer values are TASTEMWIDTHMODENATURAL, TASTEMWIDTHMODEQUANTIZED (the default), and TASTEMWIDTHMODESTRONG, as discussed above.increase-x-height An integer. For PPEM values in the range 6. #define TTFAUTOHINTMAJOR 1 #define TTFAUTOHINTMINOR 8 #define TTFAUTOHINTREVISION 3 Macro: TTFAUTOHINTVERSIONThis macro holds the ttfautohint version string.For tarball releases it has the form X. Z, with X, Y, and Z the major, minor, and revision numbers, respectively. If the revision number is zero, it is omitted.
Examples: 2.7, 2.7.1.If compiling directly from the git repository, ttfautohint’s bootstrap script derives the version number from the git describe output, appending the number of commits after a tag together with a shortened commit ID. Example: 2.7.1.23-379b.See function for more details.
#define TTFAUTOHINTVERSION '1.8.3' Function: TTFautohintversionReturn the ttfautohint version triplet. This function is useful when dynamically linking to the library, since the macros TTFAUTOHINTMAJOR, TTFAUTOHINTMINOR, and TTFAUTOHINTPATCH cannot be used in that case.The returned integer triplet is not the same as the shared library’s version triplet (which the dynamic linker uses to resolve runtime dependencies).
For example, hypothetical ttfautohint versions 2.27 and 2.27.1 might both correspond to shared library version 1.0.38 in case there are only, say, documentation or packaging differences that don’t affect the library code.If the pkg-config configuration file ttfautohint.pc is installed in a place that pkg-config can find, a call to pkg-config ttfautohint -modversionreturns the shared library version.To be more precise, the sum of the height and length of a segment must be at least 20 font units, and the height multiplied by 14 must not exceed the length. Thus (19,1) is also a valid minimum (length,height) pair, while (18,2) isn’t. The value 20 is heuristic and hard-coded, as is the value 14 (corresponding to a slope of approx.
4.1°).The notable exception is the tag ‘lao’, which originally has a trailing space as the fourth character. However, ttfautohint ignores the space.Unfortunately, there is a bug in FreeType prior to version 2.5.4 (released in December 2014) that completely disables vertical delta exceptions if subpixel hinting is activated. For this reason you should expect that the touch parameter fails on older GNU/Linux distributions.The number ‘6’ indicates the version of the shared library of FreeType, which is not directly related to the source code version of FreeType.