next up previous contents index
Next: Antialiasing Up: Using t1lib Previous: t1lib and PostScript: Notes   Contents   Index


Stroking of Character Outlines

Most available Type 1 fonts internally specify the numeric value PaintType as . This indicates that the mathematical outline definitions of the characters consist of paths that represent the left and right--or inner and outer--borders of the character area to be filled with ink. In particular, this means that every subpath of a character definition must be closed. When filling characters, the curves that describe the outline are infinitely thin and the area between paths is of interest.

By contrast, there are fonts that specify PaintType as . These are also known as stroked fonts. Basically, their characters' shapes are generated by travelling along the mathematically thin defining curves using a pen with some finite width. The penwidth used here usually is specified in the font itself by means of the quantity StrokeWidth.

Using a somewhat unusual implementation, t1lib can

In particular at low resolutions and when using large penwidths, the results of stroking may fall short of the quality of other general graphics tools like e.g. native PostScript interpreters. Also hinting generally is disabled when creating stroked character outlines. For the interested reader, the implementation of stroking is outlined in [*] (page [*]).

The process of stroking in t1lib is treated similar to the process of transformation. Therefore, firstly, a font can be generally switched to be a stroked font. This is achieved using

 int T1_StrokeFont( int FontID, int dostroke)

to 0pt Here, FontID identifies the font to be switched. The parameter dostroke determines the future rastering behavior. If it equals 0, the font's characters will be filled and for any other value the characters will be stroked. The function returns 0 in case of success. T1_StrokeFont() requires the font FontID to be loaded. If the font is not loaded T1_errno will be set appropriately and the function returns -1. After switching a font to stroked, its characters are cached as usual. It is therefore important that, at the time where T1_StrokeFont() is called, no size-dependent data does exist. If this condition is violated, the function will fail too and set T1_errno to T1ERR_OP_NOT_PERMITTED.

The second method to control the rasterizer mode for the font FontID is to use the function pair

 int T1_SetStrokeFlag( int FontID)

to 0pt and

 int T1_ClearStrokeFlag( int FontID)

to 0pt for enabling and disabling stroking, respectively. These two functions return 0 on successful completion and -1 in case of a failure. They can only fail if FontID is not valid, in which case T1_errno is set to T1ERR_INVALID_FONTID. Using these functions, switching the stroking is hence possible at any time. The netto effect is that caching will be disabled if the actually selected rasterizer mode does not match the one of the cached characters. The performance then will degrade for the rasterizer mode that is not the base mode of the font in question.

If stroked characters and filled characters are required for one particular font while preserving good performance, using logical fonts is the tool of choice (see Sec. [*], page [*]).

The currently active rasterizer mode for the font FontID can also be queried. This is done using

 int T1_GetStrokeMode( int FontID)

to 0pt If FontID is not valid, is returned and T1_errno is set to T1ERR_INVALID_FONTID. In any other case, the following values may be returned:

The width of the virtual pen used to trace the character outlines can also be adjusted. The function

 int T1_SetStrokeWidth( int FontID, float strokewidth)

to 0pt sets up strokewidth as the pen width used to stroke characters from font FontID. It is interpreted in charspace units and hence directly comparable to the StrokeWidth parameter of stroked fonts. If this function succeeds, is returned. The function call might also be unsuccessful, in which case is returned. The value of T1_errno then gives a hint to the reason of the failure. If set to T1ERR_INVALID_FONTID, the font was not loaded. The value T1ERR_INVALID_PARAMETER indicates that a negative strokewidths has been specified. Finally, T1ERR_OP_NOT_PERMITTED may appear if stroked characters are cached for the font in question, size dependent data exists, and the requested strokewidth did not equal the one used at the time where the cache data initially has been built. Allowing to setup an arbitrary strokewidth under the latter circumstances might fillup the cache for one font with characters rasterized using inconsistent strokewidths, which has to be avoided. From this discussion it becomes suggesting not to cache stroked character at all, if stroking should be done using variable strokewidths.

The pen width for a given font FontID may be queried at any time using

 float T1_GetStrokeWidth( int FontID)

to 0pt If the value is returned, this either indicates that the characters are filled or that the font in question is not loaded. Then, T1_errno is also set to T1ERR_INVALID_FONTID.


next up previous contents index
Next: Antialiasing Up: Using t1lib Previous: t1lib and PostScript: Notes   Contents   Index
2005-01-12