next up previous contents index
Next: Transparent Handling of Composite Up: Composite Characters Previous: General remarks   Contents   Index


Accessing Composite Character Data

This section describes a few functions that provide access to composite character data of a font file. The data they return can be considered a mapping of the original AFM data with respect to the current encoding. As usual, FontID must be the identifier of a font loaded into memory, otherwise an appropriate error indicator is returned. The functions described in the following may also return some other error types.

Firstly,

 int T1_GetNoCompositeChars( int FontID)

to 0pt tells the user how many composite character definitions are given in the AFM file. This, of course, does not depend on the current encoding vector and it is even possible that the current encoding vector does not incorporate any composite character at all.

The function

 int T1_QueryCompositeChar( int FontID, char char1)

to 0pt checks whether composite character information exists for the encoding index char1. If so, it returns the index within in the AFM composite character data array as a number equal to or greater than zero. If the result is valid but no composite character information has been found for char1, is returned. In case of an error, is returned and T1_errno is set to an appropriate value.

The previous function does not tell anything about whether the font FontID incorporates a character definition for the composite char or not. This can be queried using

 int T1_IsInternalChar( int FontID, char char1)

to 0pt It returns if there exists a CharString for char1 and if not. In the latter case, the application is responsible for the construction of the composite character (see later). T1_IsInternalChar() also might return and set T1_errno, which indicates that the font in question is not loaded.

The information required to construct a composite character is retrieved by calling the function

 T1_COMP_CHAR_INFO *T1_GetCompCharData( int FontID, char char1)

to 0pt It returns a pointer to a meaningfully filled struct of type T1_COMP_CHAR_INFO as described above. The composite character and the number of pieces as well as a pointer to the array of type T1_COMP_PIECE are stored in this structure. Once this information is obtained the composite character can be constructed by

In cases where char1 is not a composite character, the compchar entry is set to char1 itself and numPieces becomes , as would be expected. The pieces pointer is then set to NULL. In case of errors, this function returns NULL and T1_errno is setup correspondingly.

The pointer returned by this function should always be free'd using T1_FreeCompCharData() in order to avoid memory leaks (see also Section [*]).

A function that provides the same functionality is

 T1_COMP_CHAR_INFO *T1_GetCompCharDataByIndex( int FontID, int index)

to 0pt In this case, the information is requested by means of an index index in the AFM composite character data array. This function is thus well-suited for scanning the complete composite character information of a given font in a given encoding. index may, for example, be obtained by a call to T1_QueryCompCharData() as described above. The valid range for index is from to the value returned by T1_GetNoCompositeChars() minus one. The range of index is validated and in case of an error T1_errno is to T1ERR_INVALID_PARAMETER. There may also appear other errors and under any erroneous condition, NULL is returned.

The parameter compchar of the T1_COMP_CHAR_INFO structure that is referenced by the returned pointer, bears somewhat more information for this function than in the case of
T1_GetCompCharData(). As said it contains the index in the encoding vector where the composite glyph is encoded. It may also have the vaue , which means that the composite character is not encoded. Note that this is not an error condition.


next up previous contents index
Next: Transparent Handling of Composite Up: Composite Characters Previous: General remarks   Contents   Index
2005-01-12