1 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/Imakefile xc/lib/Xft/Imakefile
2 --- XFree86-4.0.2.orig/xc/lib/Xft/Imakefile Sat Dec 16 12:33:01 2000
3 +++ XFree86-4.0.2/xc/lib/Xft/Imakefile Fri Jan 19 20:25:58 2001
5 -XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.8 2000/12/15 17:12:52 keithp Exp $
6 +XCOMM $XFree86: xc/lib/Xft/Imakefile,v 1.9 2001/01/02 02:46:50 keithp Exp $
8 #define DoNormalLib NormalLibXft
9 #define DoSharedLib SharedLibXft
13 FT_HEADERS = XftFreetype.h
14 - FT_SRCS = xftdir.c xftfreetype.c xftglyphs.c xftrender.c
15 - FT_OBJS = xftdir.o xftfreetype.o xftglyphs.o xftrender.o
16 + FT_SRCS = xftcache.c xftdir.c xftfreetype.c xftglyphs.c xftrender.c
17 + FT_OBJS = xftcache.o xftdir.o xftfreetype.o xftglyphs.o xftrender.o
20 HEADERS = Xft.h $(FT_HEADERS)
21 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/Xft.h xc/lib/Xft/Xft.h
22 --- XFree86-4.0.2.orig/xc/lib/Xft/Xft.h Fri Dec 8 02:51:26 2000
23 +++ XFree86-4.0.2/xc/lib/Xft/Xft.h Fri Jan 19 20:25:58 2001
26 - * $XFree86: xc/lib/Xft/Xft.h,v 1.13 2000/12/08 07:51:26 keithp Exp $
27 + * $XFree86: xc/lib/Xft/Xft.h,v 1.16 2001/01/02 02:46:50 keithp Exp $
29 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
32 /* defaults from resources */
33 #define XFT_SCALE "scale" /* double */
34 #define XFT_RENDER "render" /* Bool */
35 +#define XFT_MINSPACE "minspace" /* Bool use minimum line spacing */
37 /* specific to FreeType rasterizer */
38 #define XFT_CHAR_WIDTH "charwidth" /* Int */
45 +XftDrawStringUtf8 (XftDraw *d,
54 XftDrawRect (XftDraw *d,
61 +XftTextExtentsUtf8 (Display *dpy,
65 + XGlyphInfo *extents);
69 XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result);
72 XftNameParse (const char *name);
75 +XftNameUnparse (XftPattern *pat, char *dest, int len);
79 XftPatternCreate (void);
85 +XftUtf8ToUcs4 (XftChar8 *src_orig,
90 +XftUtf8Len (XftChar8 *string,
97 XftXlfdParse (const char *xlfd_orig, Bool ignore_scalable, Bool complete);
100 XftCoreOpen (Display *dpy, XftPattern *pattern);
103 +XftCoreClose (Display *dpy, XFontStruct *font);
107 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/XftFreetype.h xc/lib/Xft/XftFreetype.h
108 --- XFree86-4.0.2.orig/xc/lib/Xft/XftFreetype.h Sat Dec 16 12:33:01 2000
109 +++ XFree86-4.0.2/xc/lib/Xft/XftFreetype.h Fri Jan 19 20:25:58 2001
112 - * $XFree86: xc/lib/Xft/XftFreetype.h,v 1.7 2000/12/15 17:12:52 keithp Exp $
113 + * $XFree86: xc/lib/Xft/XftFreetype.h,v 1.12 2001/01/02 02:46:50 keithp Exp $
115 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
126 int max_advance_width;
131 - Bool encoded; /* use charmap */
132 + int charmap; /* -1 for unencoded */
133 XRenderPictFormat *format;
134 XGlyphInfo **realized;
142 +XftDirScan (XftFontSet *set, const char *dir, Bool force);
145 +XftDirSave (XftFontSet *set, const char *dir);
149 +XftFreeTypeQuery (const char *file, int id, int *count);
152 +XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap);
155 XftFreeTypeOpen (Display *dpy, XftPattern *pattern);
158 XftFreeTypeClose (Display *dpy, XftFontStruct *font);
161 +XftFreeTypeGet (XftFont *font);
164 +XftInitFtLibrary(void);
168 XftGlyphLoad (Display *dpy,
170 XftChar32 *string, int len);
173 +XftRenderStringUtf8 (Display *dpy, Picture src,
174 + XftFontStruct *font, Picture dst,
175 + int srcx, int srcy,
177 + XftChar8 *string, int len);
180 XftRenderExtents8 (Display *dpy,
186 XGlyphInfo *extents);
189 +XftRenderExtentsUtf8 (Display *dpy,
190 + XftFontStruct *font,
193 + XGlyphInfo *extents);
196 XftFreeTypeGet (XftFont *font);
197 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftcache.c xc/lib/Xft/xftcache.c
198 --- XFree86-4.0.2.orig/xc/lib/Xft/xftcache.c Wed Dec 31 19:00:00 1969
199 +++ XFree86-4.0.2/xc/lib/Xft/xftcache.c Fri Jan 19 20:25:58 2001
202 + * $XFree86: xc/lib/Xft/xftcache.c,v 1.1 2001/01/02 02:46:51 keithp Exp $
204 + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
206 + * Permission to use, copy, modify, distribute, and sell this software and its
207 + * documentation for any purpose is hereby granted without fee, provided that
208 + * the above copyright notice appear in all copies and that both that
209 + * copyright notice and this permission notice appear in supporting
210 + * documentation, and that the name of Keith Packard not be used in
211 + * advertising or publicity pertaining to distribution of the software without
212 + * specific, written prior permission. Keith Packard makes no
213 + * representations about the suitability of this software for any purpose. It
214 + * is provided "as is" without express or implied warranty.
216 + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
217 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
218 + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
219 + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
220 + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
221 + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
222 + * PERFORMANCE OF THIS SOFTWARE.
231 +#include <sys/types.h>
232 +#include <sys/stat.h>
235 +typedef struct _XftFileCacheEnt {
236 + struct _XftFileCacheEnt *next;
245 +#define HASH_SIZE 509
247 +typedef struct _XftFileCache {
248 + XftFileCacheEnt *ents[HASH_SIZE];
254 +static XftFileCache _XftFileCache;
257 +_XftFileCacheHash (char *string)
259 + unsigned int h = 0;
262 + while ((c = *string++))
268 +XftFileCacheFind (char *file, int id, int *count)
270 + XftFileCache *cache;
273 + XftFileCacheEnt *c, *name;
277 + cache = &_XftFileCache;
280 + hash = _XftFileCacheHash (match);
283 + for (c = cache->ents[hash % HASH_SIZE]; c; c = c->next)
285 + if (c->hash == hash && !strcmp (match, c->file))
291 + if (stat (file, &statb) < 0)
293 + if (_XftFontDebug () & XFT_DBG_CACHE)
294 + printf (" file missing\n");
297 + if (statb.st_mtime != c->time)
299 + if (_XftFontDebug () & XFT_DBG_CACHE)
300 + printf (" timestamp mismatch (was %d is %d)\n",
301 + (int) c->time, (int) statb.st_mtime);
304 + if (!c->referenced)
306 + cache->referenced++;
307 + c->referenced = True;
320 + * Cache file syntax is quite simple:
322 + * "file_name" id time "font_name" \n
326 +_XftFileCacheReadString (FILE *f, char *dest, int len)
331 + while ((c = getc (f)) != EOF)
340 + while ((c = getc (f)) != EOF)
362 +_XftFileCacheReadUlong (FILE *f, unsigned long *dest)
367 + while ((c = getc (f)) != EOF)
377 + if (c == EOF || isspace (c))
381 + t = t * 10 + (c - '0');
389 +_XftFileCacheReadInt (FILE *f, int *dest)
394 + ret = _XftFileCacheReadUlong (f, &t);
401 +_XftFileCacheReadTime (FILE *f, time_t *dest)
406 + ret = _XftFileCacheReadUlong (f, &t);
408 + *dest = (time_t) t;
413 +_XftFileCacheAdd (XftFileCache *cache,
420 + XftFileCacheEnt *c;
421 + XftFileCacheEnt **prev, *old;
424 + if (_XftFontDebug () & XFT_DBG_CACHE)
426 + printf ("%s face %s/%d as %s\n", replace ? "Replace" : "Add",
429 + hash = _XftFileCacheHash (file);
430 + for (prev = &cache->ents[hash % HASH_SIZE];
432 + prev = &(*prev)->next)
434 + if (old->hash == hash && old->id == id && !strcmp (old->file, file))
443 + if (old->referenced)
444 + cache->referenced--;
450 + c = malloc (sizeof (XftFileCacheEnt) +
451 + strlen (file) + 1 +
452 + strlen (name) + 1);
458 + c->file = (char *) (c + 1);
460 + c->name = c->file + strlen (file) + 1;
461 + strcpy (c->file, file);
463 + c->referenced = replace;
464 + strcpy (c->name, name);
470 +XftFileCacheDispose (void)
472 + XftFileCache *cache;
473 + XftFileCacheEnt *c, *next;
476 + cache = &_XftFileCache;
478 + for (h = 0; h < HASH_SIZE; h++)
480 + for (c = cache->ents[h]; c; c = next)
485 + cache->ents[h] = 0;
487 + cache->entries = 0;
488 + cache->referenced = 0;
489 + cache->updated = False;
493 +XftFileCacheLoad (char *cache_file)
495 + XftFileCache *cache;
502 + f = fopen (cache_file, "r");
506 + cache = &_XftFileCache;
508 + cache->updated = False;
509 + while (_XftFileCacheReadString (f, file, sizeof (file)) &&
510 + _XftFileCacheReadInt (f, &id) &&
511 + _XftFileCacheReadTime (f, &time) &&
512 + _XftFileCacheReadString (f, name, sizeof (name)))
514 + (void) _XftFileCacheAdd (cache, file, id, time, name, False);
520 +XftFileCacheUpdate (char *file, int id, char *name)
522 + XftFileCache *cache;
527 + cache = &_XftFileCache;
530 + if (stat (file, &statb) < 0)
532 + ret = _XftFileCacheAdd (cache, match, id,
533 + statb.st_mtime, name, True);
535 + cache->updated = True;
540 +_XftFileCacheWriteString (FILE *f, char *string)
544 + if (putc ('"', f) == EOF)
546 + while ((c = *string++))
551 + if (putc ('\\', f) == EOF)
555 + if (putc (c, f) == EOF)
559 + if (putc ('"', f) == EOF)
565 +_XftFileCacheWriteUlong (FILE *f, unsigned long t)
568 + unsigned long temp, digit;
580 + digit = temp / pow;
581 + if (putc ((char) digit + '0', f) == EOF)
583 + temp = temp - pow * digit;
590 +_XftFileCacheWriteInt (FILE *f, int i)
592 + return _XftFileCacheWriteUlong (f, (unsigned long) i);
596 +_XftFileCacheWriteTime (FILE *f, time_t t)
598 + return _XftFileCacheWriteUlong (f, (unsigned long) t);
602 +XftFileCacheSave (char *cache_file)
604 + XftFileCache *cache;
609 + XftFileCacheEnt *c;
611 + cache = &_XftFileCache;
613 + if (!cache->updated && cache->referenced == cache->entries)
616 + lck = malloc (strlen (cache_file)*2 + 4);
619 + tmp = lck + strlen (cache_file) + 2;
620 + strcpy (lck, cache_file);
622 + strcpy (tmp, cache_file);
624 + if (link (lck, cache_file) < 0 && errno != ENOENT)
626 + if (access (tmp, F_OK) == 0)
628 + f = fopen (tmp, "w");
632 + for (h = 0; h < HASH_SIZE; h++)
634 + for (c = cache->ents[h]; c; c = c->next)
636 + if (!c->referenced)
638 + if (!_XftFileCacheWriteString (f, c->file))
640 + if (putc (' ', f) == EOF)
642 + if (!_XftFileCacheWriteInt (f, c->id))
644 + if (putc (' ', f) == EOF)
646 + if (!_XftFileCacheWriteTime (f, c->time))
648 + if (putc (' ', f) == EOF)
650 + if (!_XftFileCacheWriteString (f, c->name))
652 + if (putc ('\n', f) == EOF)
657 + if (fclose (f) == EOF)
660 + if (rename (tmp, cache_file) < 0)
664 + cache->updated = False;
680 +XftFileCacheReadDir (XftFontSet *set, const char *cache_file)
691 + if (_XftFontDebug () & XFT_DBG_CACHE)
693 + printf ("XftFileCacheReadDir cache_file \"%s\"\n", cache_file);
696 + f = fopen (cache_file, "r");
699 + if (_XftFontDebug () & XFT_DBG_CACHE)
701 + printf (" no cache file\n");
706 + base = strrchr (cache_file, '/');
710 + path = malloc (base - cache_file + 8192 + 1);
713 + memcpy (path, cache_file, base - cache_file);
714 + base = path + (base - cache_file);
716 + while (_XftFileCacheReadString (f, file, sizeof (file)) &&
717 + _XftFileCacheReadInt (f, &id) &&
718 + _XftFileCacheReadString (f, name, sizeof (name)))
720 + font = XftNameParse (name);
723 + strcpy (base, file);
724 + if (_XftFontDebug () & XFT_DBG_CACHEV)
726 + printf (" dir cache file \"%s\"\n", file);
728 + XftPatternAddString (font, XFT_FILE, path);
729 + if (!XftFontSetAdd (set, font))
733 + if (_XftFontDebug () & XFT_DBG_CACHE)
735 + printf (" cache loaded\n");
748 +XftFileCacheWriteDir (XftFontSet *set, const char *cache_file)
757 + if (_XftFontDebug () & XFT_DBG_CACHE)
758 + printf ("XftFileCacheWriteDir cache_file \"%s\"\n", cache_file);
760 + f = fopen (cache_file, "w");
763 + if (_XftFontDebug () & XFT_DBG_CACHE)
764 + printf (" can't create \"%s\"\n", cache_file);
767 + for (n = 0; n < set->nfont; n++)
769 + font = set->fonts[n];
770 + if (XftPatternGetString (font, XFT_FILE, 0, &file) != XftResultMatch)
772 + base = strrchr (file, '/');
777 + if (XftPatternGetInteger (font, XFT_INDEX, 0, &id) != XftResultMatch)
779 + if (!XftNameUnparse (font, name, sizeof (name)))
781 + if (_XftFontDebug () & XFT_DBG_CACHEV)
782 + printf (" write file \"%s\"\n", base);
783 + if (!_XftFileCacheWriteString (f, base))
785 + if (putc (' ', f) == EOF)
787 + if (!_XftFileCacheWriteInt (f, id))
789 + if (putc (' ', f) == EOF)
791 + if (!_XftFileCacheWriteString (f, name))
793 + if (putc ('\n', f) == EOF)
796 + if (fclose (f) == EOF)
799 + if (_XftFontDebug () & XFT_DBG_CACHE)
800 + printf (" cache written\n");
806 + unlink (cache_file);
809 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftcfg.c xc/lib/Xft/xftcfg.c
810 --- XFree86-4.0.2.orig/xc/lib/Xft/xftcfg.c Tue Dec 19 08:12:29 2000
811 +++ XFree86-4.0.2/xc/lib/Xft/xftcfg.c Fri Jan 19 20:25:58 2001
814 - * $XFree86: xc/lib/Xft/xftcfg.c,v 1.7 2000/12/17 09:11:37 keithp Exp $
815 + * $XFree86: xc/lib/Xft/xftcfg.c,v 1.8 2001/01/02 02:46:51 keithp Exp $
817 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
820 char **XftConfigDirs = XftConfigDefaultDirs;
821 static int XftConfigNdirs;
823 +char XftConfigDefaultCache[] = "~/.xftcache";
824 +char *XftConfigCache = 0;
826 static XftSubst *XftSubsts;
827 /* #define XFT_DEBUG_EDIT */
832 dir = (char *) malloc (strlen (h) + strlen (d));
839 free (XftConfigDirs);
840 XftConfigDirs = dirs;
845 +XftConfigSetCache (char *c)
852 + h = getenv ("HOME");
855 + new = (char *) malloc (strlen (h) + strlen (c));
863 + new = _XftSaveString (c);
865 + if (XftConfigCache)
866 + free (XftConfigCache);
867 + XftConfigCache = new;
872 +XftConfigGetCache (void)
874 + if (!XftConfigCache)
875 + XftConfigSetCache (XftConfigDefaultCache);
876 + return XftConfigCache;
879 static int XftSubstsMaxObjects;
880 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftcore.c xc/lib/Xft/xftcore.c
881 --- XFree86-4.0.2.orig/xc/lib/Xft/xftcore.c Fri Dec 8 02:51:27 2000
882 +++ XFree86-4.0.2/xc/lib/Xft/xftcore.c Fri Jan 19 20:25:58 2001
885 - * $XFree86: xc/lib/Xft/xftcore.c,v 1.4 2000/12/08 07:51:27 keithp Exp $
886 + * $XFree86: xc/lib/Xft/xftcore.c,v 1.5 2000/12/20 00:28:44 keithp Exp $
888 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
895 +XftCoreConvertUtf8 (XftChar8 *string,
897 + XChar2b xcloc[XFT_CORE_N16LOCAL],
906 + if (!XftUtf8Len (string, len, &n, &width))
909 + if (n < XFT_CORE_N16LOCAL)
912 + xc = (XChar2b *) malloc (n * sizeof (XChar2b));
913 + for (i = 0; i < n; i++)
915 + clen = XftUtf8ToUcs4 (string, &c, len);
916 + xc[i].byte1 = c & 0xff;
917 + xc[i].byte2 = (c >> 8) & 0xff;
926 XftCoreExtents8 (Display *dpy,
929 xc = XftCoreConvert16 (string, len, xcloc);
930 XTextExtents16 (fs, xc, len, &direction,
931 &ascent, &descent, &overall);
934 if (overall.lbearing < overall.rbearing)
936 extents->x = overall.lbearing;
938 xc = XftCoreConvert32 (string, len, xcloc);
939 XTextExtents16 (fs, xc, len, &direction,
940 &ascent, &descent, &overall);
943 + if (overall.lbearing < overall.rbearing)
945 + extents->x = overall.lbearing;
946 + extents->width = overall.rbearing - overall.lbearing;
950 + extents->x = overall.rbearing;
951 + extents->width = overall.lbearing - overall.rbearing;
953 + extents->y = -overall.ascent;
954 + extents->height = overall.ascent + overall.descent;
955 + extents->xOff = overall.width;
960 +XftCoreExtentsUtf8 (Display *dpy,
964 + XGlyphInfo *extents)
967 + int ascent, descent;
968 + XCharStruct overall;
969 + XChar2b *xc, xcloc[XFT_CORE_N16LOCAL];
972 + xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
973 + XTextExtents16 (fs, xc, n, &direction,
974 + &ascent, &descent, &overall);
977 if (overall.lbearing < overall.rbearing)
979 extents->x = overall.lbearing;
980 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftdir.c xc/lib/Xft/xftdir.c
981 --- XFree86-4.0.2.orig/xc/lib/Xft/xftdir.c Wed Nov 29 03:39:21 2000
982 +++ XFree86-4.0.2/xc/lib/Xft/xftdir.c Fri Jan 19 20:25:58 2001
985 - * $XFree86: xc/lib/Xft/xftdir.c,v 1.1 2000/11/29 08:39:21 keithp Exp $
986 + * $XFree86: xc/lib/Xft/xftdir.c,v 1.2 2001/01/02 02:46:51 keithp Exp $
988 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
994 -XftDirScan (XftFontSet *set, const char *dir)
995 +XftDirScan (XftFontSet *set, const char *dir, Bool force)
1007 - d = opendir (dir);
1010 file = (char *) malloc (strlen (dir) + 1 + 256 + 1);
1019 base = file + strlen (file);
1022 + strcpy (base, "XftCache");
1024 + if (XftFileCacheReadDir (set, file))
1031 + d = opendir (dir);
1037 while (ret && (e = readdir (d)))
1039 if (e->d_name[0] != '.')
1041 - strcpy (base, e->d_name);
1043 + strcpy (base, e->d_name);
1046 - font = XftFreeTypeQuery (file, id, &count);
1048 + name = XftFileCacheFind (file, id, &count);
1053 + font = XftNameParse (name);
1055 + XftPatternAddString (font, XFT_FILE, file);
1059 + font = XftFreeTypeQuery (file, id, &count);
1060 + if (font && !force)
1062 + char unparse[8192];
1064 + if (XftNameUnparse (font, unparse, sizeof (unparse)))
1066 + (void) XftFileCacheUpdate (file, id, unparse);
1072 if (!XftFontSetAdd (set, font))
1079 +XftDirSave (XftFontSet *set, const char *dir)
1085 + file = (char *) malloc (strlen (dir) + 1 + 256 + 1);
1089 + strcpy (file, dir);
1090 + strcat (file, "/");
1091 + base = file + strlen (file);
1092 + strcpy (base, "XftCache");
1093 + ret = XftFileCacheWriteDir (set, file);
1098 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftdpy.c xc/lib/Xft/xftdpy.c
1099 --- XFree86-4.0.2.orig/xc/lib/Xft/xftdpy.c Tue Dec 19 08:12:29 2000
1100 +++ XFree86-4.0.2/xc/lib/Xft/xftdpy.c Fri Jan 19 20:25:58 2001
1103 - * $XFree86: xc/lib/Xft/xftdpy.c,v 1.4 2000/12/17 08:30:45 keithp Exp $
1104 + * $XFree86: xc/lib/Xft/xftdpy.c,v 1.5 2000/12/20 00:20:48 keithp Exp $
1106 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
1109 * PERFORMANCE OF THIS SOFTWARE.
1115 #include <X11/Xlibint.h>
1118 info->coreFonts = 0;
1119 info->hasRender = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0;
1120 + if (_XftFontDebug () & XFT_DBG_RENDER)
1122 + Visual *visual = DefaultVisual (dpy, DefaultScreen (dpy));
1123 + XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1125 + printf ("XftDisplayInfoGet Default visual 0x%x ",
1126 + (int) visual->visualid);
1129 + if (format->type == PictTypeDirect)
1131 + printf ("format %d,%d,%d,%d\n",
1132 + format->direct.alpha,
1133 + format->direct.red,
1134 + format->direct.green,
1135 + format->direct.blue);
1139 + printf ("format indexed\n");
1143 + printf ("No Render format for default visual\n");
1145 + printf ("XftDisplayInfoGet initialized, hasRender set to \"%s\"\n",
1146 + info->hasRender ? "True" : "False");
1149 info->next = _XftDisplayInfo;
1150 _XftDisplayInfo = info;
1155 + if (_XftFontDebug () & XFT_DBG_RENDER)
1157 + printf ("XftDisplayInfoGet failed to initialize, Xft unhappy\n");
1164 if (!_XftDefaultInitBool (dpy, pat, XFT_ANTIALIAS))
1166 + if (!_XftDefaultInitBool (dpy, pat, XFT_MINSPACE))
1171 @@ -343,6 +378,12 @@
1172 XftPatternAddInteger (pattern, XFT_RGBA,
1173 XftDefaultGetInteger (dpy, XFT_RGBA, screen,
1176 + if (XftPatternGet (pattern, XFT_MINSPACE, 0, &v) == XftResultNoMatch)
1178 + XftPatternAddBool (pattern, XFT_MINSPACE,
1179 + XftDefaultGetBool (dpy, XFT_MINSPACE, screen,
1182 if (XftPatternGet (pattern, XFT_PIXEL_SIZE, 0, &v) == XftResultNoMatch)
1184 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftdraw.c xc/lib/Xft/xftdraw.c
1185 --- XFree86-4.0.2.orig/xc/lib/Xft/xftdraw.c Sat Dec 16 12:33:01 2000
1186 +++ XFree86-4.0.2/xc/lib/Xft/xftdraw.c Fri Jan 19 20:25:58 2001
1189 - * $XFree86: xc/lib/Xft/xftdraw.c,v 1.10 2000/12/15 17:12:52 keithp Exp $
1190 + * $XFree86: xc/lib/Xft/xftdraw.c,v 1.12 2000/12/20 00:28:44 keithp Exp $
1192 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
1195 * PERFORMANCE OF THIS SOFTWARE.
1201 #include <X11/Xutil.h>
1202 @@ -200,6 +201,14 @@
1204 if (memcmp (&color->color, &draw->render.fg_color, sizeof (XRenderColor)))
1206 + if (_XftFontDebug () & XFT_DBG_DRAW)
1208 + printf ("Switching to color %04x,%04x,%04x,%04x\n",
1209 + color->color.alpha,
1211 + color->color.green,
1212 + color->color.blue);
1214 XRenderFillRectangle (draw->dpy, PictOpSrc, draw->render.fg_pict,
1215 &color->color, 0, 0, 1, 1);
1216 draw->render.fg_color = color->color;
1217 @@ -255,6 +264,10 @@
1221 + if (_XftFontDebug () & XFT_DBG_DRAW)
1223 + printf ("DrawString \"%*.*s\"\n", len, len, string);
1227 XftDrawCorePrepare (draw, color, font);
1228 @@ -331,6 +344,41 @@
1234 +XftDrawStringUtf8 (XftDraw *draw,
1245 + XChar2b xcloc[XFT_CORE_N16LOCAL];
1248 + XftDrawCorePrepare (draw, color, font);
1249 + xc = XftCoreConvertUtf8 (string, len, xcloc, &n);
1252 + XDrawString16 (draw->dpy, draw->drawable, draw->core.draw_gc, x, y,
1259 + else if (XftDrawRenderPrepare (draw, color, font))
1261 + XftRenderStringUtf8 (draw->dpy, draw->render.fg_pict, font->u.ft.font,
1262 + draw->render.pict, 0, 0, x, y, string, len);
1269 XftDrawRect (XftDraw *draw,
1270 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftextent.c xc/lib/Xft/xftextent.c
1271 --- XFree86-4.0.2.orig/xc/lib/Xft/xftextent.c Sat Dec 16 12:33:01 2000
1272 +++ XFree86-4.0.2/xc/lib/Xft/xftextent.c Fri Jan 19 20:25:58 2001
1275 - * $XFree86: xc/lib/Xft/xftextent.c,v 1.4 2000/12/15 17:12:52 keithp Exp $
1276 + * $XFree86: xc/lib/Xft/xftextent.c,v 1.5 2000/12/20 00:28:44 keithp Exp $
1278 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
1281 * PERFORMANCE OF THIS SOFTWARE.
1284 +#include <stdlib.h>
1289 XftRenderExtents32 (dpy, font->u.ft.font, string, len, extents);
1295 +XftTextExtentsUtf8 (Display *dpy,
1299 + XGlyphInfo *extents)
1303 + XftChar32 lbuf[4096];
1312 + /* compute needed width */
1318 + clen = XftUtf8ToUcs4 (src, &c, rlen);
1319 + if (clen <= 0) /* malformed UTF8 string */
1321 + memset (extents, 0, sizeof (XGlyphInfo));
1326 + else if (c >= 0x100)
1336 + if (n * width > sizeof (lbuf))
1338 + dst = (XftChar32 *) malloc (n * width);
1341 + memset (extents, 0, sizeof (XGlyphInfo));
1353 + clen = XftUtf8ToUcs4 (src, &c, rlen);
1354 + if (clen <= 0) /* malformed UTF8 string */
1361 + XftTextExtents32 (dpy, font, dst32, n, extents);
1366 + dst16 = (XftChar16 *) dst;
1369 + clen = XftUtf8ToUcs4 (src, &c, rlen);
1370 + if (clen <= 0) /* malformed UTF8 string */
1376 + dst16 = (XftChar16 *) dst;
1377 + XftTextExtents16 (dpy, font, dst16, n, extents);
1382 + dst8 = (XftChar8 *) dst;
1385 + clen = XftUtf8ToUcs4 (src, &c, rlen);
1386 + if (clen <= 0) /* malformed UTF8 string */
1392 + dst8 = (XftChar8 *) dst;
1393 + XftTextExtents8 (dpy, font, dst8, n, extents);
1399 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftfont.c xc/lib/Xft/xftfont.c
1400 --- XFree86-4.0.2.orig/xc/lib/Xft/xftfont.c Sat Dec 16 12:33:01 2000
1401 +++ XFree86-4.0.2/xc/lib/Xft/xftfont.c Fri Jan 19 20:25:58 2001
1404 - * $XFree86: xc/lib/Xft/xftfont.c,v 1.7 2000/12/15 17:12:53 keithp Exp $
1405 + * $XFree86: xc/lib/Xft/xftfont.c,v 1.8 2000/12/20 00:20:48 keithp Exp $
1407 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
1410 * PERFORMANCE OF THIS SOFTWARE.
1419 XftFontMatch (Display *dpy, int screen, XftPattern *pattern, XftResult *result)
1421 new = XftPatternDuplicate (pattern);
1425 + if (_XftFontDebug () & XFT_DBG_OPENV)
1427 + printf ("XftFontMatch pattern ");
1428 + XftPatternPrint (new);
1430 XftConfigSubstitute (new);
1431 + if (_XftFontDebug () & XFT_DBG_OPENV)
1433 + printf ("XftFontMatch after XftConfig substitutions ");
1434 + XftPatternPrint (new);
1436 XftDefaultSubstitute (dpy, screen, new);
1437 + if (_XftFontDebug () & XFT_DBG_OPENV)
1439 + printf ("XftFontMatch after X resource substitutions ");
1440 + XftPatternPrint (new);
1447 (void) XftPatternGetBool (new, XFT_RENDER, 0, &render);
1448 (void) XftPatternGetBool (new, XFT_CORE, 0, &core);
1449 + if (_XftFontDebug () & XFT_DBG_OPENV)
1451 + printf ("XftFontMatch: use core fonts \"%s\", use render fonts \"%s\"\n",
1452 + core ? "True" : "False", render ? "True" : "False");
1457 @@ -133,10 +154,17 @@
1464 - debug = getenv ("XFT_DEBUG") != 0;
1466 - printf ("XFT_DEBUG found\n");
1467 + e = getenv ("XFT_DEBUG");
1470 + printf ("XFT_DEBUG=%s\n", e);
1478 @@ -155,12 +183,12 @@
1482 - if (_XftFontDebug ())
1483 + if (_XftFontDebug () & XFT_DBG_OPEN)
1484 printf ("XftFontOpen: Invalid pattern argument\n");
1487 match = XftFontMatch (dpy, screen, pat, &result);
1488 - if (_XftFontDebug ())
1489 + if (_XftFontDebug () & XFT_DBG_OPEN)
1491 printf ("Pattern ");
1492 XftPatternPrint (pat);
1494 font = XftFontOpenPattern (dpy, match);
1497 - if (_XftFontDebug ())
1498 + if (_XftFontDebug () & XFT_DBG_OPEN)
1499 printf ("No Font\n");
1500 XftPatternDestroy (match);
1505 pat = XftNameParse (name);
1506 - if (_XftFontDebug ())
1507 + if (_XftFontDebug () & XFT_DBG_OPEN)
1509 printf ("XftFontOpenName \"%s\": ", name);
1514 match = XftFontMatch (dpy, screen, pat, &result);
1515 - if (_XftFontDebug ())
1516 + if (_XftFontDebug () & XFT_DBG_OPEN)
1523 pat = XftXlfdParse (xlfd, False, False);
1524 - if (_XftFontDebug ())
1525 + if (_XftFontDebug () & XFT_DBG_OPEN)
1527 printf ("XftFontOpenXlfd \"%s\": ", xlfd);
1532 match = XftFontMatch (dpy, screen, pat, &result);
1533 - if (_XftFontDebug ())
1534 + if (_XftFontDebug () & XFT_DBG_OPEN)
1539 XftFontClose (Display *dpy, XftFont *font)
1542 - XFreeFont (dpy, font->u.core.font);
1543 + XftCoreClose (dpy, font->u.core.font);
1546 XftFreeTypeClose (dpy, font->u.ft.font);
1547 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftfreetype.c xc/lib/Xft/xftfreetype.c
1548 --- XFree86-4.0.2.orig/xc/lib/Xft/xftfreetype.c Sat Dec 16 12:33:01 2000
1549 +++ XFree86-4.0.2/xc/lib/Xft/xftfreetype.c Fri Jan 19 20:25:58 2001
1552 - * $XFree86: xc/lib/Xft/xftfreetype.c,v 1.5 2000/12/15 17:12:53 keithp Exp $
1553 + * $XFree86: xc/lib/Xft/xftfreetype.c,v 1.9 2001/01/02 02:46:51 keithp Exp $
1555 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
1564 FT_Library _XftFTlibrary;
1566 FT_Encoding encoding;
1569 -XftFtEncoding xftFtEncoding[] = {
1570 +static XftFtEncoding xftFtEncoding[] = {
1571 { "iso10646-1", ft_encoding_unicode, },
1572 { "iso8859-1", ft_encoding_unicode, },
1573 + { "apple-roman", ft_encoding_apple_roman },
1574 { "adobe-fontspecific", ft_encoding_symbol, },
1575 { "glyphs-fontspecific",ft_encoding_none, },
1579 slant = XFT_SLANT_ROMAN;
1580 if (face->style_flags & FT_STYLE_FLAG_ITALIC)
1581 - slant = (XFT_SLANT_ITALIC + XFT_SLANT_OBLIQUE) / 2;
1582 + slant = XFT_SLANT_ITALIC;
1584 if (!XftPatternAddInteger (pat, XFT_SLANT, slant))
1587 if (!XftPatternAddInteger (pat, XFT_INDEX, id))
1590 + if ((face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0)
1591 + if (!XftPatternAddInteger (pat, XFT_SPACING, XFT_MONO))
1594 if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
1596 for (i = 0; i < face->num_fixed_sizes; i++)
1597 @@ -142,41 +148,185 @@
1602 + * List of all open files (each face in a file is managed separately)
1604 +typedef struct _XftFtFile {
1605 + struct _XftFtFile *next;
1616 +static XftFtFile *_XftFtFiles;
1619 +_XftFreeTypeOpenFile (char *file, int id)
1624 + for (f = _XftFtFiles; f; f = f->next)
1626 + if (!strcmp (f->file, file) && f->id == id)
1629 + if (_XftFontDebug () & XFT_DBG_REF)
1630 + printf ("FontFile %s/%d matches existing (%d)\n",
1631 + file, id, f->ref);
1635 + if (FT_New_Face (_XftFTlibrary, file, id, &face))
1638 + f = malloc (sizeof (XftFtFile) + strlen (file) + 1);
1642 + if (_XftFontDebug () & XFT_DBG_REF)
1643 + printf ("FontFile %s/%d matches new\n",
1645 + f->next = _XftFtFiles;
1649 + f->file = (char *) (f+1);
1650 + strcpy (f->file, file);
1660 +XftFreeTypeSetFace (FT_Face face, FT_F26Dot6 size, int charmap)
1662 + XftFtFile *f, **prev;
1664 + for (prev = &_XftFtFiles; (f = *prev); prev = &f->next)
1666 + if (f->face == face)
1669 + if (prev != &_XftFtFiles)
1672 + f->next = _XftFtFiles;
1675 + if (f->size != size)
1677 + if (_XftFontDebug() & XFT_DBG_GLYPH)
1678 + printf ("Set face size to %d (%d)\n",
1679 + (int) (size >> 6), (int) size);
1680 + if (FT_Set_Char_Size (face, size, size, 0, 0))
1684 + if (f->charmap != charmap && charmap != -1)
1686 + if (_XftFontDebug() & XFT_DBG_GLYPH)
1687 + printf ("Set face charmap to %d\n", charmap);
1688 + if (FT_Set_Charmap (face, face->charmaps[charmap]))
1690 + f->charmap = charmap;
1699 +_XftFreeTypeCloseFile (XftFtFile *f)
1703 + if (--f->ref != 0)
1705 + for (prev = &_XftFtFiles; *prev; prev = &(*prev)->next)
1713 + FT_Done_Face (f->face);
1718 + * Cache of all glyphsets
1720 +typedef struct _XftFtGlyphSet {
1721 + struct _XftFtGlyphSet *next;
1728 + XftFontStruct font;
1731 +static XftFtGlyphSet *_XftFtGlyphSets;
1734 XftFreeTypeOpen (Display *dpy, XftPattern *pattern)
1739 + XftFtGlyphSet *gs;
1751 char *encoding_name;
1753 XftFontStruct *font;
1755 FT_Encoding encoding;
1759 - int height, ascent, descent;
1763 + int height, ascent, descent;
1764 XRenderPictFormat pf, *format;
1766 - if (XftPatternGetString (pattern, XFT_FILE, 0, &file) != XftResultMatch)
1770 + if (XftPatternGetString (pattern, XFT_FILE, 0, &filename) != XftResultMatch)
1773 if (XftPatternGetInteger (pattern, XFT_INDEX, 0, &id) != XftResultMatch)
1776 + file = _XftFreeTypeOpenFile (filename, id);
1780 + face = file->face;
1783 + * Extract the glyphset information from the pattern
1785 if (XftPatternGetString (pattern, XFT_ENCODING, 0, &encoding_name) != XftResultMatch)
1788 - if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &size) != XftResultMatch)
1789 + if (XftPatternGetDouble (pattern, XFT_PIXEL_SIZE, 0, &dsize) != XftResultMatch)
1792 switch (XftPatternGetInteger (pattern, XFT_RGBA, 0, &rgba)) {
1793 @@ -199,11 +349,101 @@
1797 + switch (XftPatternGetBool (pattern, XFT_MINSPACE, 0, &minspace)) {
1798 + case XftResultNoMatch:
1801 + case XftResultMatch:
1807 + switch (XftPatternGetInteger (pattern, XFT_SPACING, 0, &spacing)) {
1808 + case XftResultNoMatch:
1809 + spacing = XFT_PROPORTIONAL;
1811 + case XftResultMatch:
1817 if (XftPatternGetInteger (pattern, XFT_CHAR_WIDTH,
1818 0, &char_width) != XftResultMatch)
1822 + else if (char_width)
1823 + spacing = XFT_MONO;
1825 + encoding = face->charmaps[0]->encoding;
1827 + for (j = 0; j < NUM_FT_ENCODINGS; j++)
1828 + if (!strcmp (encoding_name, xftFtEncoding[j].name))
1830 + encoding = xftFtEncoding[j].encoding;
1834 + size = (FT_F26Dot6) (dsize * 64.0);
1836 + if (encoding == ft_encoding_none)
1840 + for (charmap = 0; charmap < face->num_charmaps; charmap++)
1841 + if (face->charmaps[charmap]->encoding == encoding)
1844 + if (charmap == face->num_charmaps)
1850 + * Match an existing glyphset
1852 + for (gs = _XftFtGlyphSets; gs; gs = gs->next)
1854 + if (gs->file == file &&
1855 + gs->minspace == minspace &&
1856 + gs->char_width == char_width &&
1857 + gs->font.size == size &&
1858 + gs->font.spacing == spacing &&
1859 + gs->font.charmap == charmap &&
1860 + gs->font.rgba == rgba &&
1861 + gs->font.antialias == antialias)
1864 + if (_XftFontDebug () & XFT_DBG_REF)
1866 + printf ("Face size %g matches existing (%d)\n",
1873 + if (_XftFontDebug () & XFT_DBG_REF)
1875 + printf ("Face size %g matches new\n",
1879 + * No existing glyphset, create another
1881 + gs = malloc (sizeof (XftFtGlyphSet));
1888 + gs->minspace = minspace;
1889 + gs->char_width = char_width;
1895 @@ -261,106 +501,60 @@
1902 - if (FT_New_Face (_XftFTlibrary, file, id, &face))
1904 + font->size = size;
1906 - font = (XftFontStruct *) malloc (sizeof (XftFontStruct));
1910 - font->size = (FT_F26Dot6) (size * 64.0);
1912 - if ( FT_Set_Char_Size (face, font->size, font->size, 0, 0) )
1913 + if (!XftFreeTypeSetFace (face, size, charmap))
1916 - encoding = face->charmaps[0]->encoding;
1918 - for (j = 0; j < NUM_FT_ENCODINGS; j++)
1919 - if (!strcmp (encoding_name, xftFtEncoding[j].name))
1921 - encoding = xftFtEncoding[j].encoding;
1925 - if (encoding == ft_encoding_none)
1928 + descent = -(face->size->metrics.descender >> 6);
1929 + ascent = face->size->metrics.ascender >> 6;
1933 - for (charmap = 0; charmap < face->num_charmaps; charmap++)
1934 - if (face->charmaps[charmap]->encoding == encoding)
1937 - if (charmap == face->num_charmaps)
1940 - error = FT_Set_Charmap(face,
1941 - face->charmaps[charmap]);
1945 + height = ascent + descent;
1948 - height = face->height;
1949 - ascent = face->ascender;
1950 - descent = face->descender;
1951 - if (descent < 0) descent = - descent;
1952 - extra = (height - (ascent + descent));
1956 - ascent = ascent + extra / 2;
1957 - descent = height - ascent;
1958 + height = face->size->metrics.height >> 6;
1959 + extra = (height - (ascent + descent));
1962 + ascent = ascent + extra / 2;
1963 + descent = height - ascent;
1965 + else if (extra < 0)
1966 + height = ascent + descent;
1968 - else if (extra < 0)
1969 - height = ascent + descent;
1970 - div = face->units_per_EM;
1971 - if (height > div * 5)
1974 - div = face->units_per_EM;
1975 - if (height > div * 5)
1978 - font->descent = descent * font->size / (64 * div);
1979 - font->ascent = ascent * font->size / (64 * div);
1980 - font->height = height * font->size / (64 * div);
1981 - font->max_advance_width = face->max_advance_width * font->size / (64 * div);
1982 + font->ascent = ascent;
1983 + font->descent = descent;
1984 + font->height = height;
1986 - font->monospace = (face->face_flags & FT_FACE_FLAG_FIXED_WIDTH) != 0;
1989 font->max_advance_width = char_width;
1990 - font->monospace = True;
1992 - switch (XftPatternGetInteger (pattern, XFT_SPACING, 0, &spacing)) {
1993 - case XftResultNoMatch:
1995 - case XftResultMatch:
1996 - if (spacing != XFT_PROPORTIONAL)
1997 - font->monospace = True;
2003 + font->max_advance_width = face->size->metrics.max_advance >> 6;
2005 + gs->next = _XftFtGlyphSets;
2006 + _XftFtGlyphSets = gs;
2008 font->glyphset = XRenderCreateGlyphSet (dpy, format);
2010 + font->spacing = spacing;
2011 font->format = format;
2013 font->nrealized = 0;
2015 font->antialias = antialias;
2016 - font->encoded = encoded;
2017 + font->charmap = charmap;
2026 - FT_Done_Face (font->face);
2027 + _XftFreeTypeCloseFile (file);
2031 @@ -368,10 +562,26 @@
2033 XftFreeTypeClose (Display *dpy, XftFontStruct *font)
2035 - XRenderFreeGlyphSet (dpy, font->glyphset);
2036 - if (font->realized)
2037 - free (font->realized);
2038 - FT_Done_Face (font->face);
2039 + XftFtGlyphSet *gs, **prev;
2041 + for (prev = &_XftFtGlyphSets; (gs = *prev); prev = &gs->next)
2043 + if (&gs->font == font)
2045 + if (--gs->ref == 0)
2047 + XRenderFreeGlyphSet (dpy, font->glyphset);
2048 + if (font->realized)
2049 + free (font->realized);
2051 + _XftFreeTypeCloseFile (gs->file);
2063 XftInitFtLibrary (void)
2070 @@ -396,16 +607,21 @@
2071 _XftFontSet = XftFontSetCreate ();
2074 + cache = XftConfigGetCache ();
2076 + XftFileCacheLoad (cache);
2077 for (d = XftConfigDirs; d && *d; d++)
2079 #ifdef XFT_DEBUG_FONTSET
2080 printf ("scan dir %s\n", *d);
2082 - XftDirScan (_XftFontSet, *d);
2083 + XftDirScan (_XftFontSet, *d, False);
2085 #ifdef XFT_DEBUG_FONTSET
2086 XftPrintFontSet (_XftFontSet);
2089 + XftFileCacheSave (cache);
2090 + XftFileCacheDispose ();
2094 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftglyphs.c xc/lib/Xft/xftglyphs.c
2095 --- XFree86-4.0.2.orig/xc/lib/Xft/xftglyphs.c Sat Dec 16 12:33:01 2000
2096 +++ XFree86-4.0.2/xc/lib/Xft/xftglyphs.c Fri Jan 19 20:25:58 2001
2099 - * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.6 2000/12/15 17:12:53 keithp Exp $
2100 + * $XFree86: xc/lib/Xft/xftglyphs.c,v 1.8 2000/12/22 02:25:41 keithp Exp $
2102 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2105 * PERFORMANCE OF THIS SOFTWARE.
2111 #include <freetype/ftoutln.h>
2116 + if (!XftFreeTypeSetFace (font->face, font->size, font->charmap))
2119 if (font->antialias && font->rgba)
2121 matrix.xx = 0x30000L;
2126 - if (font->encoded)
2127 + if (font->charmap != -1)
2129 glyphindex = FT_Get_Char_Index (font->face, charcode);
2132 + if (_XftFontDebug() & XFT_DBG_GLYPH)
2133 + printf ("glyph (%c) %d missing\n",
2134 + (int) charcode, (int) charcode);
2139 glyphindex = (FT_UInt) charcode;
2142 * Try to keep monospace fonts ink-inside
2144 - if (font->monospace)
2145 + if (font->spacing != XFT_PROPORTIONAL)
2147 if (TRUNC(right) > font->max_advance_width)
2149 @@ -192,39 +201,42 @@
2154 + if (_XftFontDebug() & XFT_DBG_GLYPH)
2157 - unsigned char *line;
2160 - printf ("\nchar 0x%x (%c):\n", (int) charcode, (char) charcode);
2161 - for (y = 0; y < height; y++)
2162 + printf ("char 0x%x (%c):\n", (int) charcode, (char) charcode);
2163 + if (_XftFontDebug() & XFT_DBG_GLYPHV)
2165 - if (font->antialias)
2167 - static char den[] = { " .:;=+*#" };
2168 - for (x = 0; x < pitch; x++)
2169 - printf ("%c", den[line[x] >> 5]);
2173 + unsigned char *line;
2176 + for (y = 0; y < height; y++)
2178 - for (x = 0; x < pitch * 8; x++)
2179 + if (font->antialias)
2181 - printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
2182 + static char den[] = { " .:;=+*#" };
2183 + for (x = 0; x < pitch; x++)
2184 + printf ("%c", den[line[x] >> 5]);
2188 + for (x = 0; x < pitch * 8; x++)
2190 + printf ("%c", line[x>>3] & (1 << (x & 7)) ? '#' : ' ');
2205 - printf ("glyph (%c) %d missing\n", (int) charcode, (int) charcode);
2207 + if (_XftFontDebug() & XFT_DBG_GLYPH)
2208 + printf ("glyph (%c) %d no outline\n",
2209 + (int) charcode, (int) charcode);
2214 gi->height = height;
2215 gi->x = -TRUNC(left);
2217 - if (font->monospace)
2218 + if (font->spacing != XFT_PROPORTIONAL)
2219 gi->xOff = font->max_advance_width;
2221 gi->xOff = TRUNC(ROUND(glyph->metrics.horiAdvance));
2222 @@ -368,7 +380,10 @@
2223 XftFontStruct *font,
2226 - if (font->encoded)
2227 + if (font->charmap != -1)
2229 + FT_Set_Charmap (font->face, font->face->charmaps[font->charmap]);
2230 glyph = (XftChar32) FT_Get_Char_Index (font->face, (FT_ULong) glyph);
2232 return glyph && glyph <= font->face->num_glyphs;
2234 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftgram.y xc/lib/Xft/xftgram.y
2235 --- XFree86-4.0.2.orig/xc/lib/Xft/xftgram.y Thu Nov 30 18:30:00 2000
2236 +++ XFree86-4.0.2/xc/lib/Xft/xftgram.y Fri Jan 19 20:25:58 2001
2239 - * $XFree86: xc/lib/Xft/xftgram.y,v 1.2 2000/11/30 23:30:00 dawes Exp $
2240 + * $XFree86: xc/lib/Xft/xftgram.y,v 1.3 2001/01/02 02:46:51 keithp Exp $
2242 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2245 %token <dval> DOUBLE
2246 %token <sval> STRING NAME
2247 %token <ival> ANY ALL
2248 -%token <ival> DIR INCLUDE INCLUDEIF MATCH EDIT TOK_TRUE TOK_FALSE TOK_NIL
2249 +%token <ival> DIR CACHE INCLUDE INCLUDEIF MATCH EDIT
2250 +%token <ival> TOK_TRUE TOK_FALSE TOK_NIL
2251 %token <ival> EQUAL SEMI
2257 { XftConfigAddDir ($2); }
2259 + { XftConfigSetCache ($2); }
2261 { XftConfigPushInput ($2, True); }
2263 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftint.h xc/lib/Xft/xftint.h
2264 --- XFree86-4.0.2.orig/xc/lib/Xft/xftint.h Sat Dec 16 12:33:01 2000
2265 +++ XFree86-4.0.2/xc/lib/Xft/xftint.h Fri Jan 19 20:25:58 2001
2268 - * $XFree86: xc/lib/Xft/xftint.h,v 1.15 2000/12/15 17:12:53 keithp Exp $
2269 + * $XFree86: xc/lib/Xft/xftint.h,v 1.20 2001/01/02 02:46:51 keithp Exp $
2271 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2274 #define XFT_DEFAULT_PATH "/usr/X11R6/lib/X11/XftConfig"
2277 +#define XFT_DBG_OPEN 1
2278 +#define XFT_DBG_OPENV 2
2279 +#define XFT_DBG_RENDER 4
2280 +#define XFT_DBG_DRAW 8
2281 +#define XFT_DBG_REF 16
2282 +#define XFT_DBG_GLYPH 32
2283 +#define XFT_DBG_GLYPHV 64
2284 +#define XFT_DBG_CACHE 128
2285 +#define XFT_DBG_CACHEV 256
2287 typedef enum _XftOp {
2288 XftOpInteger, XftOpDouble, XftOpString, XftOpBool, XftOpNil,
2290 @@ -191,11 +201,40 @@
2297 +XftFileCacheFind (char *file, int id, int *count);
2300 +XftFileCacheDispose (void);
2303 +XftFileCacheLoad (char *cache);
2306 +XftFileCacheUpdate (char *file, int id, char *name);
2309 +XftFileCacheSave (char *cache);
2312 +XftFileCacheReadDir (XftFontSet *set, const char *cache_file);
2315 +XftFileCacheWriteDir (XftFontSet *set, const char *cache_file);
2319 XftConfigAddDir (char *d);
2322 +XftConfigSetCache (char *c);
2325 +XftConfigGetCache (void);
2328 XftConfigAddEdit (XftTest *test, XftEdit *edit);
2331 @@ -217,6 +256,12 @@
2333 XChar2b xcloc[XFT_CORE_N16LOCAL]);
2336 +XftCoreConvertUtf8 (XftChar8 *string,
2338 + XChar2b xcloc[XFT_CORE_N16LOCAL],
2342 XftCoreExtents8 (Display *dpy,
2344 @@ -238,6 +283,13 @@
2346 XGlyphInfo *extents);
2349 +XftCoreExtentsUtf8 (Display *dpy,
2353 + XGlyphInfo *extents);
2356 XftCoreGlyphExists (Display *dpy,
2358 @@ -259,10 +311,6 @@
2360 XftSubstPrint (XftSubst *subst);
2364 -XftDirScan (XftFontSet *set, const char *dir);
2368 XftDefaultParseBool (char *v);
2369 @@ -295,12 +343,7 @@
2371 _XftFontDebug (void);
2373 -/* xftfreetype.c */
2375 -XftFreeTypeQuery (const char *file, int id, int *count);
2381 XftConfigparse (void);
2386 -XftInitFtLibrary (void);
2387 +XftInit (char *config);
2390 extern int XftConfigLineno;
2392 XftConfigPushInput (char *s, Bool complain);
2396 -_XftObjectSetVapBuild (const char *first, va_list *vap);
2399 XftListValueCompare (XftValue v1,
2401 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftlex.l xc/lib/Xft/xftlex.l
2402 --- XFree86-4.0.2.orig/xc/lib/Xft/xftlex.l Sat Dec 16 12:33:01 2000
2403 +++ XFree86-4.0.2/xc/lib/Xft/xftlex.l Fri Jan 19 20:25:58 2001
2407 - * $XFree86: xc/lib/Xft/xftlex.l,v 1.3 2000/12/15 22:48:39 dawes Exp $
2408 + * $XFree86: xc/lib/Xft/xftlex.l,v 1.4 2001/01/02 02:46:51 keithp Exp $
2410 * Copyright (c) 2000 Keith Packard, member of The XFree86 Project, Inc.
2413 "/\052" _XftConfigSkipComment();
2414 ^# _XftConfigSkipLine();
2416 +cache return CACHE;
2417 include return INCLUDE;
2418 includeif return INCLUDEIF;
2420 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftname.c xc/lib/Xft/xftname.c
2421 --- XFree86-4.0.2.orig/xc/lib/Xft/xftname.c Sat Dec 16 12:33:00 2000
2422 +++ XFree86-4.0.2/xc/lib/Xft/xftname.c Fri Jan 19 20:25:58 2001
2425 - * $XFree86: xc/lib/Xft/xftname.c,v 1.5 2000/12/14 23:03:56 keithp Exp $
2426 + * $XFree86: xc/lib/Xft/xftname.c,v 1.8 2001/01/02 02:46:51 keithp Exp $
2428 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2436 typedef struct _XftObjectType {
2441 -const XftObjectType _XftObjectTypes[] = {
2442 +static const XftObjectType _XftObjectTypes[] = {
2443 { XFT_FAMILY, XftTypeString, },
2444 { XFT_STYLE, XftTypeString, },
2445 { XFT_SLANT, XftTypeInteger, },
2447 { XFT_RGBA, XftTypeInteger, },
2448 { XFT_SCALE, XftTypeDouble, },
2449 { XFT_RENDER, XftTypeBool, },
2450 + { XFT_MINSPACE, XftTypeBool, },
2451 + { XFT_CHAR_WIDTH, XftTypeInteger },
2452 + { XFT_CHAR_HEIGHT, XftTypeInteger },
2455 #define NUM_OBJECT_TYPES (sizeof _XftObjectTypes / sizeof _XftObjectTypes[0])
2456 @@ -152,9 +156,17 @@
2460 - while (*cur && !strchr (delim, *cur))
2461 + while ((c = *cur))
2470 + else if (strchr (delim, c))
2476 @@ -211,10 +223,10 @@
2478 while (delim == ':')
2480 - name = _XftNameFindNext (name, "=-:", save, &delim);
2481 + name = _XftNameFindNext (name, "=_:", save, &delim);
2484 - if (delim == '=' || delim == '-')
2485 + if (delim == '=' || delim == '_')
2487 t = XftNameGetType (save);
2489 @@ -250,4 +262,118 @@
2496 +_XftNameUnparseString (const char *string, char *escape, char **destp, int *lenp)
2499 + char *dest = *destp;
2502 + while ((c = *string++))
2504 + if (escape && strchr (escape, c))
2508 + *dest++ = escape[0];
2520 +_XftNameUnparseValue (XftValue v, char *escape, char **destp, int *lenp)
2527 + case XftTypeInteger:
2528 + sprintf (temp, "%d", v.u.i);
2529 + return _XftNameUnparseString (temp, 0, destp, lenp);
2530 + case XftTypeDouble:
2531 + sprintf (temp, "%g", v.u.d);
2532 + return _XftNameUnparseString (temp, 0, destp, lenp);
2533 + case XftTypeString:
2534 + return _XftNameUnparseString (v.u.s, escape, destp, lenp);
2536 + return _XftNameUnparseString (v.u.b ? "True" : "False", 0, destp, lenp);
2542 +_XftNameUnparseValueList (XftValueList *v, char *escape, char **destp, int *lenp)
2546 + if (!_XftNameUnparseValue (v->value, escape, destp, lenp))
2548 + if ((v = v->next))
2549 + if (!_XftNameUnparseString (",", 0, destp, lenp))
2555 +#define XFT_ESCAPE_FIXED "\\-:,"
2556 +#define XFT_ESCAPE_VARIABLE "\\=_:,"
2559 +XftNameUnparse (XftPattern *pat, char *dest, int len)
2563 + const XftObjectType *o;
2565 + e = XftPatternFind (pat, XFT_FAMILY, False);
2568 + if (!_XftNameUnparseValueList (e->values, XFT_ESCAPE_FIXED,
2572 + e = XftPatternFind (pat, XFT_SIZE, False);
2575 + if (!_XftNameUnparseString ("-", 0, &dest, &len))
2577 + if (!_XftNameUnparseValueList (e->values, XFT_ESCAPE_FIXED, &dest, &len))
2580 + for (i = 0; i < NUM_OBJECT_TYPES; i++)
2582 + o = &_XftObjectTypes[i];
2583 + if (!strcmp (o->object, XFT_FAMILY) ||
2584 + !strcmp (o->object, XFT_SIZE) ||
2585 + !strcmp (o->object, XFT_FILE))
2588 + e = XftPatternFind (pat, o->object, False);
2591 + if (!_XftNameUnparseString (":", 0, &dest, &len))
2593 + if (!_XftNameUnparseString (o->object, XFT_ESCAPE_VARIABLE,
2596 + if (!_XftNameUnparseString ("=", 0, &dest, &len))
2598 + if (!_XftNameUnparseValueList (e->values, XFT_ESCAPE_VARIABLE,
2608 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftrender.c xc/lib/Xft/xftrender.c
2609 --- XFree86-4.0.2.orig/xc/lib/Xft/xftrender.c Fri Dec 8 02:51:28 2000
2610 +++ XFree86-4.0.2/xc/lib/Xft/xftrender.c Fri Jan 19 20:25:58 2001
2613 - * $XFree86: xc/lib/Xft/xftrender.c,v 1.5 2000/12/08 07:51:28 keithp Exp $
2614 + * $XFree86: xc/lib/Xft/xftrender.c,v 1.6 2000/12/20 00:28:45 keithp Exp $
2616 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2619 * PERFORMANCE OF THIS SOFTWARE.
2622 +#include <stdlib.h>
2630 +XftRenderStringUtf8 (Display *dpy, Picture src,
2631 + XftFontStruct *font, Picture dst,
2632 + int srcx, int srcy,
2634 + XftChar8 *string, int len)
2638 + XftChar32 lbuf[4096];
2647 + /* compute needed width */
2648 + if (!XftUtf8Len (string, len, &n, &width))
2652 + if (n * width > sizeof (lbuf))
2654 + d = (XftChar32 *) malloc (n * width);
2666 + clen = XftUtf8ToUcs4 (s, &c, rlen);
2667 + if (clen <= 0) /* malformed UTF8 string */
2674 + XftRenderString32 (dpy, src, font, dst, srcx, srcy, x, y,
2680 + dst16 = (XftChar16 *) d;
2683 + clen = XftUtf8ToUcs4 (s, &c, rlen);
2684 + if (clen <= 0) /* malformed UTF8 string */
2690 + dst16 = (XftChar16 *) d;
2691 + XftRenderString16 (dpy, src, font, dst, srcx, srcy, x, y,
2697 + dst8 = (XftChar8 *) d;
2700 + clen = XftUtf8ToUcs4 (s, &c, rlen);
2701 + if (clen <= 0) /* malformed UTF8 string */
2707 + dst8 = (XftChar8 *) d;
2708 + XftRenderString8 (dpy, src, font, dst, srcx, srcy, x, y,
2717 XftRenderExtents8 (Display *dpy,
2718 XftFontStruct *font,
2720 @@ -273,6 +361,89 @@
2724 + gi = c < font->nrealized ? font->realized[c] : 0;
2727 + if (gi->x + x < extents->x)
2728 + extents->x = gi->x + x;
2729 + if (gi->y + y < extents->y)
2730 + extents->y = gi->y + y;
2731 + if (gi->width + x > extents->width)
2732 + extents->width = gi->width + x;
2733 + if (gi->height + y > extents->height)
2734 + extents->height = gi->height + y;
2738 + extents->xOff = x;
2739 + extents->yOff = y;
2743 +XftRenderExtentsUtf8 (Display *dpy,
2744 + XftFontStruct *font,
2747 + XGlyphInfo *extents)
2749 + unsigned int missing[XFT_NMISSING];
2762 + clen = XftUtf8ToUcs4 (s, &c, l);
2765 + XftGlyphCheck (dpy, font, c, missing, &nmissing);
2770 + XftGlyphLoad (dpy, font, missing, nmissing);
2775 + clen = XftUtf8ToUcs4 (string, &c, len);
2783 + gi = c < font->nrealized ? font->realized[c] : 0;
2787 + if (len == 0 && !gi)
2789 + extents->width = 0;
2790 + extents->height = 0;
2793 + extents->yOff = 0;
2794 + extents->xOff = 0;
2802 + clen = XftUtf8ToUcs4 (string, &c, len);
2807 gi = c < font->nrealized ? font->realized[c] : 0;
2810 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftstr.c xc/lib/Xft/xftstr.c
2811 --- XFree86-4.0.2.orig/xc/lib/Xft/xftstr.c Sat Dec 16 12:33:00 2000
2812 +++ XFree86-4.0.2/xc/lib/Xft/xftstr.c Fri Jan 19 20:25:58 2001
2815 - * $XFree86: xc/lib/Xft/xftstr.c,v 1.2 2000/12/14 23:03:57 keithp Exp $
2816 + * $XFree86: xc/lib/Xft/xftstr.c,v 1.4 2000/12/20 10:24:27 keithp Exp $
2818 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2820 @@ -149,4 +149,108 @@
2823 return (int) c2 - (int) c1;
2827 +XftUtf8ToUcs4 (XftChar8 *src_orig,
2831 + XftChar8 *src = src_orig;
2847 + else if (!(s & 0x40))
2851 + else if (!(s & 0x20))
2853 + result = s & 0x1f;
2856 + else if (!(s & 0x10))
2861 + else if (!(s & 0x08))
2863 + result = s & 0x07;
2866 + else if (!(s & 0x04))
2868 + result = s & 0x03;
2871 + else if ( ! (s & 0x02))
2873 + result = s & 0x01;
2888 + if ((s & 0xc0) != 0x80)
2891 + result |= s & 0x3f;
2894 + return src - src_orig;
2898 +XftUtf8Len (XftChar8 *string,
2911 + clen = XftUtf8ToUcs4 (string, &c, len);
2912 + if (clen <= 0) /* malformed UTF8 string */
2916 + else if (c >= 0x100)
2929 diff -urN -x CVS xc-4.0.2.orig/lib/Xft/xftxlfd.c xc/lib/Xft/xftxlfd.c
2930 --- XFree86-4.0.2.orig/xc/lib/Xft/xftxlfd.c Sat Dec 16 12:33:00 2000
2931 +++ XFree86-4.0.2/xc/lib/Xft/xftxlfd.c Fri Jan 19 20:25:58 2001
2934 - * $XFree86: xc/lib/Xft/xftxlfd.c,v 1.5 2000/12/14 23:03:57 keithp Exp $
2935 + * $XFree86: xc/lib/Xft/xftxlfd.c,v 1.7 2000/12/22 05:05:16 tsi Exp $
2937 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
2939 @@ -208,9 +208,21 @@
2944 +typedef struct _XftCoreFont {
2945 + struct _XftCoreFont *next;
2948 + XFontStruct *font;
2953 +static XftCoreFont *_XftCoreFonts;
2956 XftCoreOpen (Display *dpy, XftPattern *pattern)
2960 char *xlfd_pixel = 0;
2962 @@ -258,9 +270,66 @@
2966 - ret = XLoadQueryFont (dpy, xlfd);
2967 + for (cf = _XftCoreFonts; cf; cf = cf->next)
2969 + if (cf->display == dpy &&
2970 + !_XftStrCmpIgnoreCase (cf->xlfd, xlfd))
2973 + if (_XftFontDebug () & XFT_DBG_REF)
2975 + printf ("Xlfd \"%s\" matches existing font (%d)\n",
2983 + ret = XLoadQueryFont (dpy, xlfd);
2987 + cf = (XftCoreFont *) malloc (sizeof (XftCoreFont) +
2988 + strlen (xlfd) + 1);
2991 + XFreeFont (dpy, ret);
2995 + if (_XftFontDebug () & XFT_DBG_REF)
2996 + printf ("Xlfd \"%s\" matches new font\n", xlfd);
2998 + cf->next = _XftCoreFonts;
2999 + _XftCoreFonts = cf;
3003 + cf->xlfd = (char *) (cf + 1);
3004 + strcpy (cf->xlfd, xlfd);
3013 +XftCoreClose (Display *dpy, XFontStruct *font)
3015 + XftCoreFont *cf, **prev;
3017 + for (prev = &_XftCoreFonts; (cf = *prev); prev = &cf->next)
3019 + if (cf->display == dpy && cf->font == font)
3021 + if (--cf->ref == 0)
3023 + XFreeFont (dpy, cf->font);