]> cvs.zerfleddert.de Git - micropolis/blob - src/tk/tkfont.c
Fixes for compilation with gcc 15
[micropolis] / src / tk / tkfont.c
1 /*
2 * tkFont.c --
3 *
4 * This file maintains a database of looked-up fonts for the Tk
5 * toolkit, in order to avoid round-trips to the server to map
6 * font names to XFontStructs.
7 *
8 * Copyright 1990 Regents of the University of California
9 * Permission to use, copy, modify, and distribute this
10 * software and its documentation for any purpose and without
11 * fee is hereby granted, provided that the above copyright
12 * notice appear in all copies. The University of California
13 * makes no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without
15 * express or implied warranty.
16 */
17
18 #ifndef lint
19 static char rcsid[] = "$Header: /user6/ouster/wish/RCS/tkFont.c,v 1.21 92/06/15 14:00:19 ouster Exp $ SPRITE (Berkeley)";
20 #endif
21
22 #include "tkconfig.h"
23 #include "tkint.h"
24
25 /*
26 * This module caches extra information about fonts in addition to
27 * what X already provides. The extra information is used by the
28 * TkMeasureChars procedure, and consists of two parts: a type and
29 * a width. The type is one of the following:
30 *
31 * NORMAL: Standard character.
32 * TAB: Tab character: output enough space to
33 * get to next tab stop.
34 * NEWLINE: Newline character: don't output anything more
35 * on this line (character has infinite width).
36 * REPLACE: This character doesn't print: instead of
37 * displaying character, display a replacement
38 * sequence of the form "\xdd" where dd is the
39 * hex equivalent of the character.
40 * SKIP: Don't display anything for this character. This
41 * is only used where the font doesn't contain
42 * all the characters needed to generate
43 * replacement sequences.
44 * The width gives the total width of the displayed character or
45 * sequence: for replacement sequences, it gives the width of the
46 * sequence.
47 */
48
49 #define NORMAL 1
50 #define TAB 2
51 #define NEWLINE 3
52 #define REPLACE 4
53 #define SKIP 5
54
55 /*
56 * One of the following data structures exists for each font that is
57 * currently active. The structure is indexed with two hash tables,
58 * one based on font name and one based on XFontStruct address.
59 */
60
61 typedef struct {
62 XFontStruct *fontStructPtr; /* X information about font. */
63 Display *display; /* Display to which font belongs. */
64 int refCount; /* Number of active uses of this font. */
65 char *types; /* Malloc'ed array giving types of all
66 * chars in the font (may be NULL). */
67 unsigned char *widths; /* Malloc'ed array giving widths of all
68 * chars in the font (may be NULL). */
69 int tabWidth; /* Width of tabs in this font. */
70 Tcl_HashEntry *nameHashPtr; /* Entry in name-based hash table (needed
71 * when deleting this structure). */
72 } TkFont;
73
74 /*
75 * Hash table for name -> TkFont mapping, and key structure used to
76 * index into that table:
77 */
78
79 static Tcl_HashTable nameTable;
80 typedef struct {
81 Tk_Uid name; /* Name of font. */
82 Display *display; /* Display for which font is valid. */
83 } NameKey;
84
85 /*
86 * Hash table for font struct -> TkFont mapping. This table is
87 * indexed by the XFontStruct address.
88 */
89
90 static Tcl_HashTable fontTable;
91
92 static int initialized = 0; /* 0 means static structures haven't been
93 * initialized yet. */
94
95 /*
96 * To speed up TkMeasureChars, the variables below keep the last
97 * mapping from (XFontStruct *) to (TkFont *).
98 */
99
100 static TkFont *lastFontPtr = NULL;
101 static XFontStruct *lastFontStructPtr = NULL;
102
103 /*
104 * Characters used when displaying control sequences as their
105 * hex equivalents.
106 */
107
108 static char hexChars[] = "0123456789abcdefx\\";
109
110 /*
111 * Forward declarations for procedures defined in this file:
112 */
113
114 static void FontInit _ANSI_ARGS_((void));
115 static void SetFontMetrics _ANSI_ARGS_((TkFont *fontPtr));
116 \f
117 /*
118 *----------------------------------------------------------------------
119 *
120 * Tk_GetFontStruct --
121 *
122 * Given a string name for a font, map the name to an XFontStruct
123 * describing the font.
124 *
125 * Results:
126 * The return value is normally a pointer to the font description
127 * for the desired font. If an error occurs in mapping the string
128 * to a font, then an error message will be left in interp->result
129 * and NULL will be returned.
130 *
131 * Side effects:
132 * The font is added to an internal database with a reference count.
133 * For each call to this procedure, there should eventually be a call
134 * to Tk_FreeFontStruct, so that the database is cleaned up when fonts
135 * aren't in use anymore.
136 *
137 *----------------------------------------------------------------------
138 */
139
140 XFontStruct *
141 Tk_GetFontStruct (
142 Tcl_Interp *interp, /* Place to leave error message if
143 * font can't be found. */
144 Tk_Window tkwin, /* Window in which font will be used. */
145 Tk_Uid name /* Name of font (in form suitable for
146 * passing to XLoadQueryFont). */
147 )
148 {
149 NameKey nameKey;
150 Tcl_HashEntry *nameHashPtr, *fontHashPtr;
151 int new;
152 register TkFont *fontPtr;
153 XFontStruct *fontStructPtr;
154
155 if (!initialized) {
156 FontInit();
157 }
158
159 /*
160 * First, check to see if there's already a mapping for this font
161 * name.
162 */
163
164 nameKey.name = name;
165 nameKey.display = Tk_Display(tkwin);
166 nameHashPtr = Tcl_CreateHashEntry(&nameTable, (char *) &nameKey, &new);
167 if (!new) {
168 fontPtr = (TkFont *) Tcl_GetHashValue(nameHashPtr);
169 fontPtr->refCount++;
170 return fontPtr->fontStructPtr;
171 }
172
173 /*
174 * The name isn't currently known. Map from the name to a font, and
175 * add a new structure to the database.
176 */
177
178 fontStructPtr = XLoadQueryFont(nameKey.display, name);
179 if (fontStructPtr == NULL) {
180 Tcl_DeleteHashEntry(nameHashPtr);
181 Tcl_AppendResult(interp, "font \"", name, "\" doesn't exist",
182 (char *) NULL);
183 return NULL;
184 }
185 fontPtr = (TkFont *) ckalloc(sizeof(TkFont));
186 fontPtr->display = nameKey.display;
187 fontPtr->fontStructPtr = fontStructPtr;
188 fontPtr->refCount = 1;
189 fontPtr->types = NULL;
190 fontPtr->widths = NULL;
191 fontPtr->nameHashPtr = nameHashPtr;
192 fontHashPtr = Tcl_CreateHashEntry(&fontTable, (char *) fontStructPtr, &new);
193 if (!new) {
194 panic("XFontStruct already registered in Tk_GetFontStruct");
195 }
196 Tcl_SetHashValue(nameHashPtr, fontPtr);
197 Tcl_SetHashValue(fontHashPtr, fontPtr);
198 return fontPtr->fontStructPtr;
199 }
200 \f
201 /*
202 *--------------------------------------------------------------
203 *
204 * Tk_NameOfFontStruct --
205 *
206 * Given a font, return a textual string identifying it.
207 *
208 * Results:
209 * If font was created by Tk_GetFontStruct, then the return
210 * value is the "string" that was used to create it.
211 * Otherwise the return value is a string giving the X
212 * identifier for the font. The storage for the returned
213 * string is only guaranteed to persist up until the next
214 * call to this procedure.
215 *
216 * Side effects:
217 * None.
218 *
219 *--------------------------------------------------------------
220 */
221
222 char *
223 Tk_NameOfFontStruct (
224 XFontStruct *fontStructPtr /* Font whose name is desired. */
225 )
226 {
227 Tcl_HashEntry *fontHashPtr;
228 TkFont *fontPtr;
229 static char string[20];
230
231 if (!initialized) {
232 printid:
233 sprintf(string, "font id 0x%x", fontStructPtr->fid);
234 return string;
235 }
236 fontHashPtr = Tcl_FindHashEntry(&fontTable, (char *) fontStructPtr);
237 if (fontHashPtr == NULL) {
238 goto printid;
239 }
240 fontPtr = (TkFont *) Tcl_GetHashValue(fontHashPtr);
241 return ((NameKey *) fontPtr->nameHashPtr->key.words)->name;
242 }
243 \f
244 /*
245 *----------------------------------------------------------------------
246 *
247 * Tk_FreeFontStruct --
248 *
249 * This procedure is called to release a font allocated by
250 * Tk_GetFontStruct.
251 *
252 * Results:
253 * None.
254 *
255 * Side effects:
256 * The reference count associated with font is decremented, and
257 * the font is officially deallocated if no-one is using it
258 * anymore.
259 *
260 *----------------------------------------------------------------------
261 */
262
263 void
264 Tk_FreeFontStruct (
265 XFontStruct *fontStructPtr /* Font to be released. */
266 )
267 {
268 Tcl_HashEntry *fontHashPtr;
269 register TkFont *fontPtr;
270
271 if (!initialized) {
272 panic("Tk_FreeFontStruct called before Tk_GetFontStruct");
273 }
274
275 fontHashPtr = Tcl_FindHashEntry(&fontTable, (char *) fontStructPtr);
276 if (fontHashPtr == NULL) {
277 panic("Tk_FreeFontStruct received unknown font argument");
278 }
279 fontPtr = (TkFont *) Tcl_GetHashValue(fontHashPtr);
280 fontPtr->refCount--;
281 if (fontPtr->refCount == 0) {
282 XFreeFont(fontPtr->display, fontPtr->fontStructPtr);
283 Tcl_DeleteHashEntry(fontPtr->nameHashPtr);
284 Tcl_DeleteHashEntry(fontHashPtr);
285 if (fontPtr->types != NULL) {
286 ckfree(fontPtr->types);
287 }
288 if (fontPtr->widths != NULL) {
289 ckfree((char *) fontPtr->widths);
290 }
291 ckfree((char *) fontPtr);
292 lastFontStructPtr = NULL;
293 }
294 }
295 \f
296 /*
297 *----------------------------------------------------------------------
298 *
299 * FontInit --
300 *
301 * Initialize the structure used for font management.
302 *
303 * Results:
304 * None.
305 *
306 * Side effects:
307 * Read the code.
308 *
309 *----------------------------------------------------------------------
310 */
311
312 static void
313 FontInit (void)
314 {
315 initialized = 1;
316 Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));
317 Tcl_InitHashTable(&fontTable, TCL_ONE_WORD_KEYS);
318 }
319 \f
320 /*
321 *--------------------------------------------------------------
322 *
323 * SetFontMetrics --
324 *
325 * This procedure is called to fill in the "widths" and "types"
326 * arrays for a font.
327 *
328 * Results:
329 * None.
330 *
331 * Side effects:
332 * FontPtr gets modified to hold font metric information.
333 *
334 *--------------------------------------------------------------
335 */
336
337 static void
338 SetFontMetrics (
339 register TkFont *fontPtr /* Font structure in which to
340 * set metrics. */
341 )
342 {
343 int i, replaceOK, baseWidth;
344 register XFontStruct *fontStructPtr = fontPtr->fontStructPtr;
345 char *p;
346
347 /*
348 * Pass 1: initialize the arrays.
349 */
350
351 fontPtr->types = (char *) ckalloc(256);
352 fontPtr->widths = (unsigned char *) ckalloc(256);
353 for (i = 0; i < 256; i++) {
354 fontPtr->types[i] = REPLACE;
355 }
356
357 /*
358 * Pass 2: for all characters that exist in the font and are
359 * not control characters, fill in the type and width
360 * information.
361 */
362
363 for (i = ' '; i < 256; i++) {
364 if ((i == 0177) || (i < fontStructPtr->min_char_or_byte2)
365 || (i > fontStructPtr->max_char_or_byte2)) {
366 continue;
367 }
368 fontPtr->types[i] = NORMAL;
369 if (fontStructPtr->per_char == NULL) {
370 fontPtr->widths[i] = fontStructPtr->min_bounds.width;
371 } else {
372 fontPtr->widths[i] = fontStructPtr->per_char[i
373 - fontStructPtr->min_char_or_byte2].width;
374 }
375 }
376
377 /*
378 * Pass 3: fill in information for characters that have to
379 * be replaced with "\xhh" strings. If the font doesn't
380 * have the characters needed for this, then just use the
381 * font's default character.
382 */
383
384 replaceOK = 1;
385 baseWidth = fontPtr->widths['\\'] + fontPtr->widths['x'];
386 for (p = hexChars; *p != 0; p++) {
387 if (fontPtr->types[*p] != NORMAL) {
388 replaceOK = 0;
389 break;
390 }
391 }
392 for (i = 0; i < 256; i++) {
393 if (fontPtr->types[i] != REPLACE) {
394 continue;
395 }
396 if (replaceOK) {
397 fontPtr->widths[i] = baseWidth
398 + fontPtr->widths[hexChars[i & 0xf]]
399 + fontPtr->widths[hexChars[(i>>4) & 0xf]];
400 } else {
401 fontPtr->types[i] = SKIP;
402 fontPtr->widths[i] = 0;
403 }
404 }
405
406 /*
407 * Lastly, fill in special information for newline and tab.
408 */
409
410 fontPtr->types['\n'] = NEWLINE;
411 fontPtr->widths['\n'] = 0;
412 fontPtr->types['\t'] = TAB;
413 fontPtr->widths['\t'] = 0;
414 if (fontPtr->types['0'] == NORMAL) {
415 fontPtr->tabWidth = 8*fontPtr->widths['0'];
416 } else {
417 fontPtr->tabWidth = 8*fontStructPtr->max_bounds.width;
418 }
419
420 /*
421 * Make sure the tab width isn't zero (some fonts may not have enough
422 * information to set a reasonable tab width).
423 */
424
425 if (fontPtr->tabWidth == 0) {
426 fontPtr->tabWidth = 1;
427 }
428 }
429 \f
430 /*
431 *--------------------------------------------------------------
432 *
433 * TkMeasureChars --
434 *
435 * Measure the number of characters from a string that
436 * will fit in a given horizontal span. The measurement
437 * is done under the assumption that TkDisplayChars will
438 * be used to actually display the characters.
439 *
440 * Results:
441 * The return value is the number of characters from source
442 * that fit in the span given by startX and maxX. *nextXPtr
443 * is filled in with the x-coordinate at which the first
444 * character that didn't fit would be drawn, if it were to
445 * be drawn.
446 *
447 * Side effects:
448 * None.
449 *
450 *--------------------------------------------------------------
451 */
452
453 int
454 TkMeasureChars (
455 XFontStruct *fontStructPtr, /* Font in which to draw characters. */
456 char *source, /* Characters to be displayed. Need not
457 * be NULL-terminated. */
458 int maxChars, /* Maximum # of characters to consider from
459 * source. */
460 int startX, /* X-position at which first character will
461 * be drawn. */
462 int maxX, /* Don't consider any character that would
463 * cross this x-position. */
464 int flags, /* Various flag bits OR-ed together.
465 * TK_WHOLE_WORDS means stop on a word boundary
466 * (just before a space character) if
467 * possible. TK_AT_LEAST_ONE means always
468 * return a value of at least one, even
469 * if the character doesn't fit.
470 * TK_PARTIAL_OK means it's OK to display only
471 * a part of the last character in the line.
472 * TK_NEWLINES_NOT_SPECIAL means that newlines
473 * are treated just like other control chars:
474 * they don't terminate the line,*/
475 int *nextXPtr /* Return x-position of terminating
476 * character here. */
477 )
478 {
479 register TkFont *fontPtr;
480 register char *p; /* Current character. */
481 register int c;
482 char *term; /* Pointer to most recent character that
483 * may legally be a terminating character. */
484 int termX; /* X-position just after term. */
485 int curX; /* X-position corresponding to p. */
486 int newX; /* X-position corresponding to p+1. */
487 int type;
488
489 /*
490 * Find the TkFont structure for this font, and make sure its
491 * font metrics exist.
492 */
493
494 if (lastFontStructPtr == fontStructPtr) {
495 fontPtr = lastFontPtr;
496 } else {
497 Tcl_HashEntry *fontHashPtr;
498
499 if (!initialized) {
500 badArg:
501 panic("TkMeasureChars received unknown font argument");
502 }
503
504 fontHashPtr = Tcl_FindHashEntry(&fontTable, (char *) fontStructPtr);
505 if (fontHashPtr == NULL) {
506 goto badArg;
507 }
508 fontPtr = (TkFont *) Tcl_GetHashValue(fontHashPtr);
509 lastFontStructPtr = fontPtr->fontStructPtr;
510 lastFontPtr = fontPtr;
511 }
512 if (fontPtr->types == NULL) {
513 SetFontMetrics(fontPtr);
514 }
515
516 /*
517 * Scan the input string one character at a time, until a character
518 * is found that crosses maxX.
519 */
520
521 newX = curX = startX;
522 termX = 0; /* Not needed, but eliminates compiler warning. */
523 term = source;
524 for (p = source, c = *p & 0xff; maxChars > 0; p++, maxChars--) {
525 type = fontPtr->types[c];
526 if (type == NORMAL) {
527 newX += fontPtr->widths[c];
528 } else if (type == TAB) {
529 newX += fontPtr->tabWidth;
530 newX -= newX % fontPtr->tabWidth;
531 } else if (type == REPLACE) {
532 replaceType:
533 newX += fontPtr->widths['\\'] + fontPtr->widths['x']
534 + fontPtr->widths[hexChars[(c >> 4) & 0xf]]
535 + fontPtr->widths[hexChars[c & 0xf]];
536 } else if (type == NEWLINE) {
537 if (flags & TK_NEWLINES_NOT_SPECIAL) {
538 goto replaceType;
539 }
540 break;
541 } else if (type != SKIP) {
542 panic("Unknown type %d in TkMeasureChars", type);
543 }
544 if (newX > maxX) {
545 break;
546 }
547 c = p[1] & 0xff;
548 if (isspace(c) || (c == 0)) {
549 term = p+1;
550 termX = newX;
551 }
552 curX = newX;
553 }
554
555 /*
556 * P points to the first character that doesn't fit in the desired
557 * span. Use the flags to figure out what to return.
558 */
559
560 if ((flags & TK_PARTIAL_OK) && (curX < maxX)) {
561 curX = newX;
562 p++;
563 }
564 if ((flags & TK_AT_LEAST_ONE) && (term == source) && (maxChars > 0)
565 & !isspace(*term)) {
566 term = p;
567 termX = curX;
568 if (term == source) {
569 term++;
570 termX = newX;
571 }
572 } else if ((maxChars == 0) || !(flags & TK_WHOLE_WORDS)) {
573 term = p;
574 termX = curX;
575 }
576 *nextXPtr = termX;
577 return term-source;
578 }
579 \f
580 /*
581 *--------------------------------------------------------------
582 *
583 * TkDisplayChars --
584 *
585 * Draw a string of characters on the screen, converting
586 * tabs to the right number of spaces and control characters
587 * to sequences of the form "\xhh" where hh are two hex
588 * digits.
589 *
590 * Results:
591 * None.
592 *
593 * Side effects:
594 * Information gets drawn on the screen.
595 *
596 *--------------------------------------------------------------
597 */
598
599 void
600 TkDisplayChars (
601 Display *display, /* Display on which to draw. */
602 Drawable drawable, /* Window or pixmap in which to draw. */
603 GC gc, /* Graphics context for actually drawing
604 * characters. */
605 XFontStruct *fontStructPtr, /* Font used in GC; must have been allocated
606 * by Tk_GetFontStruct. Used to compute sizes
607 * of tabs, etc. */
608 char *string, /* Characters to be displayed. */
609 int numChars, /* Number of characters to display from
610 * string. */
611 int x,
612 int y, /* Coordinates at which to draw string. */
613 int flags /* Flags to control display. Only
614 * TK_NEWLINES_NOT_SPECIAL is supported right
615 * now. See TkMeasureChars for information
616 * about it. */
617 )
618 {
619 register TkFont *fontPtr;
620 register char *p; /* Current character being scanned. */
621 register int c;
622 int type;
623 char *start; /* First character waiting to be displayed. */
624 int startX; /* X-coordinate corresponding to start. */
625 int curX; /* X-coordinate corresponding to p. */
626 char replace[10];
627
628 /*
629 * Find the TkFont structure for this font, and make sure its
630 * font metrics exist.
631 */
632
633 if (lastFontStructPtr == fontStructPtr) {
634 fontPtr = lastFontPtr;
635 } else {
636 Tcl_HashEntry *fontHashPtr;
637
638 if (!initialized) {
639 badArg:
640 panic("TkDisplayChars received unknown font argument");
641 }
642
643 fontHashPtr = Tcl_FindHashEntry(&fontTable, (char *) fontStructPtr);
644 if (fontHashPtr == NULL) {
645 goto badArg;
646 }
647 fontPtr = (TkFont *) Tcl_GetHashValue(fontHashPtr);
648 lastFontStructPtr = fontPtr->fontStructPtr;
649 lastFontPtr = fontPtr;
650 }
651 if (fontPtr->types == NULL) {
652 SetFontMetrics(fontPtr);
653 }
654
655 /*
656 * Scan the string one character at a time. Display control
657 * characters immediately, but delay displaying normal characters
658 * in order to pass many characters to the server all together.
659 */
660
661 startX = curX = x;
662 start = string;
663 for (p = string; numChars > 0; numChars--, p++) {
664 c = *p & 0xff;
665 type = fontPtr->types[c];
666 if (type == NORMAL) {
667 curX += fontPtr->widths[c];
668 continue;
669 }
670 if (p != start) {
671 XDrawString(display, drawable, gc, startX, y, start, p - start);
672 startX = curX;
673 }
674 if (type == TAB) {
675 curX += fontPtr->tabWidth;
676 curX -= curX % fontPtr->tabWidth;
677 } else if (type == REPLACE) {
678 doReplace:
679 replace[0] = '\\';
680 replace[1] = 'x';
681 replace[2] = hexChars[(c >> 4) & 0xf];
682 replace[3] = hexChars[c & 0xf];
683 XDrawString(display, drawable, gc, startX, y, replace, 4);
684 curX += fontPtr->widths[replace[0]]
685 + fontPtr->widths[replace[1]]
686 + fontPtr->widths[replace[2]]
687 + fontPtr->widths[replace[3]];
688 } else if (type == NEWLINE) {
689 if (flags & TK_NEWLINES_NOT_SPECIAL) {
690 goto doReplace;
691 }
692 y += fontStructPtr->ascent + fontStructPtr->descent;
693 curX = x;
694 } else if (type != SKIP) {
695 panic("Unknown type %d in TkDisplayChars", type);
696 }
697 startX = curX;
698 start = p+1;
699 }
700
701 /*
702 * At the very end, there may be one last batch of normal characters
703 * to display.
704 */
705
706 if (p != start) {
707 XDrawString(display, drawable, gc, startX, y, start, p - start);
708 }
709 }
710 \f
711 /*
712 *----------------------------------------------------------------------
713 *
714 * TkUnderlineChars --
715 *
716 * This procedure draws an underline for a given range of characters
717 * in a given string, using appropriate information for the string's
718 * font. It doesn't draw the characters (which are assumed to have
719 * been displayed previously); it just draws the underline.
720 *
721 * Results:
722 * None.
723 *
724 * Side effects:
725 * Information gets displayed in "drawable".
726 *
727 *----------------------------------------------------------------------
728 */
729
730 void
731 TkUnderlineChars (
732 Display *display, /* Display on which to draw. */
733 Drawable drawable, /* Window or pixmap in which to draw. */
734 GC gc, /* Graphics context for actually drawing
735 * underline. */
736 XFontStruct *fontStructPtr, /* Font used in GC; must have been allocated
737 * by Tk_GetFontStruct. Used to character
738 * dimensions, etc. */
739 char *string, /* String containing characters to be
740 * underlined. */
741 int x,
742 int y, /* Coordinates at which first character of
743 * string is drawn. */
744 int flags, /* Flags that were passed to TkDisplayChars. */
745 int firstChar, /* Index of first character to underline. */
746 int lastChar /* Index of last character to underline. */
747 )
748 {
749 int xUnder, yUnder, width, height;
750 unsigned long value;
751
752 /*
753 * First compute the vertical span of the underline, using font
754 * properties if they exist.
755 */
756
757 if (XGetFontProperty(fontStructPtr, XA_UNDERLINE_POSITION, &value)) {
758 yUnder = y + value;
759 } else {
760 yUnder = y + fontStructPtr->max_bounds.descent/2;
761 }
762 if (XGetFontProperty(fontStructPtr, XA_UNDERLINE_THICKNESS, &value)) {
763 height = value;
764 } else {
765 height = 2;
766 }
767
768 /*
769 * Now compute the horizontal span of the underline.
770 */
771
772 TkMeasureChars(fontStructPtr, string, firstChar, x, (int) 1000000, flags,
773 &xUnder);
774 TkMeasureChars(fontStructPtr, string+firstChar, lastChar+1-firstChar,
775 xUnder, (int) 1000000, flags, &width);
776 width -= xUnder;
777
778 XFillRectangle(display, drawable, gc, xUnder, yUnder,
779 (unsigned int) width, (unsigned int) height);
780 }
Impressum, Datenschutz