I did some small, but important, changes in file tkUnixRFont.c, because the check for overflow in x/y coordinates is not working properly in original implementation, it will be done too late (functions Tk_DrawChars and TkDrawAngledChars), this is causing that an uninitialized glyph will be displayed, the result is garbage. Furthermore the original implementation did not check underflow of the coordinates. It seems that nobody has tested these edge conditions. The changes in revised implementation are tested.

The following script demonstrates the problem (tested with X11):

Furthermore I've added this comment in function TkDrawAngledChars:

/*

* Breaking at this place is sub-optimal, but the whole algorithm

* has a design problem, the choice of NUM_SPEC is arbitrary, and so

* the inter-glyph spacing will look arbitrary. This algorithm

* has to draw the whole string at once (or whole blocks with same

* font), this requires a dynamic 'glyphs' array. In case of overflow

* the array has to be divided until the maximal string will fit. (GC)

*/

* Breaking at this place is sub-optimal, but the whole algorithm

* has a design problem, the choice of NUM_SPEC is arbitrary, and so

* the inter-glyph spacing will look arbitrary. This algorithm

* has to draw the whole string at once (or whole blocks with same

* font), this requires a dynamic 'glyphs' array. In case of overflow

* the array has to be divided until the maximal string will fit. (GC)

*/

The whole algorithm of this function seems not to be well tested. I did not change the current algorithm, but I think that someone has to re-implement this function more conscientiously.