Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU (der Mouse) Newsgroups: comp.windows.x Subject: Re: naive query Message-ID: <9103040614.AA08270@lightning.McRCIM.McGill.EDU> Date: 4 Mar 91 06:14:56 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 42 > (Since I'm much too sleepy to find and wade through the source...) > Does anyone know exactly the algorithm which the XDrawString > functions use to draw one character after another? Specifically, how > the horiz. position of each subsequent character is determined. Do you want to know how they *actually* do it or how they're *supposed* to do it? :-) In the Xlib document, in the discussion of the font structures, such as XCharStruct, I find For a character origin at [x,y], the bounding box of a character (that is, the smallest rectangle that encloses the character's shape) described in terms of XCharStruct components is [...]. The origin for the next character is defined to be: [x + width, y] In other words, you simply step along the X axis by adding the width field of each character's XCharStruct after drawing that character's glyph. As for how they *actually* do it.... XTextWidth and XTextExtents really do do things this way, at least in the MIT source. A quick scan of the mfb code gives me the impression that it does as well, though to be sure would require a much more careful scan. (And note that not all servers use mfb, of course.) > I've written a small chunk of code which draws text in either a > line-by-line or character-by-character fashion...the problem is that > character-by-character just doesn't get the kerning right, and the > text drawn this way is always slightly off from when the text would > be drawn in one shot as a line. If the above doesn't help, I'd have to see the code. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu