aboutsummaryrefslogtreecommitdiff
path: root/libXfont/src/fontfile
diff options
context:
space:
mode:
Diffstat (limited to 'libXfont/src/fontfile')
-rw-r--r--libXfont/src/fontfile/Makefile.am36
-rw-r--r--libXfont/src/fontfile/Makefile.in487
-rw-r--r--libXfont/src/fontfile/bitsource.c174
-rw-r--r--libXfont/src/fontfile/bufio.c206
-rw-r--r--libXfont/src/fontfile/bunzip2.c179
-rw-r--r--libXfont/src/fontfile/catalogue.c478
-rw-r--r--libXfont/src/fontfile/decompress.c410
-rw-r--r--libXfont/src/fontfile/defaults.c77
-rw-r--r--libXfont/src/fontfile/dirfile.c495
-rw-r--r--libXfont/src/fontfile/ffcheck.c188
-rw-r--r--libXfont/src/fontfile/fileio.c99
-rw-r--r--libXfont/src/fontfile/filewr.c65
-rw-r--r--libXfont/src/fontfile/fontdir.c833
-rw-r--r--libXfont/src/fontfile/fontencc.c77
-rw-r--r--libXfont/src/fontfile/fontfile.c1152
-rw-r--r--libXfont/src/fontfile/fontscale.c447
-rw-r--r--libXfont/src/fontfile/gunzip.c227
-rw-r--r--libXfont/src/fontfile/printerfont.c178
-rw-r--r--libXfont/src/fontfile/register.c124
-rw-r--r--libXfont/src/fontfile/renderers.c117
20 files changed, 6049 insertions, 0 deletions
diff --git a/libXfont/src/fontfile/Makefile.am b/libXfont/src/fontfile/Makefile.am
new file mode 100644
index 000000000..45d1dbaa4
--- /dev/null
+++ b/libXfont/src/fontfile/Makefile.am
@@ -0,0 +1,36 @@
+FONTENCDIR=@ENCODINGSDIR@
+FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTENCDIR)/encodings.dir\"
+
+INCLUDES = \
+ -I${top_srcdir}/include \
+ $(FONTENCDEFS)
+
+AM_CFLAGS = $(XFONT_CFLAGS) $(OS_CFLAGS) $(CWARNFLAGS)
+
+noinst_LTLIBRARIES = libfontfile.la
+
+libfontfile_la_LIBADD = \
+ $(Z_LIBS)
+
+libfontfile_la_SOURCES = \
+ bitsource.c \
+ bufio.c \
+ decompress.c \
+ defaults.c \
+ dirfile.c \
+ ffcheck.c \
+ fileio.c \
+ filewr.c \
+ fontdir.c \
+ fontencc.c \
+ fontfile.c \
+ fontscale.c \
+ gunzip.c \
+ printerfont.c \
+ register.c \
+ renderers.c \
+ catalogue.c
+
+if X_BZIP2_FONT_COMPRESSION
+libfontfile_la_SOURCES += bunzip2.c
+endif
diff --git a/libXfont/src/fontfile/Makefile.in b/libXfont/src/fontfile/Makefile.in
new file mode 100644
index 000000000..dca443eaa
--- /dev/null
+++ b/libXfont/src/fontfile/Makefile.in
@@ -0,0 +1,487 @@
+# Makefile.in generated by automake 1.10 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@X_BZIP2_FONT_COMPRESSION_TRUE@am__append_1 = bunzip2.c
+subdir = src/fontfile
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h \
+ $(top_builddir)/include/X11/fonts/fontconf.h
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libfontfile_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__libfontfile_la_SOURCES_DIST = bitsource.c bufio.c decompress.c \
+ defaults.c dirfile.c ffcheck.c fileio.c filewr.c fontdir.c \
+ fontencc.c fontfile.c fontscale.c gunzip.c printerfont.c \
+ register.c renderers.c catalogue.c bunzip2.c
+@X_BZIP2_FONT_COMPRESSION_TRUE@am__objects_1 = bunzip2.lo
+am_libfontfile_la_OBJECTS = bitsource.lo bufio.lo decompress.lo \
+ defaults.lo dirfile.lo ffcheck.lo fileio.lo filewr.lo \
+ fontdir.lo fontencc.lo fontfile.lo fontscale.lo gunzip.lo \
+ printerfont.lo register.lo renderers.lo catalogue.lo \
+ $(am__objects_1)
+libfontfile_la_OBJECTS = $(am_libfontfile_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(top_builddir) -I$(top_builddir)/include/X11/fonts@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libfontfile_la_SOURCES)
+DIST_SOURCES = $(am__libfontfile_la_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHANGELOG_CMD = @CHANGELOG_CMD@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CWARNFLAGS = @CWARNFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENCODINGSDIR = @ENCODINGSDIR@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+FREETYPE_REQUIRES = @FREETYPE_REQUIRES@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MATH_LIBS = @MATH_LIBS@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OS_CFLAGS = @OS_CFLAGS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XFONT_CFLAGS = @XFONT_CFLAGS@
+XFONT_LIBS = @XFONT_LIBS@
+X_GZIP_FONT_COMPRESSION = @X_GZIP_FONT_COMPRESSION@
+Z_LIBS = @Z_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+distcleancheck_listfiles = @distcleancheck_listfiles@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+FONTENCDIR = @ENCODINGSDIR@
+FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTENCDIR)/encodings.dir\"
+INCLUDES = \
+ -I${top_srcdir}/include \
+ $(FONTENCDEFS)
+
+AM_CFLAGS = $(XFONT_CFLAGS) $(OS_CFLAGS) $(CWARNFLAGS)
+noinst_LTLIBRARIES = libfontfile.la
+libfontfile_la_LIBADD = \
+ $(Z_LIBS)
+
+libfontfile_la_SOURCES = bitsource.c bufio.c decompress.c defaults.c \
+ dirfile.c ffcheck.c fileio.c filewr.c fontdir.c fontencc.c \
+ fontfile.c fontscale.c gunzip.c printerfont.c register.c \
+ renderers.c catalogue.c $(am__append_1)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/fontfile/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/fontfile/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libfontfile.la: $(libfontfile_la_OBJECTS) $(libfontfile_la_DEPENDENCIES)
+ $(LINK) $(libfontfile_la_OBJECTS) $(libfontfile_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitsource.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bufio.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bunzip2.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/catalogue.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/decompress.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defaults.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirfile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffcheck.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filewr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontdir.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontencc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontfile.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontscale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gunzip.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printerfont.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/register.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/renderers.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/libXfont/src/fontfile/bitsource.c b/libXfont/src/fontfile/bitsource.c
new file mode 100644
index 000000000..ae27de8fe
--- /dev/null
+++ b/libXfont/src/fontfile/bitsource.c
@@ -0,0 +1,174 @@
+/* $Xorg: bitsource.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/bitsource.c,v 1.3 2001/01/17 19:43:29 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+
+BitmapSourcesRec FontFileBitmapSources;
+
+Bool
+FontFileRegisterBitmapSource (FontPathElementPtr fpe)
+{
+ FontPathElementPtr *new;
+ int i;
+ int newsize;
+
+ for (i = 0; i < FontFileBitmapSources.count; i++)
+ if (FontFileBitmapSources.fpe[i] == fpe)
+ return TRUE;
+ if (FontFileBitmapSources.count == FontFileBitmapSources.size)
+ {
+ newsize = FontFileBitmapSources.size + 4;
+ new = (FontPathElementPtr *) xrealloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
+ if (!new)
+ return FALSE;
+ FontFileBitmapSources.size = newsize;
+ FontFileBitmapSources.fpe = new;
+ }
+ FontFileBitmapSources.fpe[FontFileBitmapSources.count++] = fpe;
+ return TRUE;
+}
+
+void
+FontFileUnregisterBitmapSource (FontPathElementPtr fpe)
+{
+ int i;
+
+ for (i = 0; i < FontFileBitmapSources.count; i++)
+ if (FontFileBitmapSources.fpe[i] == fpe)
+ {
+ FontFileBitmapSources.count--;
+ if (FontFileBitmapSources.count == 0)
+ {
+ FontFileBitmapSources.size = 0;
+ xfree (FontFileBitmapSources.fpe);
+ FontFileBitmapSources.fpe = 0;
+ }
+ else
+ {
+ for (; i < FontFileBitmapSources.count; i++)
+ FontFileBitmapSources.fpe[i] = FontFileBitmapSources.fpe[i+1];
+ }
+ break;
+ }
+}
+
+/*
+ * Our set_path_hook: unregister all bitmap sources.
+ * This is necessary because already open fonts will keep their FPEs
+ * allocated, but they may not be on the new font path.
+ * The bitmap sources in the new path will be registered by the init_func.
+ */
+void
+FontFileEmptyBitmapSource(void)
+{
+ if (FontFileBitmapSources.count == 0)
+ return;
+
+ FontFileBitmapSources.count = 0;
+ FontFileBitmapSources.size = 0;
+ xfree (FontFileBitmapSources.fpe);
+ FontFileBitmapSources.fpe = 0;
+}
+
+int
+FontFileMatchBitmapSource (FontPathElementPtr fpe,
+ FontPtr *pFont,
+ int flags,
+ FontEntryPtr entry,
+ FontNamePtr zeroPat,
+ FontScalablePtr vals,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ Bool noSpecificSize)
+{
+ int source;
+ FontEntryPtr zero;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ FontDirectoryPtr dir;
+ FontScaledPtr scaled;
+
+ /*
+ * Look through all the registered bitmap sources for
+ * the same zero name as ours; entries along that one
+ * can be scaled as desired.
+ */
+ ret = BadFontName;
+ for (source = 0; source < FontFileBitmapSources.count; source++)
+ {
+ if (FontFileBitmapSources.fpe[source] == fpe)
+ continue;
+ dir = (FontDirectoryPtr) FontFileBitmapSources.fpe[source]->private;
+ zero = FontFileFindNameInDir (&dir->scalable, zeroPat);
+ if (!zero)
+ continue;
+ scaled = FontFileFindScaledInstance (zero, vals, noSpecificSize);
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFont = scaled->pFont;
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmap (
+ FontFileBitmapSources.fpe[source],
+ pFont, flags, entry, format, fmask);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = FontFileBitmapSources.fpe[source];
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ break;
+ }
+ }
+ return ret;
+}
diff --git a/libXfont/src/fontfile/bufio.c b/libXfont/src/fontfile/bufio.c
new file mode 100644
index 000000000..a5746e3bd
--- /dev/null
+++ b/libXfont/src/fontfile/bufio.c
@@ -0,0 +1,206 @@
+/* $Xorg: bufio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/bufio.c,v 3.9 2001/12/14 19:56:50 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xos.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+#include <errno.h>
+
+BufFilePtr
+BufFileCreate (char *private,
+ int (*input)(BufFilePtr),
+ int (*output)(int, BufFilePtr),
+ int (*skip)(BufFilePtr, int),
+ int (*close)(BufFilePtr, int))
+{
+ BufFilePtr f;
+
+ f = (BufFilePtr) xalloc (sizeof *f);
+ if (!f)
+ return 0;
+ f->private = private;
+ f->bufp = f->buffer;
+ f->left = 0;
+ f->input = input;
+ f->output = output;
+ f->skip = skip;
+ f->eof = 0;
+ f->close = close;
+ return f;
+}
+
+#define FileDes(f) ((int)(long) (f)->private)
+
+static int
+BufFileRawFill (BufFilePtr f)
+{
+ int left;
+
+ left = read (FileDes(f), (char *)f->buffer, BUFFILESIZE);
+ if (left <= 0) {
+ f->left = 0;
+ return BUFFILEEOF;
+ }
+ f->left = left - 1;
+ f->bufp = f->buffer + 1;
+ return f->buffer[0];
+}
+
+static int
+BufFileRawSkip (BufFilePtr f, int count)
+{
+ int curoff;
+ int fileoff;
+ int todo;
+
+ curoff = f->bufp - f->buffer;
+ fileoff = curoff + f->left;
+ if (curoff + count <= fileoff) {
+ f->bufp += count;
+ f->left -= count;
+ } else {
+ todo = count - (fileoff - curoff);
+ if (lseek (FileDes(f), todo, 1) == -1) {
+ if (errno != ESPIPE)
+ return BUFFILEEOF;
+ while (todo) {
+ curoff = BUFFILESIZE;
+ if (curoff > todo)
+ curoff = todo;
+ fileoff = read (FileDes(f), (char *)f->buffer, curoff);
+ if (fileoff <= 0)
+ return BUFFILEEOF;
+ todo -= fileoff;
+ }
+ }
+ f->left = 0;
+ }
+ return count;
+}
+
+static int
+BufFileRawClose (BufFilePtr f, int doClose)
+{
+ if (doClose)
+ close (FileDes (f));
+ return 1;
+}
+
+BufFilePtr
+BufFileOpenRead (int fd)
+{
+#if defined(__UNIXOS2__) || defined (WIN32)
+ /* hv: I'd bet WIN32 has the same effect here */
+ setmode(fd,O_BINARY);
+#endif
+ return BufFileCreate ((char *)(long) fd, BufFileRawFill, 0, BufFileRawSkip, BufFileRawClose);
+}
+
+static int
+BufFileRawFlush (int c, BufFilePtr f)
+{
+ int cnt;
+
+ if (c != BUFFILEEOF)
+ *f->bufp++ = c;
+ cnt = f->bufp - f->buffer;
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ if (write (FileDes(f), (char *)f->buffer, cnt) != cnt)
+ return BUFFILEEOF;
+ return c;
+}
+
+static int
+BufFileFlush (BufFilePtr f, int doClose)
+{
+ if (f->bufp != f->buffer)
+ return (*f->output) (BUFFILEEOF, f);
+ return 0;
+}
+
+BufFilePtr
+BufFileOpenWrite (int fd)
+{
+ BufFilePtr f;
+
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* hv: I'd bet WIN32 has the same effect here */
+ setmode(fd,O_BINARY);
+#endif
+ f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
+ f->bufp = f->buffer;
+ f->left = BUFFILESIZE;
+ return f;
+}
+
+int
+BufFileRead (BufFilePtr f, char *b, int n)
+{
+ int c, cnt;
+ cnt = n;
+ while (cnt--) {
+ c = BufFileGet (f);
+ if (c == BUFFILEEOF)
+ break;
+ *b++ = c;
+ }
+ return n - cnt - 1;
+}
+
+int
+BufFileWrite (BufFilePtr f, char *b, int n)
+{
+ int cnt;
+ cnt = n;
+ while (cnt--) {
+ if (BufFilePut (*b++, f) == BUFFILEEOF)
+ return BUFFILEEOF;
+ }
+ return n;
+}
+
+int
+BufFileClose (BufFilePtr f, int doClose)
+{
+ int ret;
+ ret = (*f->close) (f, doClose);
+ xfree (f);
+ return ret;
+}
diff --git a/libXfont/src/fontfile/bunzip2.c b/libXfont/src/fontfile/bunzip2.c
new file mode 100644
index 000000000..9964de6e9
--- /dev/null
+++ b/libXfont/src/fontfile/bunzip2.c
@@ -0,0 +1,179 @@
+/* Based on src/fontfile/gunzip.c
+ written by Mark Eichin <eichin@kitten.gen.ma.us> September 1996.
+ intended for inclusion in X11 public releases. */
+
+/* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+
+#include "config.h"
+
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+#include <bzlib.h>
+
+typedef struct _xzip_buf {
+ bz_stream z;
+ int zstat;
+ BufChar b[BUFFILESIZE];
+ BufChar b_in[BUFFILESIZE];
+ BufFilePtr f;
+} xzip_buf;
+
+static int BufBzip2FileClose ( BufFilePtr f, int flag );
+static int BufBzip2FileFill ( BufFilePtr f );
+static int BufBzip2FileSkip ( BufFilePtr f, int c );
+
+_X_HIDDEN BufFilePtr
+BufFilePushBZIP2 (BufFilePtr f)
+{
+ xzip_buf *x;
+
+ x = (xzip_buf *) xalloc (sizeof (xzip_buf));
+ if (!x) return NULL;
+
+ bzero(&(x->z), sizeof(bz_stream));
+ x->f = f;
+
+ x->zstat = BZ2_bzDecompressInit(&(x->z),
+ 0, /* verbosity: 0 silent, 4 max */
+ 0); /* 0: go faster, 1: use less memory */
+ if (x->zstat != BZ_OK) {
+ xfree(x);
+ return NULL;
+ }
+
+ /* now that the history buffer is allocated, we provide the data buffer */
+ x->z.next_out = (char *) x->b;
+ x->z.avail_out = BUFFILESIZE;
+ x->z.next_in = (char *) x->b_in;
+ x->z.avail_in = 0;
+
+ return BufFileCreate((char *)x,
+ BufBzip2FileFill,
+ NULL,
+ BufBzip2FileSkip,
+ BufBzip2FileClose);
+}
+
+static int
+BufBzip2FileClose(BufFilePtr f, int flag)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+ BZ2_bzDecompressEnd (&(x->z));
+ BufFileClose (x->f, flag);
+ xfree (x);
+ return 1;
+}
+
+/* here's the real work.
+ -- we need to put stuff in f.buffer, update f.left and f.bufp,
+ then return the first byte (or BUFFILEEOF).
+ -- to do this, we need to get stuff into avail_in, and next_in,
+ and call BZ2_bzDecompress appropriately.
+ -- we may also need to add CRC maintenance - if BZ2_bzDecompress tells us
+ BZ_STREAM_END, we then have 4bytes CRC and 4bytes length...
+*/
+static int
+BufBzip2FileFill (BufFilePtr f)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+
+ /* we only get called when left == 0... */
+ /* but just in case, deal */
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ }
+ /* did we run out last time? */
+ switch (x->zstat) {
+ case BZ_OK:
+ break;
+ case BZ_STREAM_END:
+ case BZ_DATA_ERROR:
+ case BZ_DATA_ERROR_MAGIC:
+ f->left = 0;
+ return BUFFILEEOF;
+ default:
+ return BUFFILEEOF;
+ }
+ /* now we work to consume what we can */
+ /* let libbz2 know what we can handle */
+ x->z.next_out = (char *) x->b;
+ x->z.avail_out = BUFFILESIZE;
+
+ /* and try to consume all of it */
+ while (x->z.avail_out > 0) {
+ /* if we don't have anything to work from... */
+ if (x->z.avail_in == 0) {
+ /* ... fill the z buf from underlying file */
+ int i, c;
+ for (i = 0; i < sizeof(x->b_in); i++) {
+ c = BufFileGet(x->f);
+ if (c == BUFFILEEOF) break;
+ x->b_in[i] = c;
+ }
+ x->z.avail_in += i;
+ x->z.next_in = (char *) x->b_in;
+ }
+ /* so now we have some output space and some input data */
+ x->zstat = BZ2_bzDecompress(&(x->z));
+ /* the inflation output happens in the f buffer directly... */
+ if (x->zstat == BZ_STREAM_END) {
+ /* deal with EOF, crc */
+ break;
+ }
+ if (x->zstat != BZ_OK) {
+ break;
+ }
+ }
+ f->bufp = x->b;
+ f->left = BUFFILESIZE - x->z.avail_out;
+
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ } else {
+ return BUFFILEEOF;
+ }
+}
+
+/* there should be a BufCommonSkip... */
+static int
+BufBzip2FileSkip (BufFilePtr f, int c)
+{
+ /* BufFileRawSkip returns the count unchanged.
+ BufCompressedSkip returns 0.
+ That means it probably never gets called... */
+ int retval = c;
+ while(c--) {
+ int get = BufFileGet(f);
+ if (get == BUFFILEEOF) return get;
+ }
+ return retval;
+}
diff --git a/libXfont/src/fontfile/catalogue.c b/libXfont/src/fontfile/catalogue.c
new file mode 100644
index 000000000..d49423617
--- /dev/null
+++ b/libXfont/src/fontfile/catalogue.c
@@ -0,0 +1,478 @@
+/*
+ * Copyright © 2007 Red Hat, Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Kristian Høgsberg <krh@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <unistd.h>
+
+static const char CataloguePrefix[] = "catalogue:";
+
+static int CatalogueFreeFPE (FontPathElementPtr fpe);
+
+static int
+CatalogueNameCheck (char *name)
+{
+ return strncmp(name, CataloguePrefix, sizeof(CataloguePrefix) - 1) == 0;
+}
+
+typedef struct _CatalogueRec {
+ time_t mtime;
+ int fpeCount, fpeAlloc;
+ FontPathElementPtr *fpeList;
+} CatalogueRec, *CataloguePtr;
+
+static int
+CatalogueAddFPE (CataloguePtr cat, FontPathElementPtr fpe)
+{
+ FontPathElementPtr *new;
+
+ if (cat->fpeCount >= cat->fpeAlloc)
+ {
+ if (cat->fpeAlloc == 0)
+ cat->fpeAlloc = 16;
+ else
+ cat->fpeAlloc *= 2;
+
+ new = xrealloc(cat->fpeList,
+ cat->fpeAlloc * sizeof(FontPathElementPtr));
+ if (new == NULL)
+ return AllocError;
+
+ cat->fpeList = new;
+ }
+
+ cat->fpeList[cat->fpeCount++] = fpe;
+
+ return Successful;
+}
+
+static const char PriorityAttribute[] = "pri=";
+
+static int
+ComparePriority(const void *p1, const void *p2)
+{
+ FontDirectoryPtr dir1 = (*(FontPathElementPtr*) p1)->private;
+ FontDirectoryPtr dir2 = (*(FontPathElementPtr*) p2)->private;
+ const char *pri1 = NULL;
+ const char *pri2 = NULL;
+
+ if (dir1->attributes != NULL)
+ pri1 = strstr(dir1->attributes, PriorityAttribute);
+ if (dir2->attributes != NULL)
+ pri2 = strstr(dir2->attributes, PriorityAttribute);
+
+ if (pri1 == NULL && pri2 == NULL)
+ return 0;
+ else if (pri1 == NULL)
+ return 1;
+ else if (pri2 == NULL)
+ return -1;
+ else
+ return
+ atoi(pri1 + strlen(PriorityAttribute)) -
+ atoi(pri2 + strlen(PriorityAttribute));
+}
+
+static void
+CatalogueUnrefFPEs (FontPathElementPtr fpe)
+{
+ CataloguePtr cat = fpe->private;
+ FontPathElementPtr subfpe;
+ int i;
+
+ for (i = 0; i < cat->fpeCount; i++)
+ {
+ subfpe = cat->fpeList[i];
+ subfpe->refcount--;
+ if (subfpe->refcount == 0)
+ {
+ FontFileFreeFPE (subfpe);
+ xfree(subfpe->name);
+ xfree(subfpe);
+ }
+ }
+
+ cat->fpeCount = 0;
+}
+
+/* Rescan catalogue directory if modified timestamp has changed or
+ * the forceScan argument says to do it anyway (like on first load). */
+static int
+CatalogueRescan (FontPathElementPtr fpe, Bool forceScan)
+{
+ CataloguePtr cat = fpe->private;
+ char link[MAXFONTFILENAMELEN];
+ char dest[MAXFONTFILENAMELEN];
+ char *attrib;
+ FontPathElementPtr subfpe;
+ struct stat statbuf;
+ const char *path;
+ DIR *dir;
+ struct dirent *entry;
+ int len;
+ int pathlen;
+
+ path = fpe->name + strlen(CataloguePrefix);
+ if (stat(path, &statbuf) < 0 || !S_ISDIR(statbuf.st_mode))
+ return BadFontPath;
+
+ if ((forceScan == FALSE) && (statbuf.st_mtime <= cat->mtime))
+ return Successful;
+
+ dir = opendir(path);
+ if (dir == NULL)
+ {
+ xfree(cat);
+ return BadFontPath;
+ }
+
+ CatalogueUnrefFPEs (fpe);
+ while (entry = readdir(dir), entry != NULL)
+ {
+ snprintf(link, sizeof link, "%s/%s", path, entry->d_name);
+ len = readlink(link, dest, sizeof dest - 1);
+ if (len < 0)
+ continue;
+
+ dest[len] = '\0';
+
+ if (dest[0] != '/')
+ {
+ pathlen = strlen(path);
+ memmove(dest + pathlen + 1, dest, sizeof dest - pathlen - 1);
+ memcpy(dest, path, pathlen);
+ memcpy(dest + pathlen, "/", 1);
+ len += pathlen + 1;
+ }
+
+ attrib = strchr(link, ':');
+ if (attrib && len + strlen(attrib) < sizeof dest)
+ {
+ memcpy(dest + len, attrib, strlen(attrib));
+ len += strlen(attrib);
+ }
+
+ subfpe = xalloc(sizeof *subfpe);
+ if (subfpe == NULL)
+ continue;
+
+ /* The fonts returned by OpenFont will point back to the
+ * subfpe they come from. So set the type of the subfpe to
+ * what the catalogue fpe was assigned, so calls to CloseFont
+ * (which uses font->fpe->type) goes to CatalogueCloseFont. */
+ subfpe->type = fpe->type;
+ subfpe->name_length = len;
+ subfpe->name = xalloc (len + 1);
+ if (subfpe == NULL)
+ {
+ xfree(subfpe);
+ continue;
+ }
+
+ memcpy(subfpe->name, dest, len);
+ subfpe->name[len] = '\0';
+
+ /* The X server will manipulate the subfpe ref counts
+ * associated with the font in OpenFont and CloseFont, so we
+ * have to make sure it's valid. */
+ subfpe->refcount = 1;
+
+ if (FontFileInitFPE (subfpe) != Successful)
+ {
+ xfree(subfpe->name);
+ xfree(subfpe);
+ continue;
+ }
+
+ if (CatalogueAddFPE(cat, subfpe) != Successful)
+ {
+ FontFileFreeFPE (subfpe);
+ xfree(subfpe);
+ continue;
+ }
+ }
+
+ closedir(dir);
+
+ qsort(cat->fpeList,
+ cat->fpeCount, sizeof cat->fpeList[0], ComparePriority);
+
+ cat->mtime = statbuf.st_mtime;
+
+ return Successful;
+}
+
+static int
+CatalogueInitFPE (FontPathElementPtr fpe)
+{
+ CataloguePtr cat;
+
+ cat = (CataloguePtr) xalloc(sizeof *cat);
+ if (cat == NULL)
+ return AllocError;
+
+ fpe->private = (pointer) cat;
+ cat->fpeCount = 0;
+ cat->fpeAlloc = 0;
+ cat->fpeList = NULL;
+ cat->mtime = 0;
+
+ return CatalogueRescan (fpe, TRUE);
+}
+
+static int
+CatalogueResetFPE (FontPathElementPtr fpe)
+{
+ /* Always just tell the caller to close and re-open */
+ return FPEResetFailed;
+}
+
+static int
+CatalogueFreeFPE (FontPathElementPtr fpe)
+{
+ CataloguePtr cat = fpe->private;
+
+ /* If the catalogue is modified while the xserver has fonts open
+ * from the previous subfpes, we'll unref the old subfpes when we
+ * reload the catalogue, and the xserver will the call FreeFPE on
+ * them once it drops its last reference. Thus, the FreeFPE call
+ * for the subfpe ends up here and we just forward it to
+ * FontFileFreeFPE. */
+
+ if (!CatalogueNameCheck (fpe->name))
+ return FontFileFreeFPE (fpe);
+
+ CatalogueUnrefFPEs (fpe);
+ xfree(cat->fpeList);
+ xfree(cat);
+
+ return Successful;
+}
+
+static int
+CatalogueOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ CataloguePtr cat = fpe->private;
+ FontPathElementPtr subfpe;
+ FontDirectoryPtr dir;
+ int i, status;
+
+ CatalogueRescan (fpe, FALSE);
+
+ for (i = 0; i < cat->fpeCount; i++)
+ {
+ subfpe = cat->fpeList[i];
+ dir = subfpe->private;
+ status = FontFileOpenFont(client, subfpe, flags,
+ name, namelen, format, fmask, id,
+ pFont, aliasName, non_cachable_font);
+ if (status == Successful || status == FontNameAlias)
+ return status;
+ }
+
+ return BadFontName;
+}
+
+static void
+CatalogueCloseFont (FontPathElementPtr fpe, FontPtr pFont)
+{
+ /* Note: this gets called with the actual subfpe where we found
+ * the font, not the catalogue fpe. */
+
+ FontFileCloseFont(fpe, pFont);
+}
+
+static int
+CatalogueListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
+{
+ CataloguePtr cat = fpe->private;
+ FontPathElementPtr subfpe;
+ FontDirectoryPtr dir;
+ int i;
+
+ CatalogueRescan (fpe, FALSE);
+
+ for (i = 0; i < cat->fpeCount; i++)
+ {
+ subfpe = cat->fpeList[i];
+ dir = subfpe->private;
+ FontFileListFonts(client, subfpe, pat, len, max, names);
+ }
+
+ return Successful;
+}
+
+int
+FontFileStartListFonts(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep, int mark_aliases);
+
+typedef struct _LFWIData {
+ pointer *privates;
+ int current;
+} LFWIDataRec, *LFWIDataPtr;
+
+static int
+CatalogueStartListFonts(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, pointer *privatep,
+ int mark_aliases)
+{
+ CataloguePtr cat = fpe->private;
+ LFWIDataPtr data;
+ int ret, i, j;
+
+ CatalogueRescan (fpe, FALSE);
+
+ data = (LFWIDataPtr) xalloc (sizeof *data +
+ sizeof data->privates[0] * cat->fpeCount);
+ if (!data)
+ return AllocError;
+ data->privates = (pointer *) (data + 1);
+
+ for (i = 0; i < cat->fpeCount; i++)
+ {
+ ret = FontFileStartListFonts(client, cat->fpeList[i], pat, len,
+ max, &data->privates[i], mark_aliases);
+ if (ret != Successful)
+ goto bail;
+ }
+
+ data->current = 0;
+ *privatep = (pointer) data;
+ return Successful;
+
+ bail:
+ for (j = 0; j < i; j++)
+ /* FIXME: we have no way to free the per-fpe privates. */;
+ xfree (data);
+
+ return AllocError;
+}
+
+static int
+CatalogueStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 0);
+}
+
+static int
+CatalogueListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ LFWIDataPtr data = private;
+ CataloguePtr cat = fpe->private;
+ int ret;
+
+ if (data->current == cat->fpeCount)
+ {
+ xfree(data);
+ return BadFontName;
+ }
+
+ ret = FontFileListNextFontWithInfo(client, cat->fpeList[data->current],
+ namep, namelenp,
+ pFontInfo, numFonts,
+ data->privates[data->current]);
+ if (ret == BadFontName)
+ {
+ data->current++;
+ return CatalogueListNextFontWithInfo(client, fpe, namep, namelenp,
+ pFontInfo, numFonts, private);
+ }
+
+ return ret;
+}
+
+static int
+CatalogueStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 1);
+}
+
+static int
+CatalogueListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp, char **resolvedp,
+ int *resolvedlenp, pointer private)
+{
+ LFWIDataPtr data = private;
+ CataloguePtr cat = fpe->private;
+ int ret;
+
+ if (data->current == cat->fpeCount)
+ {
+ xfree(data);
+ return BadFontName;
+ }
+
+ ret = FontFileListNextFontOrAlias(client, cat->fpeList[data->current],
+ namep, namelenp,
+ resolvedp, resolvedlenp,
+ data->privates[data->current]);
+ if (ret == BadFontName)
+ {
+ data->current++;
+ return CatalogueListNextFontOrAlias(client, fpe, namep, namelenp,
+ resolvedp, resolvedlenp, private);
+ }
+
+ return ret;
+}
+
+void
+CatalogueRegisterLocalFpeFunctions (void)
+{
+ RegisterFPEFunctions(CatalogueNameCheck,
+ CatalogueInitFPE,
+ CatalogueFreeFPE,
+ CatalogueResetFPE,
+ CatalogueOpenFont,
+ CatalogueCloseFont,
+ CatalogueListFonts,
+ CatalogueStartListFontsWithInfo,
+ CatalogueListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ CatalogueStartListFontsAndAliases,
+ CatalogueListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/libXfont/src/fontfile/decompress.c b/libXfont/src/fontfile/decompress.c
new file mode 100644
index 000000000..a4c546871
--- /dev/null
+++ b/libXfont/src/fontfile/decompress.c
@@ -0,0 +1,410 @@
+/* $Xorg: decompress.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+/*
+ * Copyright 1985, 1986 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * James A. Woods, derived from original work by Spencer Thomas
+ * and Joseph Orost.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/decompress.c,v 1.4 2001/01/17 19:43:29 dawes Exp $ */
+/*
+ * decompress - cat a compressed file
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+
+#define BITS 16
+
+/*
+ * a code_int must be able to hold 2**BITS values of type int, and also -1
+ */
+#if BITS > 15
+typedef long int code_int;
+#else
+typedef int code_int;
+#endif
+
+typedef long int count_int;
+
+#ifdef NO_UCHAR
+ typedef char char_type;
+#else
+ typedef unsigned char char_type;
+#endif /* UCHAR */
+
+static char_type magic_header[] = { "\037\235" }; /* 1F 9D */
+
+/* Defines for third byte of header */
+#define BIT_MASK 0x1f
+#define BLOCK_MASK 0x80
+/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
+ a fourth header byte (for expansion).
+*/
+
+#define INIT_BITS 9 /* initial number of bits/code */
+
+#ifdef COMPATIBLE /* But wrong! */
+# define MAXCODE(n_bits) (1 << (n_bits) - 1)
+#else
+# define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
+#endif /* COMPATIBLE */
+
+/*
+ * the next two codes should not be changed lightly, as they must not
+ * lie within the contiguous general code space.
+ */
+#define FIRST 257 /* first free entry */
+#define CLEAR 256 /* table clear output code */
+
+#define STACK_SIZE 8192
+
+typedef struct _compressedFILE {
+ BufFilePtr file;
+
+ char_type *stackp;
+ code_int oldcode;
+ char_type finchar;
+
+ int block_compress;
+ int maxbits;
+ code_int maxcode, maxmaxcode;
+
+ code_int free_ent;
+ int clear_flg;
+ int n_bits;
+
+ /* bit buffer */
+ int offset, size;
+ char_type buf[BITS];
+
+ char_type de_stack[STACK_SIZE];
+ char_type *tab_suffix;
+ unsigned short *tab_prefix;
+} CompressedFile;
+
+
+static int hsize_table[] = {
+ 5003, /* 12 bits - 80% occupancy */
+ 9001, /* 13 bits - 91% occupancy */
+ 18013, /* 14 bits - 91% occupancy */
+ 35023, /* 15 bits - 94% occupancy */
+ 69001 /* 16 bits - 95% occupancy */
+};
+
+static int BufCompressedClose ( BufFilePtr f, int doClose );
+static int BufCompressedFill ( BufFilePtr f );
+static code_int getcode ( CompressedFile *file );
+static int BufCompressedSkip ( BufFilePtr f, int bytes );
+
+BufFilePtr
+BufFilePushCompressed (BufFilePtr f)
+{
+ int code;
+ int maxbits;
+ int hsize;
+ CompressedFile *file;
+ int extra;
+
+ if ((BufFileGet(f) != (magic_header[0] & 0xFF)) ||
+ (BufFileGet(f) != (magic_header[1] & 0xFF)))
+ {
+ return 0;
+ }
+ code = BufFileGet (f);
+ if (code == BUFFILEEOF) return 0;
+
+ maxbits = code & BIT_MASK;
+ if (maxbits > BITS || maxbits < 12)
+ return 0;
+ hsize = hsize_table[maxbits - 12];
+ extra = (1 << maxbits) * sizeof (char_type) +
+ hsize * sizeof (unsigned short);
+ file = (CompressedFile *) xalloc (sizeof (CompressedFile) + extra);
+ if (!file)
+ return 0;
+ file->file = f;
+ file->maxbits = maxbits;
+ file->block_compress = code & BLOCK_MASK;
+ file->maxmaxcode = 1 << file->maxbits;
+ file->tab_suffix = (char_type *) &file[1];
+ file->tab_prefix = (unsigned short *) (file->tab_suffix + file->maxmaxcode);
+ /*
+ * As above, initialize the first 256 entries in the table.
+ */
+ file->maxcode = MAXCODE(file->n_bits = INIT_BITS);
+ for ( code = 255; code >= 0; code-- ) {
+ file->tab_prefix[code] = 0;
+ file->tab_suffix[code] = (char_type) code;
+ }
+ file->free_ent = ((file->block_compress) ? FIRST : 256 );
+ file->clear_flg = 0;
+ file->offset = 0;
+ file->size = 0;
+ file->stackp = file->de_stack;
+ bzero(file->buf, BITS);
+ file->finchar = file->oldcode = getcode (file);
+ if (file->oldcode != -1)
+ *file->stackp++ = file->finchar;
+ return BufFileCreate ((char *) file,
+ BufCompressedFill,
+ 0,
+ BufCompressedSkip,
+ BufCompressedClose);
+}
+
+static int
+BufCompressedClose (BufFilePtr f, int doClose)
+{
+ CompressedFile *file;
+ BufFilePtr raw;
+
+ file = (CompressedFile *) f->private;
+ raw = file->file;
+ xfree (file);
+ BufFileClose (raw, doClose);
+ return 1;
+}
+
+static int
+BufCompressedFill (BufFilePtr f)
+{
+ CompressedFile *file;
+ register char_type *stackp, *de_stack;
+ register char_type finchar;
+ register code_int code, oldcode, incode;
+ BufChar *buf, *bufend;
+
+ file = (CompressedFile *) f->private;
+
+ buf = f->buffer;
+ bufend = buf + BUFFILESIZE;
+ stackp = file->stackp;
+ de_stack = file->de_stack;
+ finchar = file->finchar;
+ oldcode = file->oldcode;
+ while (buf < bufend) {
+ while (stackp > de_stack && buf < bufend)
+ *buf++ = *--stackp;
+
+ if (buf == bufend)
+ break;
+
+ if (oldcode == -1)
+ break;
+
+ code = getcode (file);
+ if (code == -1)
+ break;
+
+ if ( (code == CLEAR) && file->block_compress ) {
+ for ( code = 255; code >= 0; code-- )
+ file->tab_prefix[code] = 0;
+ file->clear_flg = 1;
+ file->free_ent = FIRST - 1;
+ if ( (code = getcode (file)) == -1 ) /* O, untimely death! */
+ break;
+ }
+ incode = code;
+ /*
+ * Special case for KwKwK string.
+ */
+ if ( code >= file->free_ent ) {
+ *stackp++ = finchar;
+ code = oldcode;
+ }
+
+ /*
+ * Generate output characters in reverse order
+ */
+ while ( code >= 256 )
+ {
+ *stackp++ = file->tab_suffix[code];
+ code = file->tab_prefix[code];
+ }
+ finchar = file->tab_suffix[code];
+ *stackp++ = finchar;
+
+ /*
+ * Generate the new entry.
+ */
+ if ( (code=file->free_ent) < file->maxmaxcode ) {
+ file->tab_prefix[code] = (unsigned short)oldcode;
+ file->tab_suffix[code] = finchar;
+ file->free_ent = code+1;
+ }
+ /*
+ * Remember previous code.
+ */
+ oldcode = incode;
+ }
+ file->oldcode = oldcode;
+ file->stackp = stackp;
+ file->finchar = finchar;
+ if (buf == f->buffer) {
+ f->left = 0;
+ return BUFFILEEOF;
+ }
+ f->bufp = f->buffer + 1;
+ f->left = (buf - f->buffer) - 1;
+ return f->buffer[0];
+}
+
+/*****************************************************************
+ * TAG( getcode )
+ *
+ * Read one code from the standard input. If BUFFILEEOF, return -1.
+ * Inputs:
+ * stdin
+ * Outputs:
+ * code or -1 is returned.
+ */
+
+static char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
+
+static code_int
+getcode(CompressedFile *file)
+{
+ register code_int code;
+ register int r_off, bits;
+ register char_type *bp = file->buf;
+ register BufFilePtr raw;
+
+ if ( file->clear_flg > 0 || file->offset >= file->size ||
+ file->free_ent > file->maxcode )
+ {
+ /*
+ * If the next entry will be too big for the current code
+ * size, then we must increase the size. This implies reading
+ * a new buffer full, too.
+ */
+ if ( file->free_ent > file->maxcode ) {
+ file->n_bits++;
+ if ( file->n_bits == file->maxbits )
+ file->maxcode = file->maxmaxcode; /* won't get any bigger now */
+ else
+ file->maxcode = MAXCODE(file->n_bits);
+ }
+ if ( file->clear_flg > 0) {
+ file->maxcode = MAXCODE (file->n_bits = INIT_BITS);
+ file->clear_flg = 0;
+ }
+ bits = file->n_bits;
+ raw = file->file;
+ while (bits > 0 && (code = BufFileGet (raw)) != BUFFILEEOF)
+ {
+ *bp++ = code;
+ --bits;
+ }
+ bp = file->buf;
+ if (bits == file->n_bits)
+ return -1; /* end of file */
+ file->size = file->n_bits - bits;
+ file->offset = 0;
+ /* Round size down to integral number of codes */
+ file->size = (file->size << 3) - (file->n_bits - 1);
+ }
+ r_off = file->offset;
+ bits = file->n_bits;
+ /*
+ * Get to the first byte.
+ */
+ bp += (r_off >> 3);
+ r_off &= 7;
+ /* Get first part (low order bits) */
+#ifdef NO_UCHAR
+ code = ((*bp++ >> r_off) & rmask[8 - r_off]) & 0xff;
+#else
+ code = (*bp++ >> r_off);
+#endif /* NO_UCHAR */
+ bits -= (8 - r_off);
+ r_off = 8 - r_off; /* now, offset into code word */
+ /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
+ if ( bits >= 8 ) {
+#ifdef NO_UCHAR
+ code |= (*bp++ & 0xff) << r_off;
+#else
+ code |= *bp++ << r_off;
+#endif /* NO_UCHAR */
+ r_off += 8;
+ bits -= 8;
+ }
+ /* high order bits. */
+ code |= (*bp & rmask[bits]) << r_off;
+ file->offset += file->n_bits;
+
+ return code;
+}
+
+static int
+BufCompressedSkip (BufFilePtr f, int bytes)
+{
+ int c;
+ while (bytes--)
+ {
+ c = BufFileGet(f);
+ if (c == BUFFILEEOF)
+ return BUFFILEEOF;
+ }
+ return 0;
+}
+
+#ifdef TEST
+int
+main (int argc, char *argv[])
+{
+ BufFilePtr inputraw, input, output;
+ int c;
+
+ inputraw = BufFileOpenRead (0);
+ input = BufFilePushCompressed (inputraw);
+ output = BufFileOpenWrite (1);
+ while ((c = BufFileGet (input)) != BUFFILEEOF)
+ BufFilePut (c, output);
+ BufFileClose (input, FALSE);
+ BufFileClose (output, FALSE);
+ return 0;
+}
+#endif
diff --git a/libXfont/src/fontfile/defaults.c b/libXfont/src/fontfile/defaults.c
new file mode 100644
index 000000000..7f20cab67
--- /dev/null
+++ b/libXfont/src/fontfile/defaults.c
@@ -0,0 +1,77 @@
+/* $Xorg: defaults.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/defaults.c,v 1.7 2001/01/17 19:43:29 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+#ifndef DEFAULT_BIT_ORDER
+#ifdef BITMAP_BIT_ORDER
+#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
+#else
+#define DEFAULT_BIT_ORDER MSBFirst
+#endif
+#endif
+
+#ifndef DEFAULT_BYTE_ORDER
+#ifdef IMAGE_BYTE_ORDER
+#define DEFAULT_BYTE_ORDER IMAGE_BYTE_ORDER
+#else
+#define DEFAULT_BYTE_ORDER MSBFirst
+#endif
+#endif
+
+#ifndef DEFAULT_GLYPH_PAD
+#ifdef GLYPHPADBYTES
+#define DEFAULT_GLYPH_PAD GLYPHPADBYTES
+#else
+#define DEFAULT_GLYPH_PAD 4
+#endif
+#endif
+
+#ifndef DEFAULT_SCAN_UNIT
+#define DEFAULT_SCAN_UNIT 1
+#endif
+
+#include <X11/fonts/fntfilst.h>
+
+void
+FontDefaultFormat (int *bit, int *byte, int *glyph, int *scan)
+{
+ *bit = DEFAULT_BIT_ORDER;
+ *byte = DEFAULT_BYTE_ORDER;
+ *glyph = DEFAULT_GLYPH_PAD;
+ *scan = DEFAULT_SCAN_UNIT;
+}
diff --git a/libXfont/src/fontfile/dirfile.c b/libXfont/src/fontfile/dirfile.c
new file mode 100644
index 000000000..148993896
--- /dev/null
+++ b/libXfont/src/fontfile/dirfile.c
@@ -0,0 +1,495 @@
+/* $Xorg: dirfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.17 2004/02/08 01:52:27 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/*
+ * dirfile.c
+ *
+ * Read fonts.dir and fonts.alias files
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+static Bool AddFileNameAliases ( FontDirectoryPtr dir );
+static int ReadFontAlias ( char *directory, Bool isFile,
+ FontDirectoryPtr *pdir );
+static int lexAlias ( FILE *file, char **lexToken );
+static int lexc ( FILE *file );
+
+int
+FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
+{
+ char file_name[MAXFONTFILENAMELEN];
+ char font_name[MAXFONTNAMELEN];
+ char dir_file[MAXFONTFILENAMELEN];
+ char dir_path[MAXFONTFILENAMELEN];
+ char *ptr;
+ FILE *file;
+ int count,
+ num_fonts,
+ status;
+ struct stat statb;
+ static char format[24] = "";
+#if defined(__UNIXOS2__) || defined(WIN32)
+ int i;
+#endif
+
+ FontDirectoryPtr dir = NullFontDirectory;
+
+ if (strlen(directory) + 1 + sizeof(FontDirFile) > sizeof(dir_file))
+ return BadFontPath;
+
+ /* Check for font directory attributes */
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+ if ((ptr = strchr(directory, ':'))) {
+#else
+ /* OS/2 and WIN32 path might start with a drive letter, don't clip this */
+ if ((ptr = strchr(directory+2, ':'))) {
+#endif
+ strncpy(dir_path, directory, ptr - directory);
+ dir_path[ptr - directory] = '\0';
+ } else {
+ strcpy(dir_path, directory);
+ }
+ strcpy(dir_file, dir_path);
+ if (dir_file[strlen(dir_file) - 1] != '/')
+ strcat(dir_file, "/");
+ strcat(dir_file, FontDirFile);
+ file = fopen(dir_file, "rt");
+ if (file) {
+#ifndef WIN32
+ if (fstat (fileno(file), &statb) == -1)
+#else
+ if (stat (dir_file, &statb) == -1)
+#endif
+ {
+ fclose(file);
+ return BadFontPath;
+ }
+ count = fscanf(file, "%d\n", &num_fonts);
+ if ((count == EOF) || (count != 1)) {
+ fclose(file);
+ return BadFontPath;
+ }
+ dir = FontFileMakeDir(directory, num_fonts);
+ if (dir == NULL) {
+ fclose(file);
+ return BadFontPath;
+ }
+ dir->dir_mtime = statb.st_mtime;
+ if (format[0] == '\0')
+ sprintf(format, "%%%ds %%%d[^\n]\n",
+ MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+
+ while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* strip any existing trailing CR */
+ for (i=0; i<strlen(font_name); i++) {
+ if (font_name[i]=='\r') font_name[i] = '\0';
+ }
+#endif
+ if (count != 2) {
+ FontFileFreeDir (dir);
+ fclose(file);
+ return BadFontPath;
+ }
+
+ /*
+ * We blindly try to load all the font files specified.
+ * In theory, we might want to warn that some of the fonts
+ * couldn't be loaded.
+ */
+ FontFileAddFontFile (dir, font_name, file_name);
+ }
+ fclose(file);
+
+ } else if (errno != ENOENT) {
+ return BadFontPath;
+ }
+ status = ReadFontAlias(dir_path, FALSE, &dir);
+ if (status != Successful) {
+ if (dir)
+ FontFileFreeDir (dir);
+ return status;
+ }
+ if (!dir)
+ return BadFontPath;
+
+ FontFileSortDir(dir);
+
+ *pdir = dir;
+ return Successful;
+}
+
+Bool
+FontFileDirectoryChanged(FontDirectoryPtr dir)
+{
+ char dir_file[MAXFONTFILENAMELEN];
+ struct stat statb;
+
+ if (strlen(dir->directory) + sizeof(FontDirFile) > sizeof(dir_file))
+ return FALSE;
+
+ strcpy (dir_file, dir->directory);
+ strcat (dir_file, FontDirFile);
+ if (stat (dir_file, &statb) == -1)
+ {
+ if (errno != ENOENT || dir->dir_mtime != 0)
+ return TRUE;
+ return FALSE; /* doesn't exist and never did: no change */
+ }
+ if (dir->dir_mtime != statb.st_mtime)
+ return TRUE;
+
+ if ((strlen(dir->directory) + sizeof(FontAliasFile)) > sizeof(dir_file))
+ return FALSE;
+ strcpy (dir_file, dir->directory);
+ strcat (dir_file, FontAliasFile);
+ if (stat (dir_file, &statb) == -1)
+ {
+ if (errno != ENOENT || dir->alias_mtime != 0)
+ return TRUE;
+ return FALSE; /* doesn't exist and never did: no change */
+ }
+ if (dir->alias_mtime != statb.st_mtime)
+ return TRUE;
+ return FALSE;
+}
+
+/*
+ * Make each of the file names an automatic alias for each of the files.
+ */
+
+static Bool
+AddFileNameAliases(FontDirectoryPtr dir)
+{
+ int i;
+ char copy[MAXFONTFILENAMELEN];
+ char *fileName;
+ FontTablePtr table;
+ FontRendererPtr renderer;
+ int len;
+ FontNameRec name;
+
+ table = &dir->nonScalable;
+ for (i = 0; i < table->used; i++) {
+ if (table->entries[i].type != FONT_ENTRY_BITMAP)
+ continue;
+ fileName = table->entries[i].u.bitmap.fileName;
+ renderer = FontFileMatchRenderer (fileName);
+ if (!renderer)
+ continue;
+
+ len = strlen (fileName) - renderer->fileSuffixLen;
+ if (len >= sizeof(copy))
+ continue;
+ CopyISOLatin1Lowered (copy, fileName, len);
+ copy[len] = '\0';
+ name.name = copy;
+ name.length = len;
+ name.ndashes = FontFileCountDashes (copy, len);
+
+ if (!FontFileFindNameInDir(table, &name)) {
+ if (!FontFileAddFontAlias (dir, copy, table->entries[i].name.name))
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/*
+ * parse the font.alias file. Format is:
+ *
+ * alias font-name
+ *
+ * To imbed white-space in an alias name, enclose it like "font name"
+ * in double quotes. \ escapes and character, so
+ * "font name \"With Double Quotes\" \\ and \\ back-slashes"
+ * works just fine.
+ *
+ * A line beginning with a ! denotes a newline-terminated comment.
+ */
+
+/*
+ * token types
+ */
+
+#define NAME 0
+#define NEWLINE 1
+#define DONE 2
+#define EALLOC 3
+
+static int
+ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir)
+{
+ char alias[MAXFONTNAMELEN];
+ char font_name[MAXFONTNAMELEN];
+ char alias_file[MAXFONTFILENAMELEN];
+ FILE *file;
+ FontDirectoryPtr dir;
+ int token;
+ char *lexToken;
+ int status = Successful;
+ struct stat statb;
+
+ if (strlen(directory) >= sizeof(alias_file))
+ return BadFontPath;
+ dir = *pdir;
+ strcpy(alias_file, directory);
+ if (!isFile) {
+ if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file))
+ return BadFontPath;
+ if (directory[strlen(directory) - 1] != '/')
+ strcat(alias_file, "/");
+ strcat(alias_file, FontAliasFile);
+ }
+ file = fopen(alias_file, "rt");
+ if (!file)
+ return ((errno == ENOENT) ? Successful : BadFontPath);
+ if (!dir)
+ *pdir = dir = FontFileMakeDir(directory, 10);
+ if (!dir)
+ {
+ fclose (file);
+ return AllocError;
+ }
+#ifndef WIN32
+ if (fstat (fileno (file), &statb) == -1)
+#else
+ if (stat (alias_file, &statb) == -1)
+#endif
+ {
+ fclose (file);
+ return BadFontPath;
+ }
+ dir->alias_mtime = statb.st_mtime;
+ while (status == Successful) {
+ token = lexAlias(file, &lexToken);
+ switch (token) {
+ case NEWLINE:
+ break;
+ case DONE:
+ fclose(file);
+ return Successful;
+ case EALLOC:
+ status = AllocError;
+ break;
+ case NAME:
+ if (strlen(lexToken) >= sizeof(alias)) {
+ status = BadFontPath;
+ break;
+ }
+ strcpy(alias, lexToken);
+ token = lexAlias(file, &lexToken);
+ switch (token) {
+ case NEWLINE:
+ if (strcmp(alias, "FILE_NAMES_ALIASES"))
+ status = BadFontPath;
+ else if (!AddFileNameAliases(dir))
+ status = AllocError;
+ break;
+ case DONE:
+ status = BadFontPath;
+ break;
+ case EALLOC:
+ status = AllocError;
+ break;
+ case NAME:
+ if (strlen(lexToken) >= sizeof(font_name)) {
+ status = BadFontPath;
+ break;
+ }
+ CopyISOLatin1Lowered(alias, alias, strlen(alias));
+ CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken));
+ if (!FontFileAddFontAlias (dir, alias, font_name))
+ status = AllocError;
+ break;
+ }
+ }
+ }
+ fclose(file);
+ return status;
+}
+
+#define QUOTE 0
+#define WHITE 1
+#define NORMAL 2
+#define END 3
+#define NL 4
+#define BANG 5
+
+static int charClass;
+
+static int
+lexAlias(FILE *file, char **lexToken)
+{
+ int c;
+ char *t;
+ enum state {
+ Begin, Normal, Quoted, Comment
+ } state;
+ int count;
+
+ static char *tokenBuf = (char *) NULL;
+ static int tokenSize = 0;
+
+ t = tokenBuf;
+ count = 0;
+ state = Begin;
+ for (;;) {
+ if (count == tokenSize) {
+ int nsize;
+ char *nbuf;
+
+ nsize = tokenSize ? (tokenSize << 1) : 64;
+ nbuf = (char *) xrealloc(tokenBuf, nsize);
+ if (!nbuf)
+ return EALLOC;
+ tokenBuf = nbuf;
+ tokenSize = nsize;
+ t = tokenBuf + count;
+ }
+ c = lexc(file);
+ switch (charClass) {
+ case QUOTE:
+ switch (state) {
+ case Begin:
+ case Normal:
+ state = Quoted;
+ break;
+ case Quoted:
+ state = Normal;
+ break;
+ case Comment:
+ break;
+ }
+ break;
+ case WHITE:
+ switch (state) {
+ case Begin:
+ case Comment:
+ continue;
+ case Normal:
+ *t = '\0';
+ *lexToken = tokenBuf;
+ return NAME;
+ case Quoted:
+ break;
+ }
+ /* fall through */
+ case NORMAL:
+ switch (state) {
+ case Begin:
+ state = Normal;
+ break;
+ case Comment:
+ continue;
+ default:
+ break;
+ }
+ *t++ = c;
+ ++count;
+ break;
+ case END:
+ case NL:
+ switch (state) {
+ case Begin:
+ case Comment:
+ *lexToken = (char *) NULL;
+ return charClass == END ? DONE : NEWLINE;
+ default:
+ *t = '\0';
+ *lexToken = tokenBuf;
+ ungetc(c, file);
+ return NAME;
+ }
+ break;
+ case BANG:
+ switch (state) {
+ case Begin:
+ state = Comment;
+ break;
+ case Comment:
+ break;
+ default:
+ *t++ = c;
+ ++count;
+ }
+ break;
+ }
+ }
+}
+
+static int
+lexc(FILE *file)
+{
+ int c;
+
+ c = getc(file);
+ switch (c) {
+ case EOF:
+ charClass = END;
+ break;
+ case '\\':
+ c = getc(file);
+ if (c == EOF)
+ charClass = END;
+ else
+ charClass = NORMAL;
+ break;
+ case '"':
+ charClass = QUOTE;
+ break;
+ case ' ':
+ case '\t':
+ charClass = WHITE;
+ break;
+ case '\r':
+ case '\n':
+ charClass = NL;
+ break;
+ case '!':
+ charClass = BANG;
+ break;
+ default:
+ charClass = NORMAL;
+ break;
+ }
+ return c;
+}
diff --git a/libXfont/src/fontfile/ffcheck.c b/libXfont/src/fontfile/ffcheck.c
new file mode 100644
index 000000000..70d117e46
--- /dev/null
+++ b/libXfont/src/fontfile/ffcheck.c
@@ -0,0 +1,188 @@
+/* $Xorg: ffcheck.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.15tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/fontmod.h>
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+
+/* Here we must check the client to see if it has a context attached to
+ * it that allows us to access the printer fonts
+ */
+
+static int
+FontFileCheckOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ if (XpClientIsBitmapClient(client))
+ return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
+ fmask, id, pFont, aliasName, non_cachable_font));
+ return BadFontName;
+}
+
+static int
+FontFileCheckListFonts (pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, FontNamesPtr names)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListFonts (client, fpe, pat, len, max, names);
+ return BadFontName;
+}
+
+static int
+FontFileCheckStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileStartListFontsWithInfo(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+FontFileCheckListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
+ pFontInfo, numFonts, private);
+ return BadFontName;
+}
+
+static int
+FontFileCheckStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileStartListFontsAndAliases(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+FontFileCheckListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private)
+{
+ if (XpClientIsBitmapClient(client))
+ return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
+ resolvedp, resolvedlenp, private);
+ return BadFontName;
+}
+
+/* Font renderers to initialize when not linked into something like
+ Xorg that provides its own module configuration options */
+static const FontModule builtinFontModuleList[] = {
+#ifdef XFONT_SPEEDO
+ {
+ SpeedoRegisterFontFileFunctions,
+ "speedo",
+ NULL
+ },
+#endif
+#ifdef XFONT_TYPE1
+ {
+ Type1RegisterFontFileFunctions,
+ "type1",
+ NULL
+ },
+#endif
+#ifdef XFONT_FREETYPE
+ {
+ FreeTypeRegisterFontFileFunctions,
+ "freetype",
+ NULL
+ },
+#endif
+ /* List terminator - must be last entry */
+ { NULL, NULL, NULL }
+};
+
+void
+FontFileCheckRegisterFpeFunctions (void)
+{
+ const FontModule *fmlist = builtinFontModuleList;
+
+#ifdef XFONT_BITMAP
+ /* bitmap is always builtin to libXfont now */
+ BitmapRegisterFontFileFunctions ();
+#endif
+
+#ifdef LOADABLEFONTS
+ if (FontModuleList) {
+ fmlist = FontModuleList;
+ }
+#endif
+
+ if (fmlist) {
+ int i;
+
+ for (i = 0; fmlist[i].name; i++) {
+ if (fmlist[i].initFunc) {
+ fmlist[i].initFunc();
+ }
+ }
+ }
+
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileCheckOpenFont,
+ FontFileCloseFont,
+ FontFileCheckListFonts,
+ FontFileCheckStartListFontsWithInfo,
+ FontFileCheckListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileCheckStartListFontsAndAliases,
+ FontFileCheckListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/libXfont/src/fontfile/fileio.c b/libXfont/src/fontfile/fileio.c
new file mode 100644
index 000000000..3733148a5
--- /dev/null
+++ b/libXfont/src/fontfile/fileio.c
@@ -0,0 +1,99 @@
+/* $Xorg: fileio.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fileio.c,v 3.9 2001/12/14 19:56:51 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilio.h>
+#include <X11/Xos.h>
+#ifndef O_BINARY
+#define O_BINARY O_RDONLY
+#endif
+
+FontFilePtr
+FontFileOpen (const char *name)
+{
+ int fd;
+ int len;
+ BufFilePtr raw, cooked;
+
+ fd = open (name, O_BINARY);
+ if (fd < 0)
+ return 0;
+ raw = BufFileOpenRead (fd);
+ if (!raw)
+ {
+ close (fd);
+ return 0;
+ }
+ len = strlen (name);
+#ifndef __UNIXOS2__
+ if (len > 2 && !strcmp (name + len - 2, ".Z")) {
+#else
+ if (len > 2 && (!strcmp (name + len - 4, ".pcz") ||
+ !strcmp (name + len - 2, ".Z"))) {
+#endif
+ cooked = BufFilePushCompressed (raw);
+ if (!cooked) {
+ BufFileClose (raw, TRUE);
+ return 0;
+ }
+ raw = cooked;
+#ifdef X_GZIP_FONT_COMPRESSION
+ } else if (len > 3 && !strcmp (name + len - 3, ".gz")) {
+ cooked = BufFilePushZIP (raw);
+ if (!cooked) {
+ BufFileClose (raw, TRUE);
+ return 0;
+ }
+ raw = cooked;
+#endif
+#ifdef X_BZIP2_FONT_COMPRESSION
+ } else if (len > 4 && !strcmp (name + len - 4, ".bz2")) {
+ cooked = BufFilePushBZIP2 (raw);
+ if (!cooked) {
+ BufFileClose (raw, TRUE);
+ return 0;
+ }
+ raw = cooked;
+#endif
+ }
+ return (FontFilePtr) raw;
+}
+
+int
+FontFileClose (FontFilePtr f)
+{
+ return BufFileClose ((BufFilePtr) f, TRUE);
+}
+
diff --git a/libXfont/src/fontfile/filewr.c b/libXfont/src/fontfile/filewr.c
new file mode 100644
index 000000000..d076f166a
--- /dev/null
+++ b/libXfont/src/fontfile/filewr.c
@@ -0,0 +1,65 @@
+/* $Xorg: filewr.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/filewr.c,v 3.6 2001/12/14 19:56:51 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilio.h>
+#include <X11/Xos.h>
+
+FontFilePtr
+FontFileOpenWrite (const char *name)
+{
+ int fd;
+
+#if defined(WIN32) || defined(__UNIXOS2__) || defined(__CYGWIN__)
+ fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0666);
+#else
+ fd = creat (name, 0666);
+#endif
+ if (fd < 0)
+ return 0;
+ return (FontFilePtr) BufFileOpenWrite (fd);
+}
+
+FontFilePtr
+FontFileOpenWriteFd (int fd)
+{
+ return (FontFilePtr) BufFileOpenWrite (fd);
+}
+
+FontFilePtr
+FontFileOpenFd (int fd)
+{
+ return (FontFilePtr) BufFileOpenRead (fd);
+}
diff --git a/libXfont/src/fontfile/fontdir.c b/libXfont/src/fontfile/fontdir.c
new file mode 100644
index 000000000..00c751153
--- /dev/null
+++ b/libXfont/src/fontfile/fontdir.c
@@ -0,0 +1,833 @@
+/* $XdotOrg: xc/lib/font/fontfile/fontdir.c,v 1.4 2005/07/03 07:01:00 daniels Exp $ */
+/* $Xorg: fontdir.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.22 2003/07/07 16:40:11 eich Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#include <X11/keysym.h>
+
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif !defined(INT32_MAX)
+#define INT32_MAX 0x7fffffff
+#endif
+
+Bool
+FontFileInitTable (FontTablePtr table, int size)
+{
+ if (size < 0 || (size > INT32_MAX/sizeof(FontEntryRec)))
+ return FALSE;
+ if (size)
+ {
+ table->entries = (FontEntryPtr) xalloc(sizeof(FontEntryRec) * size);
+ if (!table->entries)
+ return FALSE;
+ }
+ else
+ table->entries = 0;
+ table->used = 0;
+ table->size = size;
+ table->sorted = FALSE;
+ return TRUE;
+}
+
+void
+FontFileFreeEntry (FontEntryPtr entry)
+{
+ FontScalableExtraPtr extra;
+ int i;
+
+ if (entry->name.name)
+ xfree(entry->name.name);
+ entry->name.name = NULL;
+
+ switch (entry->type)
+ {
+ case FONT_ENTRY_SCALABLE:
+ xfree (entry->u.scalable.fileName);
+ extra = entry->u.scalable.extra;
+ for (i = 0; i < extra->numScaled; i++)
+ if (extra->scaled[i].vals.ranges)
+ xfree (extra->scaled[i].vals.ranges);
+ xfree (extra->scaled);
+ xfree (extra);
+ break;
+ case FONT_ENTRY_BITMAP:
+ xfree (entry->u.bitmap.fileName);
+ entry->u.bitmap.fileName = NULL;
+ break;
+ case FONT_ENTRY_ALIAS:
+ xfree (entry->u.alias.resolved);
+ entry->u.alias.resolved = NULL;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ break;
+#endif
+ }
+}
+
+void
+FontFileFreeTable (FontTablePtr table)
+{
+ int i;
+
+ for (i = 0; i < table->used; i++)
+ FontFileFreeEntry (&table->entries[i]);
+ xfree (table->entries);
+}
+
+FontDirectoryPtr
+FontFileMakeDir(char *dirName, int size)
+{
+ FontDirectoryPtr dir;
+ int dirlen;
+ int needslash = 0;
+ char *attrib;
+ int attriblen;
+
+#if !defined(__UNIXOS2__) && !defined(WIN32)
+ attrib = strchr(dirName, ':');
+#else
+ /* OS/2 uses the colon in the drive letter descriptor, skip this */
+ attrib = strchr(dirName+2, ':');
+#endif
+ if (attrib) {
+ dirlen = attrib - dirName;
+ attriblen = strlen(attrib);
+ } else {
+ dirlen = strlen(dirName);
+ attriblen = 0;
+ }
+ if (dirName[dirlen - 1] != '/')
+#ifdef NCD
+ if (dirlen) /* leave out slash for builtins */
+#endif
+ needslash = 1;
+ dir = (FontDirectoryPtr) xalloc(sizeof *dir + dirlen + needslash + 1 +
+ (attriblen ? attriblen + 1 : 0));
+ if (!dir)
+ return (FontDirectoryPtr)0;
+ if (!FontFileInitTable (&dir->scalable, 0))
+ {
+ xfree (dir);
+ return (FontDirectoryPtr)0;
+ }
+ if (!FontFileInitTable (&dir->nonScalable, size))
+ {
+ FontFileFreeTable (&dir->scalable);
+ xfree (dir);
+ return (FontDirectoryPtr)0;
+ }
+ dir->directory = (char *) (dir + 1);
+ dir->dir_mtime = 0;
+ dir->alias_mtime = 0;
+ if (attriblen)
+ dir->attributes = dir->directory + dirlen + needslash + 1;
+ else
+ dir->attributes = NULL;
+ strncpy(dir->directory, dirName, dirlen);
+ dir->directory[dirlen] = '\0';
+ if (dir->attributes)
+ strcpy(dir->attributes, attrib);
+ if (needslash)
+ strcat(dir->directory, "/");
+ return dir;
+}
+
+void
+FontFileFreeDir (FontDirectoryPtr dir)
+{
+ FontFileFreeTable (&dir->scalable);
+ FontFileFreeTable (&dir->nonScalable);
+ xfree(dir);
+}
+
+FontEntryPtr
+FontFileAddEntry(FontTablePtr table, FontEntryPtr prototype)
+{
+ FontEntryPtr entry;
+ int newsize;
+
+ /* can't add entries to a sorted table, pointers get broken! */
+ if (table->sorted)
+ return (FontEntryPtr) 0; /* "cannot" happen */
+ if (table->used == table->size) {
+ newsize = table->size + 100;
+ entry = (FontEntryPtr) xrealloc(table->entries,
+ newsize * sizeof(FontEntryRec));
+ if (!entry)
+ return (FontEntryPtr)0;
+ table->size = newsize;
+ table->entries = entry;
+ }
+ entry = &table->entries[table->used];
+ *entry = *prototype;
+ entry->name.name = (char *) xalloc(prototype->name.length + 1);
+ if (!entry->name.name)
+ return (FontEntryPtr)0;
+ memcpy (entry->name.name, prototype->name.name, prototype->name.length);
+ entry->name.name[entry->name.length] = '\0';
+ table->used++;
+ return entry;
+}
+
+/*
+ * Compare two strings just like strcmp, but preserve decimal integer
+ * sorting order, i.e. "2" < "10" or "iso8859-2" < "iso8859-10" <
+ * "iso10646-1". Strings are sorted as if sequences of digits were
+ * prefixed by a length indicator (i.e., does not ignore leading zeroes).
+ *
+ * Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
+ */
+#define Xisdigit(c) ('\060' <= (c) && (c) <= '\071')
+
+static int strcmpn(const char *s1, const char *s2)
+{
+ int digits, predigits = 0;
+ const char *ss1, *ss2;
+
+ while (1) {
+ if (*s1 == 0 && *s2 == 0)
+ return 0;
+ digits = Xisdigit(*s1) && Xisdigit(*s2);
+ if (digits && !predigits) {
+ ss1 = s1;
+ ss2 = s2;
+ while (Xisdigit(*ss1) && Xisdigit(*ss2))
+ ss1++, ss2++;
+ if (!Xisdigit(*ss1) && Xisdigit(*ss2))
+ return -1;
+ if (Xisdigit(*ss1) && !Xisdigit(*ss2))
+ return 1;
+ }
+ if ((unsigned char)*s1 < (unsigned char)*s2)
+ return -1;
+ if ((unsigned char)*s1 > (unsigned char)*s2)
+ return 1;
+ predigits = digits;
+ s1++, s2++;
+ }
+}
+
+
+static int
+FontFileNameCompare(const void* a, const void* b)
+{
+ FontEntryPtr a_name = (FontEntryPtr) a,
+ b_name = (FontEntryPtr) b;
+
+ return strcmpn(a_name->name.name, b_name->name.name);
+}
+
+void
+FontFileSortTable (FontTablePtr table)
+{
+ if (!table->sorted) {
+ qsort((char *) table->entries, table->used, sizeof(FontEntryRec),
+ FontFileNameCompare);
+ table->sorted = TRUE;
+ }
+}
+
+void
+FontFileSortDir(FontDirectoryPtr dir)
+{
+ FontFileSortTable (&dir->scalable);
+ FontFileSortTable (&dir->nonScalable);
+ /* now that the table is fixed in size, swizzle the pointers */
+ FontFileSwitchStringsToBitmapPointers (dir);
+}
+
+/*
+ Given a Font Table, SetupWildMatch() sets up various pointers and state
+ information so the table can be searched for name(s) that match a given
+ fontname pattern -- which may contain wildcards. Under certain
+ circumstances, SetupWildMatch() will find the one table entry that
+ matches the pattern. If those circumstances do not pertain,
+ SetupWildMatch() returns a range within the the table that should be
+ searched for matching name(s). With the information established by
+ SetupWildMatch(), including state information in "private", the
+ PatternMatch() procedure is then used to test names in the range for a
+ match.
+*/
+
+#define isWild(c) ((c) == XK_asterisk || (c) == XK_question)
+#define isDigit(c) (XK_0 <= (c) && (c) <= XK_9)
+
+static int
+SetupWildMatch(FontTablePtr table, FontNamePtr pat,
+ int *leftp, int *rightp, int *privatep)
+{
+ int nDashes;
+ char c;
+ char *t;
+ char *firstWild;
+ char *firstDigit;
+ int first;
+ int center,
+ left,
+ right;
+ int result;
+ char *name;
+
+ name = pat->name;
+ nDashes = pat->ndashes;
+ firstWild = 0;
+ firstDigit = 0;
+ t = name;
+ while ((c = *t++)) {
+ if (isWild(c)) {
+ if (!firstWild)
+ firstWild = t - 1;
+ }
+ if (isDigit(c)) {
+ if (!firstDigit)
+ firstDigit = t - 1;
+ }
+ }
+ left = 0;
+ right = table->used;
+ if (firstWild)
+ *privatep = nDashes;
+ else
+ *privatep = -1;
+ if (!table->sorted) {
+ *leftp = left;
+ *rightp = right;
+ return -1;
+ } else if (firstWild) {
+ if (firstDigit && firstDigit < firstWild)
+ first = firstDigit - name;
+ else
+ first = firstWild - name;
+ while (left < right) {
+ center = (left + right) / 2;
+ result = strncmp(name, table->entries[center].name.name, first);
+ if (result == 0)
+ break;
+ if (result < 0)
+ right = center;
+ else
+ left = center + 1;
+ }
+ *leftp = left;
+ *rightp = right;
+ return -1;
+ } else {
+ while (left < right) {
+ center = (left + right) / 2;
+ result = strcmpn(name, table->entries[center].name.name);
+ if (result == 0)
+ return center;
+ if (result < 0)
+ right = center;
+ else
+ left = center + 1;
+ }
+ *leftp = 1;
+ *rightp = 0;
+ return -1;
+ }
+}
+
+static int
+PatternMatch(char *pat, int patdashes, char *string, int stringdashes)
+{
+ char c,
+ t;
+
+ if (stringdashes < patdashes)
+ return 0;
+ for (;;) {
+ switch (c = *pat++) {
+ case '*':
+ if (!(c = *pat++))
+ return 1;
+ if (c == XK_minus) {
+ patdashes--;
+ for (;;) {
+ while ((t = *string++) != XK_minus)
+ if (!t)
+ return 0;
+ stringdashes--;
+ if (PatternMatch(pat, patdashes, string, stringdashes))
+ return 1;
+ if (stringdashes == patdashes)
+ return 0;
+ }
+ } else {
+ for (;;) {
+ while ((t = *string++) != c) {
+ if (!t)
+ return 0;
+ if (t == XK_minus) {
+ if (stringdashes-- < patdashes)
+ return 0;
+ }
+ }
+ if (PatternMatch(pat, patdashes, string, stringdashes))
+ return 1;
+ }
+ }
+ case '?':
+ if (*string++ == XK_minus)
+ stringdashes--;
+ break;
+ case '\0':
+ return (*string == '\0');
+ case XK_minus:
+ if (*string++ == XK_minus) {
+ patdashes--;
+ stringdashes--;
+ break;
+ }
+ return 0;
+ default:
+ if (c == *string++)
+ break;
+ return 0;
+ }
+ }
+}
+
+int
+FontFileCountDashes (char *name, int namelen)
+{
+ int ndashes = 0;
+
+ while (namelen--)
+ if (*name++ == '\055') /* avoid non ascii systems */
+ ++ndashes;
+ return ndashes;
+}
+
+char *
+FontFileSaveString (char *s)
+{
+ char *n;
+
+ n = (char *) xalloc (strlen (s) + 1);
+ if (!n)
+ return 0;
+ strcpy (n, s);
+ return n;
+}
+
+FontEntryPtr
+FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat,
+ FontScalablePtr vals)
+{
+ int i,
+ start,
+ stop,
+ res,
+ private;
+ FontNamePtr name;
+
+ if (!table->entries)
+ return NULL;
+ if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0)
+ return &table->entries[i];
+ for (i = start; i < stop; i++) {
+ name = &table->entries[i].name;
+ res = PatternMatch(pat->name, private, name->name, name->ndashes);
+ if (res > 0)
+ {
+ /* Check to see if enhancements requested are available */
+ if (vals)
+ {
+ int vs = vals->values_supplied;
+ int cap;
+
+ if (table->entries[i].type == FONT_ENTRY_SCALABLE)
+ cap = table->entries[i].u.scalable.renderer->capabilities;
+ else if (table->entries[i].type == FONT_ENTRY_ALIAS)
+ cap = ~0; /* Calling code will have to see if true */
+ else
+ cap = 0;
+ if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
+ !(cap & CAP_MATRIX)) ||
+ ((vs & CHARSUBSET_SPECIFIED) &&
+ !(cap & CAP_CHARSUBSETTING)))
+ continue;
+ }
+ return &table->entries[i];
+ }
+ if (res < 0)
+ break;
+ }
+ return (FontEntryPtr)0;
+}
+
+FontEntryPtr
+FontFileFindNameInDir(FontTablePtr table, FontNamePtr pat)
+{
+ return FontFileFindNameInScalableDir(table, pat, (FontScalablePtr)0);
+}
+
+int
+FontFileFindNamesInScalableDir(FontTablePtr table, FontNamePtr pat, int max,
+ FontNamesPtr names, FontScalablePtr vals,
+ int alias_behavior, int *newmax)
+{
+ int i,
+ start,
+ stop,
+ res,
+ private;
+ int ret = Successful;
+ FontEntryPtr fname;
+ FontNamePtr name;
+
+ if (max <= 0)
+ return Successful;
+ if ((i = SetupWildMatch(table, pat, &start, &stop, &private)) >= 0) {
+ if (alias_behavior == NORMAL_ALIAS_BEHAVIOR ||
+ table->entries[i].type != FONT_ENTRY_ALIAS)
+ {
+ name = &table->entries[i].name;
+ if (newmax) *newmax = max - 1;
+ return AddFontNamesName(names, name->name, name->length);
+ }
+ start = i;
+ stop = i + 1;
+ }
+ for (i = start, fname = &table->entries[start]; i < stop; i++, fname++) {
+ res = PatternMatch(pat->name, private, fname->name.name, fname->name.ndashes);
+ if (res > 0) {
+ if (vals)
+ {
+ int vs = vals->values_supplied;
+ int cap;
+
+ if (fname->type == FONT_ENTRY_SCALABLE)
+ cap = fname->u.scalable.renderer->capabilities;
+ else if (fname->type == FONT_ENTRY_ALIAS)
+ cap = ~0; /* Calling code will have to see if true */
+ else
+ cap = 0;
+ if ((((vs & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vs & POINTSIZE_MASK) == POINTSIZE_ARRAY) &&
+ !(cap & CAP_MATRIX)) ||
+ ((vs & CHARSUBSET_SPECIFIED) &&
+ !(cap & CAP_CHARSUBSETTING)))
+ continue;
+ }
+
+ if ((alias_behavior & IGNORE_SCALABLE_ALIASES) &&
+ fname->type == FONT_ENTRY_ALIAS)
+ {
+ FontScalableRec tmpvals;
+ if (FontParseXLFDName (fname->name.name, &tmpvals,
+ FONT_XLFD_REPLACE_NONE) &&
+ !(tmpvals.values_supplied & SIZE_SPECIFY_MASK))
+ continue;
+ }
+
+ ret = AddFontNamesName(names, fname->name.name, fname->name.length);
+ if (ret != Successful)
+ goto bail;
+
+ /* If alias_behavior is LIST_ALIASES_AND_TARGET_NAMES, mark
+ this entry as an alias by negating its length and follow
+ it by the resolved name */
+ if ((alias_behavior & LIST_ALIASES_AND_TARGET_NAMES) &&
+ fname->type == FONT_ENTRY_ALIAS)
+ {
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ ret = AddFontNamesName(names, fname->u.alias.resolved,
+ strlen(fname->u.alias.resolved));
+ if (ret != Successful)
+ goto bail;
+ }
+
+ if (--max <= 0)
+ break;
+ } else if (res < 0)
+ break;
+ }
+ bail: ;
+ if (newmax) *newmax = max;
+ return ret;
+}
+
+int
+FontFileFindNamesInDir(FontTablePtr table, FontNamePtr pat,
+ int max, FontNamesPtr names)
+{
+ return FontFileFindNamesInScalableDir(table, pat, max, names,
+ (FontScalablePtr)0,
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+}
+
+Bool
+FontFileMatchName(char *name, int length, FontNamePtr pat)
+{
+ /* Perform a fontfile-type name match on a single name */
+ FontTableRec table;
+ FontEntryRec entries[1];
+
+ /* Dummy up a table */
+ table.used = 1;
+ table.size = 1;
+ table.sorted = TRUE;
+ table.entries = entries;
+ entries[0].name.name = name;
+ entries[0].name.length = length;
+ entries[0].name.ndashes = FontFileCountDashes(name, length);
+
+ return FontFileFindNameInDir(&table, pat) != (FontEntryPtr)0;
+}
+
+/*
+ * Add a font file to a directory. This handles bitmap and
+ * scalable names both
+ */
+
+Bool
+FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
+{
+ FontEntryRec entry;
+ FontScalableRec vals, zeroVals;
+ FontRendererPtr renderer;
+ FontEntryPtr existing;
+ FontScalableExtraPtr extra;
+ FontEntryPtr bitmap = 0, scalable;
+ Bool isscale;
+ Bool scalable_xlfd;
+
+ renderer = FontFileMatchRenderer (fileName);
+ if (!renderer)
+ return FALSE;
+ entry.name.length = strlen (fontName);
+ if (entry.name.length > MAXFONTNAMELEN)
+ entry.name.length = MAXFONTNAMELEN;
+ entry.name.name = fontName;
+ CopyISOLatin1Lowered (entry.name.name, fontName, entry.name.length);
+ entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
+ entry.name.name[entry.name.length] = '\0';
+ /*
+ * Add a bitmap name if the incoming name isn't an XLFD name, or
+ * if it isn't a scalable name (i.e. non-zero scalable fields)
+ *
+ * If name of bitmapped font contains XLFD enhancements, do not add
+ * a scalable version of the name... this can lead to confusion and
+ * ambiguity between the font name and the field enhancements.
+ */
+ isscale = entry.name.ndashes == 14 &&
+ FontParseXLFDName(entry.name.name,
+ &vals, FONT_XLFD_REPLACE_NONE) &&
+ (vals.values_supplied & PIXELSIZE_MASK) != PIXELSIZE_ARRAY &&
+ (vals.values_supplied & POINTSIZE_MASK) != POINTSIZE_ARRAY &&
+ !(vals.values_supplied & ENHANCEMENT_SPECIFY_MASK);
+#define UNSCALED_ATTRIB "unscaled"
+ scalable_xlfd = (isscale &&
+ (((vals.values_supplied & PIXELSIZE_MASK) == 0) ||
+ ((vals.values_supplied & POINTSIZE_MASK) == 0)));
+ /*
+ * For scalable fonts without a scalable XFLD, check if the "unscaled"
+ * attribute is present.
+ */
+ if (isscale && !scalable_xlfd &&
+ dir->attributes && dir->attributes[0] == ':') {
+ char *ptr1 = dir->attributes + 1;
+ char *ptr2;
+ int length;
+ int uslength = strlen(UNSCALED_ATTRIB);
+
+ do {
+ ptr2 = strchr(ptr1, ':');
+ if (ptr2)
+ length = ptr2 - ptr1;
+ else
+ length = dir->attributes + strlen(dir->attributes) - ptr1;
+ if (length == uslength && !strncmp(ptr1, UNSCALED_ATTRIB, uslength))
+ isscale = FALSE;
+ if (ptr2)
+ ptr1 = ptr2 + 1;
+ } while (ptr2);
+ }
+ if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
+ {
+ /*
+ * If the renderer doesn't support OpenBitmap, FontFileOpenFont
+ * will still do the right thing.
+ */
+ entry.type = FONT_ENTRY_BITMAP;
+ entry.u.bitmap.renderer = renderer;
+ entry.u.bitmap.pFont = NullFont;
+ if (!(entry.u.bitmap.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ if (!(bitmap = FontFileAddEntry (&dir->nonScalable, &entry)))
+ {
+ xfree (entry.u.bitmap.fileName);
+ return FALSE;
+ }
+ }
+ /*
+ * Parse out scalable fields from XLFD names - a scalable name
+ * just gets inserted, a scaled name has more things to do.
+ */
+ if (isscale)
+ {
+ if (vals.values_supplied & SIZE_SPECIFY_MASK)
+ {
+ bzero((char *)&zeroVals, sizeof(zeroVals));
+ zeroVals.x = vals.x;
+ zeroVals.y = vals.y;
+ zeroVals.values_supplied = PIXELSIZE_SCALAR | POINTSIZE_SCALAR;
+ FontParseXLFDName (entry.name.name, &zeroVals,
+ FONT_XLFD_REPLACE_VALUE);
+ entry.name.length = strlen (entry.name.name);
+ existing = FontFileFindNameInDir (&dir->scalable, &entry.name);
+ if (existing)
+ {
+ if ((vals.values_supplied & POINTSIZE_MASK) ==
+ POINTSIZE_SCALAR &&
+ (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
+ {
+ existing->u.scalable.extra->defaults = vals;
+
+ xfree (existing->u.scalable.fileName);
+ if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ }
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (existing, &vals, NullFont,
+ bitmap->name.name);
+ return TRUE;
+ }
+ }
+ }
+ if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
+ return FALSE;
+ extra = (FontScalableExtraPtr) xalloc (sizeof (FontScalableExtraRec));
+ if (!extra)
+ {
+ xfree (entry.u.scalable.fileName);
+ return FALSE;
+ }
+ bzero((char *)&extra->defaults, sizeof(extra->defaults));
+ if ((vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR &&
+ (int)(vals.point_matrix[3] * 10) == GetDefaultPointSize())
+ extra->defaults = vals;
+ else
+ {
+ FontResolutionPtr resolution;
+ int num;
+
+ extra->defaults.point_matrix[0] =
+ extra->defaults.point_matrix[3] =
+ (double)GetDefaultPointSize() / 10.0;
+ extra->defaults.point_matrix[1] =
+ extra->defaults.point_matrix[2] = 0.0;
+ extra->defaults.values_supplied =
+ POINTSIZE_SCALAR | PIXELSIZE_UNDEFINED;
+ extra->defaults.width = -1;
+ if (vals.x <= 0 || vals.y <= 0)
+ {
+ resolution = GetClientResolutions (&num);
+ if (resolution && num > 0)
+ {
+ extra->defaults.x = resolution->x_resolution;
+ extra->defaults.y = resolution->y_resolution;
+ }
+ else
+ {
+ extra->defaults.x = 75;
+ extra->defaults.y = 75;
+ }
+ }
+ else
+ {
+ extra->defaults.x = vals.x;
+ extra->defaults.y = vals.y;
+ }
+ FontFileCompleteXLFD (&extra->defaults, &extra->defaults);
+ }
+ extra->numScaled = 0;
+ extra->sizeScaled = 0;
+ extra->scaled = 0;
+ extra->private = 0;
+ entry.type = FONT_ENTRY_SCALABLE;
+ entry.u.scalable.renderer = renderer;
+ entry.u.scalable.extra = extra;
+ if (!(scalable = FontFileAddEntry (&dir->scalable, &entry)))
+ {
+ xfree (extra);
+ xfree (entry.u.scalable.fileName);
+ return FALSE;
+ }
+ if (vals.values_supplied & SIZE_SPECIFY_MASK)
+ {
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (scalable, &vals, NullFont,
+ bitmap->name.name);
+ }
+ }
+ }
+ return TRUE;
+}
+
+Bool
+FontFileAddFontAlias (FontDirectoryPtr dir, char *aliasName, char *fontName)
+{
+ FontEntryRec entry;
+
+ if (strcmp(aliasName,fontName) == 0) {
+ /* Don't allow an alias to point to itself and create a loop */
+ return FALSE;
+ }
+ entry.name.length = strlen (aliasName);
+ CopyISOLatin1Lowered (aliasName, aliasName, entry.name.length);
+ entry.name.name = aliasName;
+ entry.name.ndashes = FontFileCountDashes (entry.name.name, entry.name.length);
+ entry.type = FONT_ENTRY_ALIAS;
+ if (!(entry.u.alias.resolved = FontFileSaveString (fontName)))
+ return FALSE;
+ if (!FontFileAddEntry (&dir->nonScalable, &entry))
+ {
+ xfree (entry.u.alias.resolved);
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/libXfont/src/fontfile/fontencc.c b/libXfont/src/fontfile/fontencc.c
new file mode 100644
index 000000000..b54079acf
--- /dev/null
+++ b/libXfont/src/fontfile/fontencc.c
@@ -0,0 +1,77 @@
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+/* $XFree86: xc/lib/font/fontfile/fontencc.c,v 1.1 2001/08/13 21:46:47 dawes Exp $ */
+
+/* Binary compatibility code. */
+
+/* This file includes code to make modules compiled for earlier
+ versions of the fontenc interfaces link with this one. It does
+ *not* provide source compatibility, as many of the data structures
+ now have different names. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontenc.h>
+#include <X11/fonts/fontencc.h>
+
+extern void ErrorF(const char *f, ...);
+
+char *
+font_encoding_from_xlfd(const char * name, int length)
+{
+ return FontEncFromXLFD(name, length);
+}
+
+FontEncPtr
+font_encoding_find(const char *encoding_name, const char *filename)
+{
+ return FontEncFind(encoding_name, filename);
+}
+
+unsigned
+font_encoding_recode(unsigned code,
+ FontEncPtr encoding, FontMapPtr mapping)
+{
+ if(encoding != mapping->encoding) {
+ ErrorF("Inconsistent mapping/encoding\n");
+ return 0;
+ }
+ return FontEncRecode(code, mapping);
+}
+
+char *
+font_encoding_name(unsigned code,
+ FontEncPtr encoding, FontMapPtr mapping)
+{
+ if(encoding != mapping->encoding) {
+ ErrorF("Inconsistent mapping/encoding\n");
+ return 0;
+ }
+ return FontEncName(code, mapping);
+}
+
+char **
+identifyEncodingFile(const char *filename)
+{
+ return FontEncIdentify(filename);
+}
diff --git a/libXfont/src/fontfile/fontfile.c b/libXfont/src/fontfile/fontfile.c
new file mode 100644
index 000000000..f900f7508
--- /dev/null
+++ b/libXfont/src/fontfile/fontfile.c
@@ -0,0 +1,1152 @@
+/* $XdotOrg: xc/lib/font/fontfile/fontfile.c,v 1.4 2005/07/03 07:01:00 daniels Exp $ */
+/* $Xorg: fontfile.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.21 2003/12/02 19:50:40 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#ifdef WIN32
+#include <ctype.h>
+#endif
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+static int FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font);
+
+int
+FontFileNameCheck (char *name)
+{
+#ifndef NCD
+#if defined(__UNIXOS2__) || defined(WIN32)
+ /* OS/2 uses D:/... as a path name for fonts, so accept this as a valid
+ * path if it starts with a letter and a colon. Same applies for WIN32
+ */
+ if (isalpha(*name) && name[1]==':')
+ return TRUE;
+#endif
+ return *name == '/';
+#else
+ return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
+#endif
+}
+
+int
+FontFileInitFPE (FontPathElementPtr fpe)
+{
+ int status;
+ FontDirectoryPtr dir;
+
+ status = FontFileReadDirectory (fpe->name, &dir);
+ if (status == Successful)
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ FontFileFreeFPE (fpe);
+ return AllocError;
+ }
+ fpe->private = (pointer) dir;
+ }
+ return status;
+}
+
+/* ARGSUSED */
+int
+FontFileResetFPE (FontPathElementPtr fpe)
+{
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ /*
+ * The reset must fail for bitmap fonts because they get cleared when
+ * the path is set.
+ */
+ if (FontFileDirectoryChanged (dir))
+ {
+ /* can't do it, so tell the caller to close and re-open */
+ return FPEResetFailed;
+ }
+ else
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ return FPEResetFailed;
+ }
+ return Successful;
+ }
+}
+
+int
+FontFileFreeFPE (FontPathElementPtr fpe)
+{
+ FontFileUnregisterBitmapSource (fpe);
+ FontFileFreeDir ((FontDirectoryPtr) fpe->private);
+ return Successful;
+}
+
+static int
+transfer_values_to_alias(char *entryname, int entrynamelength,
+ char *resolvedname,
+ char **aliasName, FontScalablePtr vals)
+{
+ static char aliasname[MAXFONTNAMELEN];
+ int nameok = 1, len;
+ char lowerName[MAXFONTNAMELEN];
+
+ *aliasName = resolvedname;
+ if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN &&
+ (entrynamelength < MAXFONTNAMELEN) &&
+ FontFileCountDashes (*aliasName, len) == 14)
+ {
+ FontScalableRec tmpVals;
+ FontScalableRec tmpVals2;
+
+ tmpVals2 = *vals;
+
+ /* If we're aliasing a scalable name, transfer values
+ from the name into the destination alias, multiplying
+ by matrices that appear in the alias. */
+
+ CopyISOLatin1Lowered (lowerName, entryname,
+ entrynamelength);
+ lowerName[entrynamelength] = '\0';
+
+ if (FontParseXLFDName(lowerName, &tmpVals,
+ FONT_XLFD_REPLACE_NONE) &&
+ !tmpVals.values_supplied &&
+ FontParseXLFDName(*aliasName, &tmpVals,
+ FONT_XLFD_REPLACE_NONE))
+ {
+ double *matrix = 0, tempmatrix[4];
+
+ /* Use a matrix iff exactly one is defined */
+ if ((tmpVals.values_supplied & PIXELSIZE_MASK) ==
+ PIXELSIZE_ARRAY &&
+ !(tmpVals.values_supplied & POINTSIZE_MASK))
+ matrix = tmpVals.pixel_matrix;
+ else if ((tmpVals.values_supplied & POINTSIZE_MASK) ==
+ POINTSIZE_ARRAY &&
+ !(tmpVals.values_supplied & PIXELSIZE_MASK))
+ matrix = tmpVals.point_matrix;
+
+ /* If matrix given in the alias, compute new point
+ and/or pixel matrices */
+ if (matrix)
+ {
+ /* Complete the XLFD name to avoid potential
+ gotchas */
+ if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2))
+ {
+ tempmatrix[0] =
+ matrix[0] * tmpVals2.point_matrix[0] +
+ matrix[1] * tmpVals2.point_matrix[2];
+ tempmatrix[1] =
+ matrix[0] * tmpVals2.point_matrix[1] +
+ matrix[1] * tmpVals2.point_matrix[3];
+ tempmatrix[2] =
+ matrix[2] * tmpVals2.point_matrix[0] +
+ matrix[3] * tmpVals2.point_matrix[2];
+ tempmatrix[3] =
+ matrix[2] * tmpVals2.point_matrix[1] +
+ matrix[3] * tmpVals2.point_matrix[3];
+ tmpVals2.point_matrix[0] = tempmatrix[0];
+ tmpVals2.point_matrix[1] = tempmatrix[1];
+ tmpVals2.point_matrix[2] = tempmatrix[2];
+ tmpVals2.point_matrix[3] = tempmatrix[3];
+
+ tempmatrix[0] =
+ matrix[0] * tmpVals2.pixel_matrix[0] +
+ matrix[1] * tmpVals2.pixel_matrix[2];
+ tempmatrix[1] =
+ matrix[0] * tmpVals2.pixel_matrix[1] +
+ matrix[1] * tmpVals2.pixel_matrix[3];
+ tempmatrix[2] =
+ matrix[2] * tmpVals2.pixel_matrix[0] +
+ matrix[3] * tmpVals2.pixel_matrix[2];
+ tempmatrix[3] =
+ matrix[2] * tmpVals2.pixel_matrix[1] +
+ matrix[3] * tmpVals2.pixel_matrix[3];
+ tmpVals2.pixel_matrix[0] = tempmatrix[0];
+ tmpVals2.pixel_matrix[1] = tempmatrix[1];
+ tmpVals2.pixel_matrix[2] = tempmatrix[2];
+ tmpVals2.pixel_matrix[3] = tempmatrix[3];
+
+ tmpVals2.values_supplied =
+ (tmpVals2.values_supplied &
+ ~(PIXELSIZE_MASK | POINTSIZE_MASK)) |
+ PIXELSIZE_ARRAY | POINTSIZE_ARRAY;
+ }
+ else
+ nameok = 0;
+ }
+
+ CopyISOLatin1Lowered (aliasname, *aliasName, len + 1);
+ if (nameok && FontParseXLFDName(aliasname, &tmpVals2,
+ FONT_XLFD_REPLACE_VALUE))
+ /* Return a version of the aliasname that has
+ had the vals stuffed into it. To avoid
+ memory leak, this alias name lives in a
+ static buffer. The caller needs to be done
+ with this buffer before this procedure is
+ called again to avoid reentrancy problems. */
+ *aliasName = aliasname;
+ }
+ }
+ return nameok;
+}
+
+/* ARGSUSED */
+int
+FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ FontDirectoryPtr dir;
+ char lowerName[MAXFONTNAMELEN];
+ char fileName[MAXFONTFILENAMELEN*2 + 1];
+ FontNameRec tmpName;
+ FontEntryPtr entry;
+ FontScalableRec vals;
+ FontScalableEntryPtr scalable;
+ FontScaledPtr scaled;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ Bool noSpecificSize;
+ int nranges;
+ fsRange *ranges;
+
+ if (namelen >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+
+ /* Match non-scalable pattern */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ ranges = FontParseRanges(lowerName, &nranges);
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
+ bzero(&vals, sizeof(vals));
+ if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
+ tmpName.ndashes == 14 &&
+ FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ tmpName.length = strlen(lowerName);
+ entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
+ }
+
+ if (entry)
+ {
+ switch (entry->type) {
+ case FONT_ENTRY_BITMAP:
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format,
+ fmask, non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ }
+ break;
+ case FONT_ENTRY_ALIAS:
+ vals.nranges = nranges;
+ vals.ranges = ranges;
+ transfer_values_to_alias(entry->name.name, entry->name.length,
+ entry->u.alias.resolved, aliasName, &vals);
+ ret = FontNameAlias;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ bc = &entry->u.bc;
+ entry = bc->entry;
+ ret = (*scalable->renderer->OpenScalable)
+ (fpe, pFont, flags, entry, &bc->vals, format, fmask,
+ non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ break;
+#endif
+ default:
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = BadFontName;
+ }
+
+ if (ret != BadFontName)
+ {
+ if (ranges) xfree(ranges);
+ return ret;
+ }
+
+ /* Match XLFD patterns */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
+ !(tmpName.length = strlen (lowerName),
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
+ &vals))) {
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
+ if (entry)
+ {
+ strcpy(lowerName, entry->name.name);
+ tmpName.name = lowerName;
+ tmpName.length = entry->name.length;
+ tmpName.ndashes = entry->name.ndashes;
+ }
+ }
+
+ if (entry)
+ {
+ noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
+ if (entry->type == FONT_ENTRY_SCALABLE &&
+ FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
+ {
+ scalable = &entry->u.scalable;
+ if ((vals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY ||
+ (vals.values_supplied &
+ ~SIZE_SPECIFY_MASK & ~CHARSUBSET_SPECIFIED))
+ scaled = 0;
+ else
+ scaled = FontFileFindScaledInstance (entry, &vals,
+ noSpecificSize);
+ /*
+ * A scaled instance can occur one of two ways:
+ *
+ * Either the font has been scaled to this
+ * size already, in which case scaled->pFont
+ * will point at that font.
+ *
+ * Or a bitmap instance in this size exists,
+ * which is handled as if we got a pattern
+ * matching the bitmap font name.
+ */
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFont = scaled->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFont = bitmap->pFont;
+ (*pFont)->fpe = fpe;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry,
+ format, fmask,
+ non_cachable_font);
+ if (ret == Successful && *pFont)
+ (*pFont)->fpe = fpe;
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &tmpName, &vals, format, fmask, noSpecificSize);
+ if (ret != Successful)
+ {
+ char origName[MAXFONTNAMELEN];
+
+ CopyISOLatin1Lowered (origName, name, namelen);
+ origName[namelen] = '\0';
+
+ /* Pass the original XLFD name in the vals
+ structure; the rasterizer is free to examine it
+ for hidden meanings. This information will not
+ be saved in the scaled-instances table. */
+
+ vals.xlfdName = origName;
+ vals.ranges = ranges;
+ vals.nranges = nranges;
+
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ if (scalable->renderer->OpenScalable) {
+ ret = (*scalable->renderer->OpenScalable) (fpe, pFont,
+ flags, entry, fileName, &vals, format, fmask,
+ non_cachable_font);
+ }
+ else if (scalable->renderer->OpenBitmap) {
+ ret = (*scalable->renderer->OpenBitmap) (fpe, pFont,
+ flags, entry, fileName, format, fmask,
+ non_cachable_font);
+ }
+ }
+
+ /* In case rasterizer does something bad because of
+ charset subsetting... */
+ if (ret == Successful &&
+ ((*pFont)->info.firstCol > (*pFont)->info.lastCol ||
+ (*pFont)->info.firstRow > (*pFont)->info.lastRow))
+ {
+ (*(*pFont)->unload_font)(*pFont);
+ ret = BadFontName;
+ }
+ /* Save the instance */
+ if (ret == Successful)
+ {
+ if (FontFileAddScaledInstance (entry, &vals,
+ *pFont, (char *) 0))
+ ranges = 0;
+ else
+ (*pFont)->fpePrivate = (pointer) 0;
+ (*pFont)->fpe = fpe;
+ }
+ }
+ }
+ }
+ }
+ else
+ ret = BadFontName;
+
+ if (ranges)
+ xfree(ranges);
+ return ret;
+}
+
+/* ARGSUSED */
+void
+FontFileCloseFont (FontPathElementPtr fpe, FontPtr pFont)
+{
+ FontEntryPtr entry;
+
+ if ((entry = (FontEntryPtr) pFont->fpePrivate)) {
+ switch (entry->type) {
+ case FONT_ENTRY_SCALABLE:
+ FontFileRemoveScaledInstance (entry, pFont);
+ break;
+ case FONT_ENTRY_BITMAP:
+ entry->u.bitmap.pFont = 0;
+ break;
+ default:
+ /* "cannot" happen */
+ break;
+ }
+ pFont->fpePrivate = 0;
+ }
+ (*pFont->unload_font) (pFont);
+}
+
+static int
+FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ FontPtr non_cachable_font)
+{
+ FontBitmapEntryPtr bitmap;
+ char fileName[MAXFONTFILENAMELEN*2+1];
+ int ret;
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ bitmap = &entry->u.bitmap;
+ if(!bitmap || !bitmap->renderer->OpenBitmap)
+ return BadFontName;
+ if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
+ return BadFontName;
+ strcpy (fileName, dir->directory);
+ strcat (fileName, bitmap->fileName);
+ ret = (*bitmap->renderer->OpenBitmap)
+ (fpe, pFont, flags, entry, fileName, format, fmask,
+ non_cachable_font);
+ if (ret == Successful)
+ {
+ bitmap->pFont = *pFont;
+ (*pFont)->fpePrivate = (pointer) entry;
+ }
+ return ret;
+}
+
+int
+FontFileOpenBitmap (FontPathElementPtr fpe, FontPtr *pFont,
+ int flags, FontEntryPtr entry,
+ fsBitmapFormat format, fsBitmapFormatMask fmask)
+{
+ return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
+ (FontPtr)0);
+}
+
+static int
+FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
+ FontEntryPtr entry)
+{
+ FontBitmapEntryPtr bitmap;
+ char fileName[MAXFONTFILENAMELEN*2+1];
+ int ret;
+ FontDirectoryPtr dir;
+
+ dir = (FontDirectoryPtr) fpe->private;
+ bitmap = &entry->u.bitmap;
+ if (!bitmap || !bitmap->renderer->GetInfoBitmap)
+ return BadFontName;
+ if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName))
+ return BadFontName;
+ strcpy (fileName, dir->directory);
+ strcat (fileName, bitmap->fileName);
+ ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName);
+ return ret;
+}
+
+static void
+_FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames,
+ FontNamePtr nameptr, char *zeroChars,
+ FontScalablePtr vals, fsRange *ranges,
+ int nranges, int *max)
+{
+ int i;
+ FontScalableRec zeroVals, tmpVals;
+ for (i = 0; i < scaleNames->nnames; i++)
+ {
+ char nameChars[MAXFONTNAMELEN];
+ if (!*max)
+ return;
+ FontParseXLFDName (scaleNames->names[i], &zeroVals,
+ FONT_XLFD_REPLACE_NONE);
+ tmpVals = *vals;
+ if (FontFileCompleteXLFD (&tmpVals, &zeroVals))
+ {
+ --*max;
+
+ strcpy (nameChars, scaleNames->names[i]);
+ if ((vals->values_supplied & PIXELSIZE_MASK) ||
+ !(vals->values_supplied & PIXELSIZE_WILDCARD) ||
+ vals->y == 0)
+ {
+ tmpVals.values_supplied =
+ (tmpVals.values_supplied & ~PIXELSIZE_MASK) |
+ (vals->values_supplied & PIXELSIZE_MASK);
+ tmpVals.pixel_matrix[0] = vals->pixel_matrix[0];
+ tmpVals.pixel_matrix[1] = vals->pixel_matrix[1];
+ tmpVals.pixel_matrix[2] = vals->pixel_matrix[2];
+ tmpVals.pixel_matrix[3] = vals->pixel_matrix[3];
+ }
+ if ((vals->values_supplied & POINTSIZE_MASK) ||
+ !(vals->values_supplied & POINTSIZE_WILDCARD) ||
+ vals->y == 0)
+ {
+ tmpVals.values_supplied =
+ (tmpVals.values_supplied & ~POINTSIZE_MASK) |
+ (vals->values_supplied & POINTSIZE_MASK);
+ tmpVals.point_matrix[0] = vals->point_matrix[0];
+ tmpVals.point_matrix[1] = vals->point_matrix[1];
+ tmpVals.point_matrix[2] = vals->point_matrix[2];
+ tmpVals.point_matrix[3] = vals->point_matrix[3];
+ }
+ if (vals->width <= 0)
+ tmpVals.width = 0;
+ if (vals->x == 0)
+ tmpVals.x = 0;
+ if (vals->y == 0)
+ tmpVals.y = 0;
+ tmpVals.ranges = ranges;
+ tmpVals.nranges = nranges;
+ FontParseXLFDName (nameChars, &tmpVals,
+ FONT_XLFD_REPLACE_VALUE);
+ /* If we're marking aliases with negative lengths, we
+ need to concoct a valid target name to follow it.
+ Otherwise we're done. */
+ if (scaleNames->length[i] >= 0)
+ {
+ (void) AddFontNamesName (names, nameChars,
+ strlen (nameChars));
+ /* If our original pattern matches the name from
+ the table and that name doesn't duplicate what
+ we just added, add the name from the table */
+ if (strcmp(nameChars, scaleNames->names[i]) &&
+ FontFileMatchName(scaleNames->names[i],
+ scaleNames->length[i],
+ nameptr) &&
+ *max)
+ {
+ --*max;
+ (void) AddFontNamesName (names, scaleNames->names[i],
+ scaleNames->length[i]);
+ }
+ }
+ else
+ {
+ char *aliasName;
+ vals->ranges = ranges;
+ vals->nranges = nranges;
+ if (transfer_values_to_alias(zeroChars,
+ strlen(zeroChars),
+ scaleNames->names[++i],
+ &aliasName, vals))
+ {
+ (void) AddFontNamesName (names, nameChars,
+ strlen (nameChars));
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ (void) AddFontNamesName (names, aliasName,
+ strlen (aliasName));
+ /* If our original pattern matches the name from
+ the table and that name doesn't duplicate what
+ we just added, add the name from the table */
+ if (strcmp(nameChars, scaleNames->names[i - 1]) &&
+ FontFileMatchName(scaleNames->names[i - 1],
+ -scaleNames->length[i - 1],
+ nameptr) &&
+ *max)
+ {
+ --*max;
+ (void) AddFontNamesName (names,
+ scaleNames->names[i - 1],
+ -scaleNames->length[i - 1]);
+ names->length[names->nnames - 1] =
+ -names->length[names->nnames - 1];
+ (void) AddFontNamesName (names, aliasName,
+ strlen (aliasName));
+ }
+ }
+ }
+ }
+ }
+}
+
+/* ARGSUSED */
+static int
+_FontFileListFonts (pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max, FontNamesPtr names,
+ int mark_aliases)
+{
+ FontDirectoryPtr dir;
+ char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN];
+ FontNameRec lowerName;
+ FontNameRec zeroName;
+ FontNamesPtr scaleNames;
+ FontScalableRec vals;
+ fsRange *ranges;
+ int nranges;
+ int result = BadFontName;
+
+ if (len >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+ CopyISOLatin1Lowered (lowerChars, pat, len);
+ lowerChars[len] = '\0';
+ lowerName.name = lowerChars;
+ lowerName.length = len;
+ lowerName.ndashes = FontFileCountDashes (lowerChars, len);
+
+ /* Match XLFD patterns */
+
+ strcpy (zeroChars, lowerChars);
+ if (lowerName.ndashes == 14 &&
+ FontParseXLFDName (zeroChars, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ ranges = FontParseRanges(lowerChars, &nranges);
+ result = FontFileFindNamesInScalableDir (&dir->nonScalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ (mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR) |
+ IGNORE_SCALABLE_ALIASES,
+ &max);
+ zeroName.name = zeroChars;
+ zeroName.length = strlen (zeroChars);
+ zeroName.ndashes = lowerName.ndashes;
+
+ /* Look for scalable names and aliases, adding scaled instances of
+ them to the output */
+
+ /* Scalable names... */
+ scaleNames = MakeFontNamesRecord (0);
+ if (!scaleNames)
+ {
+ if (ranges) xfree(ranges);
+ return AllocError;
+ }
+ FontFileFindNamesInScalableDir (&dir->scalable, &zeroName, max,
+ scaleNames, &vals,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ _FontFileAddScalableNames(names, scaleNames, &lowerName,
+ zeroChars, &vals, ranges, nranges,
+ &max);
+ FreeFontNames (scaleNames);
+
+ /* Scalable aliases... */
+ scaleNames = MakeFontNamesRecord (0);
+ if (!scaleNames)
+ {
+ if (ranges) xfree(ranges);
+ return AllocError;
+ }
+ FontFileFindNamesInScalableDir (&dir->nonScalable, &zeroName,
+ max, scaleNames, &vals,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ _FontFileAddScalableNames(names, scaleNames, &lowerName,
+ zeroChars, &vals, ranges, nranges,
+ &max);
+ FreeFontNames (scaleNames);
+
+ if (ranges) xfree(ranges);
+ }
+ else
+ {
+ result = FontFileFindNamesInScalableDir (&dir->nonScalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR,
+ &max);
+ if (result == Successful)
+ result = FontFileFindNamesInScalableDir (&dir->scalable,
+ &lowerName, max, names,
+ (FontScalablePtr)0,
+ mark_aliases ?
+ LIST_ALIASES_AND_TARGET_NAMES :
+ NORMAL_ALIAS_BEHAVIOR, (int *)0);
+ }
+ return result;
+}
+
+typedef struct _LFWIData {
+ FontNamesPtr names;
+ int current;
+} LFWIDataRec, *LFWIDataPtr;
+
+int
+FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
+{
+ return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
+}
+
+int
+FontFileStartListFonts(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep, int mark_aliases)
+{
+ LFWIDataPtr data;
+ int ret;
+
+ data = (LFWIDataPtr) xalloc (sizeof *data);
+ if (!data)
+ return AllocError;
+ data->names = MakeFontNamesRecord (0);
+ if (!data->names)
+ {
+ xfree (data);
+ return AllocError;
+ }
+ ret = _FontFileListFonts (client, fpe, pat, len,
+ max, data->names, mark_aliases);
+ if (ret != Successful)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return ret;
+ }
+ data->current = 0;
+ *privatep = (pointer) data;
+ return Successful;
+}
+
+
+int
+FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ return FontFileStartListFonts(client, fpe, pat, len, max, privatep, 0);
+}
+
+/* ARGSUSED */
+static int
+FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo)
+{
+ FontDirectoryPtr dir;
+ char lowerName[MAXFONTNAMELEN];
+ char fileName[MAXFONTFILENAMELEN*2 + 1];
+ FontNameRec tmpName;
+ FontEntryPtr entry;
+ FontScalableRec vals;
+ FontScalableEntryPtr scalable;
+ FontScaledPtr scaled;
+ FontBitmapEntryPtr bitmap;
+ int ret;
+ Bool noSpecificSize;
+ int nranges;
+ fsRange *ranges;
+
+ char *name = *namep;
+ int namelen = *namelenp;
+
+ if (namelen >= MAXFONTNAMELEN)
+ return AllocError;
+ dir = (FontDirectoryPtr) fpe->private;
+
+ /* Match non-scalable pattern */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ ranges = FontParseRanges(lowerName, &nranges);
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
+ bzero(&vals, sizeof(vals));
+ if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
+ tmpName.ndashes == 14 &&
+ FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
+ {
+ tmpName.length = strlen(lowerName);
+ entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
+ }
+
+ if (entry)
+ {
+ switch (entry->type) {
+ case FONT_ENTRY_BITMAP:
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFontInfo = &bitmap->pFont->info;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
+ }
+ break;
+ case FONT_ENTRY_ALIAS:
+ vals.nranges = nranges;
+ vals.ranges = ranges;
+ transfer_values_to_alias(entry->name.name, entry->name.length,
+ entry->u.alias.resolved, namep, &vals);
+ *namelenp = strlen (*namep);
+ ret = FontNameAlias;
+ break;
+#ifdef NOTYET
+ case FONT_ENTRY_BC:
+ /* no LFWI for this yet */
+ bc = &entry->u.bc;
+ entry = bc->entry;
+ /* Make a new scaled instance */
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ ret = (*scalable->renderer->GetInfoScalable)
+ (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
+ }
+ break;
+#endif
+ default:
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+ ret = BadFontName;
+ }
+
+ if (ret != BadFontName)
+ {
+ if (ranges) xfree(ranges);
+ return ret;
+ }
+
+ /* Match XLFD patterns */
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
+ !(tmpName.length = strlen (lowerName),
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
+ &vals))) {
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ lowerName[namelen] = '\0';
+ tmpName.name = lowerName;
+ tmpName.length = namelen;
+ tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
+ entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
+ if (entry)
+ {
+ strcpy(lowerName, entry->name.name);
+ tmpName.name = lowerName;
+ tmpName.length = entry->name.length;
+ tmpName.ndashes = entry->name.ndashes;
+ }
+ }
+
+ if (entry)
+ {
+ noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
+ if (entry && entry->type == FONT_ENTRY_SCALABLE &&
+ FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
+ {
+ scalable = &entry->u.scalable;
+ scaled = FontFileFindScaledInstance (entry, &vals, noSpecificSize);
+ /*
+ * A scaled instance can occur one of two ways:
+ *
+ * Either the font has been scaled to this
+ * size already, in which case scaled->pFont
+ * will point at that font.
+ *
+ * Or a bitmap instance in this size exists,
+ * which is handled as if we got a pattern
+ * matching the bitmap font name.
+ */
+ if (scaled)
+ {
+ if (scaled->pFont)
+ {
+ *pFontInfo = &scaled->pFont->info;
+ ret = Successful;
+ }
+ else if (scaled->bitmap)
+ {
+ entry = scaled->bitmap;
+ bitmap = &entry->u.bitmap;
+ if (bitmap->pFont)
+ {
+ *pFontInfo = &bitmap->pFont->info;
+ ret = Successful;
+ }
+ else
+ {
+ ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
+ }
+ }
+ else /* "cannot" happen */
+ {
+ ret = BadFontName;
+ }
+ }
+ else
+ {
+#ifdef NOTDEF
+ /* no special case yet */
+ ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &vals, format, fmask, noSpecificSize);
+ if (ret != Successful)
+#endif
+ {
+ char origName[MAXFONTNAMELEN];
+
+ CopyISOLatin1Lowered (origName, name, namelen);
+ origName[namelen] = '\0';
+ vals.xlfdName = origName;
+ vals.ranges = ranges;
+ vals.nranges = nranges;
+
+ /* Make a new scaled instance */
+ if (strlen(dir->directory) + strlen(scalable->fileName) >=
+ sizeof(fileName)) {
+ ret = BadFontName;
+ } else {
+ strcpy (fileName, dir->directory);
+ strcat (fileName, scalable->fileName);
+ if (scalable->renderer->GetInfoScalable)
+ ret = (*scalable->renderer->GetInfoScalable)
+ (fpe, *pFontInfo, entry, &tmpName, fileName,
+ &vals);
+ else if (scalable->renderer->GetInfoBitmap)
+ ret = (*scalable->renderer->GetInfoBitmap)
+ (fpe, *pFontInfo, entry, fileName);
+ }
+ if (ranges) {
+ xfree(ranges);
+ ranges = NULL;
+ }
+ }
+ }
+ if (ret == Successful) return ret;
+ }
+ CopyISOLatin1Lowered (lowerName, name, namelen);
+ tmpName.length = namelen;
+ }
+ else
+ ret = BadFontName;
+
+ if (ranges)
+ xfree(ranges);
+ return ret;
+}
+
+int
+FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ LFWIDataPtr data = (LFWIDataPtr) private;
+ int ret;
+ char *name;
+ int namelen;
+
+ if (data->current == data->names->nnames)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return BadFontName;
+ }
+ name = data->names->names[data->current];
+ namelen = data->names->length[data->current];
+ ret = FontFileListOneFontWithInfo (client, fpe, &name, &namelen, pFontInfo);
+ if (ret == BadFontName)
+ ret = AllocError;
+ *namep = name;
+ *namelenp = namelen;
+ ++data->current;
+ *numFonts = data->names->nnames - data->current;
+ return ret;
+}
+
+int
+FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ return FontFileStartListFonts(client, fpe, pat, len, max, privatep, 1);
+}
+
+int
+FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp, char **resolvedp,
+ int *resolvedlenp, pointer private)
+{
+ LFWIDataPtr data = (LFWIDataPtr) private;
+ int ret;
+ char *name;
+ int namelen;
+
+ if (data->current == data->names->nnames)
+ {
+ FreeFontNames (data->names);
+ xfree (data);
+ return BadFontName;
+ }
+ name = data->names->names[data->current];
+ namelen = data->names->length[data->current];
+
+ /* If this is a real font name... */
+ if (namelen >= 0)
+ {
+ *namep = name;
+ *namelenp = namelen;
+ ret = Successful;
+ }
+ /* Else if an alias */
+ else
+ {
+ /* Tell the caller that this is an alias... let him resolve it to
+ see if it's valid */
+ *namep = name;
+ *namelenp = -namelen;
+ *resolvedp = data->names->names[++data->current];
+ *resolvedlenp = data->names->length[data->current];
+ ret = FontNameAlias;
+ }
+
+ ++data->current;
+ return ret;
+}
+
+void
+FontFileRegisterLocalFpeFunctions (void)
+{
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileOpenFont,
+ FontFileCloseFont,
+ FontFileListFonts,
+ FontFileStartListFontsWithInfo,
+ FontFileListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileStartListFontsAndAliases,
+ FontFileListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/libXfont/src/fontfile/fontscale.c b/libXfont/src/fontfile/fontscale.c
new file mode 100644
index 000000000..8e9de513d
--- /dev/null
+++ b/libXfont/src/fontfile/fontscale.c
@@ -0,0 +1,447 @@
+/* $Xorg: fontscale.c,v 1.5 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/fontscale.c,v 3.9 2001/08/27 19:49:54 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+#ifdef _XOPEN_SOURCE
+#include <math.h>
+#else
+#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
+#include <math.h>
+#undef _XOPEN_SOURCE
+#endif
+
+Bool
+FontFileAddScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ FontPtr pFont, char *bitmapName)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ FontScaledPtr new;
+ int newsize;
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ if (extra->numScaled == extra->sizeScaled)
+ {
+ newsize = extra->sizeScaled + 4;
+ new = (FontScaledPtr) xrealloc (extra->scaled,
+ newsize * sizeof (FontScaledRec));
+ if (!new)
+ return FALSE;
+ extra->sizeScaled = newsize;
+ extra->scaled = new;
+ }
+ new = &extra->scaled[extra->numScaled++];
+ new->vals = *vals;
+ new->pFont = pFont;
+ new->bitmap = (FontEntryPtr) bitmapName;
+ if (pFont)
+ pFont->fpePrivate = (pointer) entry;
+ return TRUE;
+}
+
+/* Must call this after the directory is sorted */
+
+void
+FontFileSwitchStringsToBitmapPointers (FontDirectoryPtr dir)
+{
+ int s;
+ int b;
+ int i;
+ FontEntryPtr scalable;
+ FontEntryPtr nonScalable;
+ FontScaledPtr scaled;
+ FontScalableExtraPtr extra;
+
+ scalable = dir->scalable.entries;
+ nonScalable = dir->nonScalable.entries;
+ for (s = 0; s < dir->scalable.used; s++)
+ {
+ extra = scalable[s].u.scalable.extra;
+ scaled = extra->scaled;
+ for (i = 0; i < extra->numScaled; i++)
+ for (b = 0; b < dir->nonScalable.used; b++)
+ if (nonScalable[b].name.name == (char *) scaled[i].bitmap)
+ scaled[i].bitmap = &nonScalable[b];
+ }
+}
+
+void
+FontFileRemoveScaledInstance (FontEntryPtr entry, FontPtr pFont)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ int i;
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont == pFont)
+ {
+ if (extra->scaled[i].vals.ranges)
+ xfree (extra->scaled[i].vals.ranges);
+ extra->numScaled--;
+ for (; i < extra->numScaled; i++)
+ extra->scaled[i] = extra->scaled[i+1];
+ }
+ }
+}
+
+Bool
+FontFileCompleteXLFD (FontScalablePtr vals, FontScalablePtr def)
+{
+ FontResolutionPtr res;
+ int num_res;
+ double sx, sy, temp_matrix[4];
+ double pixel_setsize_adjustment = 1.0;
+ /*
+ * If two of the three vertical scale values are specified, compute the
+ * third. If all three are specified, make sure they are consistent
+ * (within a pixel)
+ *
+ * One purpose of this procedure is to complete XLFD names in a
+ * repeatable manner. That is, if the user partially specifies
+ * a name (say, pixelsize but not pointsize), the results generated
+ * here result in a fully specified name that will result in the
+ * same font.
+ */
+
+ res = GetClientResolutions(&num_res);
+
+ if (!(vals->values_supplied & PIXELSIZE_MASK) ||
+ !(vals->values_supplied & POINTSIZE_MASK))
+ {
+ /* If resolution(s) unspecified and cannot be computed from
+ pixelsize and pointsize, get appropriate defaults. */
+
+ if (num_res)
+ {
+ if (vals->x <= 0)
+ vals->x = res->x_resolution;
+ if (vals->y <= 0)
+ vals->y = res->y_resolution;
+ }
+
+ if (vals->x <= 0)
+ vals->x = def->x;
+ if (vals->y <= 0)
+ vals->y = def->y;
+ }
+ else
+ {
+ /* If needed, compute resolution values from the pixel and
+ pointsize information we were given. This problem is
+ overdetermined (four equations, two unknowns), but we don't
+ check for inconsistencies here. If they exist, they will
+ show up in later tests for the point and pixel sizes. */
+
+ if (vals->y <= 0)
+ {
+ double x = hypot(vals->pixel_matrix[1], vals->pixel_matrix[3]);
+ double y = hypot(vals->point_matrix[1], vals->point_matrix[3]);
+ if (y < EPS) return FALSE;
+ vals->y = (int)(x * 72.27 / y + .5);
+ }
+ if (vals->x <= 0)
+ {
+ /* If the pixelsize was given as an array, or as a scalar that
+ has been normalized for the pixel shape, we have enough
+ information to compute a separate horizontal resolution */
+
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
+ (vals->values_supplied & PIXELSIZE_MASK) ==
+ PIXELSIZE_SCALAR_NORMALIZED)
+ {
+ double x = hypot(vals->pixel_matrix[0], vals->pixel_matrix[2]);
+ double y = hypot(vals->point_matrix[0], vals->point_matrix[2]);
+ if (y < EPS) return FALSE;
+ vals->x = (int)(x * 72.27 / y + .5);
+ }
+ else
+ {
+ /* Not enough information in the pixelsize array. Just
+ assume the pixels are square. */
+ vals->x = vals->y;
+ }
+ }
+ }
+
+ if (vals->x <= 0 || vals->y <= 0) return FALSE;
+
+ /* If neither pixelsize nor pointsize is defined, take the pointsize
+ from the defaults structure we've been passed. */
+ if (!(vals->values_supplied & PIXELSIZE_MASK) &&
+ !(vals->values_supplied & POINTSIZE_MASK))
+ {
+ if (num_res)
+ {
+ vals->point_matrix[0] =
+ vals->point_matrix[3] = (double)res->point_size / 10.0;
+ vals->point_matrix[1] =
+ vals->point_matrix[2] = 0;
+ vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
+ POINTSIZE_SCALAR;
+ }
+ else if (def->values_supplied & POINTSIZE_MASK)
+ {
+ vals->point_matrix[0] = def->point_matrix[0];
+ vals->point_matrix[1] = def->point_matrix[1];
+ vals->point_matrix[2] = def->point_matrix[2];
+ vals->point_matrix[3] = def->point_matrix[3];
+ vals->values_supplied = (vals->values_supplied & ~POINTSIZE_MASK) |
+ (def->values_supplied & POINTSIZE_MASK);
+ }
+ else return FALSE;
+ }
+
+ /* At this point, at least two of the three vertical scale values
+ should be specified. Our job now is to compute the missing ones
+ and check for agreement between overspecified values */
+
+ /* If pixelsize was specified by a scalar, we need to fix the matrix
+ now that we know the resolutions. */
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_SCALAR)
+ {
+ /* pixel_setsize_adjustment used below to modify permissible
+ error in pixel/pointsize matching, since multiplying a
+ number rounded to integer changes the amount of the error
+ caused by the rounding */
+
+ pixel_setsize_adjustment = (double)vals->x / (double)vals->y;
+ vals->pixel_matrix[0] *= pixel_setsize_adjustment;
+ vals->values_supplied = (vals->values_supplied & ~PIXELSIZE_MASK) |
+ PIXELSIZE_SCALAR_NORMALIZED;
+ }
+
+ sx = (double)vals->x / 72.27;
+ sy = (double)vals->y / 72.27;
+
+ /* If a pointsize was specified, make sure pixelsize is consistent
+ to within 1 pixel, then replace pixelsize with a consistent
+ floating-point value. */
+
+ if (vals->values_supplied & POINTSIZE_MASK)
+ {
+ recompute_pixelsize: ;
+ temp_matrix[0] = vals->point_matrix[0] * sx;
+ temp_matrix[1] = vals->point_matrix[1] * sy;
+ temp_matrix[2] = vals->point_matrix[2] * sx;
+ temp_matrix[3] = vals->point_matrix[3] * sy;
+ if (vals->values_supplied & PIXELSIZE_MASK)
+ {
+ if (fabs(vals->pixel_matrix[0] - temp_matrix[0]) >
+ pixel_setsize_adjustment ||
+ fabs(vals->pixel_matrix[1] - temp_matrix[1]) > 1 ||
+ fabs(vals->pixel_matrix[2] - temp_matrix[2]) > 1 ||
+ fabs(vals->pixel_matrix[3] - temp_matrix[3]) > 1)
+ return FALSE;
+ }
+ if ((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY &&
+ (vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
+ {
+ /* In the special case that pixelsize came as an array and
+ pointsize as a scalar, recompute the pointsize matrix
+ from the pixelsize matrix. */
+ goto recompute_pointsize;
+ }
+
+ /* Refresh pixel matrix with precise values computed from
+ pointsize and resolution. */
+ vals->pixel_matrix[0] = temp_matrix[0];
+ vals->pixel_matrix[1] = temp_matrix[1];
+ vals->pixel_matrix[2] = temp_matrix[2];
+ vals->pixel_matrix[3] = temp_matrix[3];
+
+ /* Set values_supplied for pixel to match that for point */
+ vals->values_supplied =
+ (vals->values_supplied & ~PIXELSIZE_MASK) |
+ (((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY) ?
+ PIXELSIZE_ARRAY : PIXELSIZE_SCALAR_NORMALIZED);
+ }
+ else
+ {
+ /* Pointsize unspecified... compute from pixel size and
+ resolutions */
+ recompute_pointsize: ;
+ if (fabs(sx) < EPS || fabs(sy) < EPS) return FALSE;
+ vals->point_matrix[0] = vals->pixel_matrix[0] / sx;
+ vals->point_matrix[1] = vals->pixel_matrix[1] / sy;
+ vals->point_matrix[2] = vals->pixel_matrix[2] / sx;
+ vals->point_matrix[3] = vals->pixel_matrix[3] / sy;
+
+ /* Set values_supplied for pixel to match that for point */
+ vals->values_supplied =
+ (vals->values_supplied & ~POINTSIZE_MASK) |
+ (((vals->values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY) ?
+ POINTSIZE_ARRAY : POINTSIZE_SCALAR);
+
+ /* If we computed scalar pointsize from scalar pixelsize, round
+ pointsize to decipoints and recompute pixelsize so we end up
+ with a repeatable name */
+ if ((vals->values_supplied & POINTSIZE_MASK) == POINTSIZE_SCALAR)
+ {
+ /* Off-diagonal elements should be zero since no matrix was
+ specified. */
+ vals->point_matrix[0] =
+ (double)(int)(vals->point_matrix[0] * 10.0 + .5) / 10.0;
+ vals->point_matrix[3] =
+ (double)(int)(vals->point_matrix[3] * 10.0 + .5) / 10.0;
+ goto recompute_pixelsize;
+ }
+ }
+
+ /* We've succeeded. Round everything to a few decimal places
+ for repeatability. */
+
+ vals->pixel_matrix[0] = xlfd_round_double(vals->pixel_matrix[0]);
+ vals->pixel_matrix[1] = xlfd_round_double(vals->pixel_matrix[1]);
+ vals->pixel_matrix[2] = xlfd_round_double(vals->pixel_matrix[2]);
+ vals->pixel_matrix[3] = xlfd_round_double(vals->pixel_matrix[3]);
+ vals->point_matrix[0] = xlfd_round_double(vals->point_matrix[0]);
+ vals->point_matrix[1] = xlfd_round_double(vals->point_matrix[1]);
+ vals->point_matrix[2] = xlfd_round_double(vals->point_matrix[2]);
+ vals->point_matrix[3] = xlfd_round_double(vals->point_matrix[3]);
+
+ /* Fill in the deprecated fields for the benefit of rasterizers
+ that do not handle the matrices. */
+ vals->point = vals->point_matrix[3] * 10;
+ vals->pixel = vals->pixel_matrix[3];
+
+ return TRUE;
+}
+
+static Bool
+MatchScalable (FontScalablePtr a, FontScalablePtr b)
+{
+ int i;
+
+ /* Some asymmetry here: we assume that the first argument (a) is
+ the table entry and the second (b) the item we're trying to match
+ (the key). We'll consider the fonts matched if the relevant
+ metrics match *and* if a) the table entry doesn't have charset
+ subsetting or b) the table entry has identical charset subsetting
+ to that in the key. We could add logic to check if the table
+ entry has a superset of the charset required by the key, but
+ we'll resist the urge for now. */
+
+#define EQUAL(a,b) ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2] && \
+ (a)[3] == (b)[3])
+
+ if (!(a->x == b->x &&
+ a->y == b->y &&
+ (a->width == b->width || a->width == 0 || b->width == 0 || b->width == -1) &&
+ (!(b->values_supplied & PIXELSIZE_MASK) ||
+ ((a->values_supplied & PIXELSIZE_MASK) ==
+ (b->values_supplied & PIXELSIZE_MASK) &&
+ EQUAL(a->pixel_matrix, b->pixel_matrix))) &&
+ (!(b->values_supplied & POINTSIZE_MASK) ||
+ ((a->values_supplied & POINTSIZE_MASK) ==
+ (b->values_supplied & POINTSIZE_MASK) &&
+ EQUAL(a->point_matrix, b->point_matrix))) &&
+ (a->nranges == 0 || a->nranges == b->nranges)))
+ return FALSE;
+
+ for (i = 0; i < a->nranges; i++)
+ if (a->ranges[i].min_char_low != b->ranges[i].min_char_low ||
+ a->ranges[i].min_char_high != b->ranges[i].min_char_high ||
+ a->ranges[i].max_char_low != b->ranges[i].max_char_low ||
+ a->ranges[i].max_char_high != b->ranges[i].max_char_high)
+ return FALSE;
+
+ return TRUE;
+}
+
+FontScaledPtr
+FontFileFindScaledInstance (FontEntryPtr entry, FontScalablePtr vals,
+ int noSpecificSize)
+{
+ FontScalableEntryPtr scalable;
+ FontScalableExtraPtr extra;
+ FontScalablePtr mvals;
+ int dist, i;
+ int mini;
+ double mindist;
+ register double temp, sum=0.0;
+
+#define NORMDIFF(a, b) ( \
+ temp = (a)[0] - (b)[0], \
+ sum = temp * temp, \
+ temp = (a)[1] - (b)[1], \
+ sum += temp * temp, \
+ temp = (a)[2] - (b)[2], \
+ sum += temp * temp, \
+ temp = (a)[3] - (b)[3], \
+ sum + temp * temp )
+
+ scalable = &entry->u.scalable;
+ extra = scalable->extra;
+ if (noSpecificSize && extra->numScaled)
+ {
+ mini = 0;
+ mindist = NORMDIFF(extra->scaled[0].vals.point_matrix,
+ vals->point_matrix);
+ for (i = 1; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont &&
+ !extra->scaled[i].pFont->info.cachable) continue;
+ mvals = &extra->scaled[i].vals;
+ dist = NORMDIFF(mvals->point_matrix, vals->point_matrix);
+ if (dist < mindist)
+ {
+ mindist = dist;
+ mini = i;
+ }
+ }
+ if (extra->scaled[mini].pFont &&
+ !extra->scaled[mini].pFont->info.cachable) return 0;
+ return &extra->scaled[mini];
+ }
+ else
+ {
+ /* See if we've scaled to this value yet */
+ for (i = 0; i < extra->numScaled; i++)
+ {
+ if (extra->scaled[i].pFont &&
+ !extra->scaled[i].pFont->info.cachable) continue;
+ if (MatchScalable (&extra->scaled[i].vals, vals))
+ return &extra->scaled[i];
+ }
+ }
+ return 0;
+}
diff --git a/libXfont/src/fontfile/gunzip.c b/libXfont/src/fontfile/gunzip.c
new file mode 100644
index 000000000..8c9c317aa
--- /dev/null
+++ b/libXfont/src/fontfile/gunzip.c
@@ -0,0 +1,227 @@
+/* $Xorg: gunzip.c,v 1.3 2000/08/17 19:46:37 cpqbld Exp $ */
+/* lib/font/fontfile/gunzip.c
+ written by Mark Eichin <eichin@kitten.gen.ma.us> September 1996.
+ intended for inclusion in X11 public releases. */
+/* $XFree86: xc/lib/font/fontfile/gunzip.c,v 1.4 2000/09/19 12:46:08 eich Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/bufio.h>
+#include <zlib.h>
+
+typedef struct _xzip_buf {
+ z_stream z;
+ int zstat;
+ BufChar b[BUFFILESIZE];
+ BufChar b_in[BUFFILESIZE];
+ BufFilePtr f;
+} xzip_buf;
+
+static int BufZipFileClose ( BufFilePtr f, int flag );
+static int BufZipFileFill ( BufFilePtr f );
+static int BufZipFileSkip ( BufFilePtr f, int c );
+static int BufCheckZipHeader ( BufFilePtr f );
+
+BufFilePtr
+BufFilePushZIP (BufFilePtr f)
+{
+ xzip_buf *x;
+
+ x = (xzip_buf *) xalloc (sizeof (xzip_buf));
+ if (!x) return 0;
+ /* these are just for raw calloc/free */
+ x->z.zalloc = Z_NULL;
+ x->z.zfree = Z_NULL;
+ x->z.opaque = Z_NULL;
+ x->f = f;
+
+ /* force inflateInit to allocate it's own history buffer */
+ x->z.next_in = Z_NULL;
+ x->z.next_out = Z_NULL;
+ x->z.avail_in = x->z.avail_out = 0;
+
+ /* using negative windowBits sets "nowrap" mode, which turns off
+ zlib header checking [undocumented, for gzip compatibility only?] */
+ x->zstat = inflateInit2(&(x->z), -MAX_WBITS);
+ if (x->zstat != Z_OK) {
+ xfree(x);
+ return 0;
+ }
+
+ /* now that the history buffer is allocated, we provide the data buffer */
+ x->z.next_out = x->b;
+ x->z.avail_out = BUFFILESIZE;
+ x->z.next_out = x->b_in;
+ x->z.avail_in = 0;
+
+ if (BufCheckZipHeader(x->f)) {
+ xfree(x);
+ return 0;
+ }
+
+ return BufFileCreate((char *)x,
+ BufZipFileFill,
+ 0,
+ BufZipFileSkip,
+ BufZipFileClose);
+}
+
+static int
+BufZipFileClose(BufFilePtr f, int flag)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+ inflateEnd (&(x->z));
+ BufFileClose (x->f, flag);
+ xfree (x);
+ return 1;
+}
+
+/* here's the real work.
+ -- we need to put stuff in f.buffer, update f.left and f.bufp,
+ then return the first byte (or BUFFILEEOF).
+ -- to do this, we need to get stuff into avail_in, and next_in,
+ and call inflate appropriately.
+ -- we may also need to add CRC maintenance - if inflate tells us
+ Z_STREAM_END, we then have 4bytes CRC and 4bytes length...
+ gzio.c:gzread shows most of the mechanism.
+ */
+static int
+BufZipFileFill (BufFilePtr f)
+{
+ xzip_buf *x = (xzip_buf *)f->private;
+
+ /* we only get called when left == 0... */
+ /* but just in case, deal */
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ }
+ /* did we run out last time? */
+ switch (x->zstat) {
+ case Z_OK:
+ break;
+ case Z_STREAM_END:
+ case Z_DATA_ERROR:
+ case Z_ERRNO:
+ f->left = 0;
+ return BUFFILEEOF;
+ default:
+ return BUFFILEEOF;
+ }
+ /* now we work to consume what we can */
+ /* let zlib know what we can handle */
+ x->z.next_out = x->b;
+ x->z.avail_out = BUFFILESIZE;
+
+ /* and try to consume all of it */
+ while (x->z.avail_out > 0) {
+ /* if we don't have anything to work from... */
+ if (x->z.avail_in == 0) {
+ /* ... fill the z buf from underlying file */
+ int i, c;
+ for (i = 0; i < sizeof(x->b_in); i++) {
+ c = BufFileGet(x->f);
+ if (c == BUFFILEEOF) break;
+ x->b_in[i] = c;
+ }
+ x->z.avail_in += i;
+ x->z.next_in = x->b_in;
+ }
+ /* so now we have some output space and some input data */
+ x->zstat = inflate(&(x->z), Z_NO_FLUSH);
+ /* the inflation output happens in the f buffer directly... */
+ if (x->zstat == Z_STREAM_END) {
+ /* deal with EOF, crc */
+ break;
+ }
+ if (x->zstat != Z_OK) {
+ break;
+ }
+ }
+ f->bufp = x->b;
+ f->left = BUFFILESIZE - x->z.avail_out;
+
+ if (f->left >= 0) {
+ f->left--;
+ return *(f->bufp++);
+ } else {
+ return BUFFILEEOF;
+ }
+}
+
+/* there should be a BufCommonSkip... */
+static int
+BufZipFileSkip (BufFilePtr f, int c)
+{
+ /* BufFileRawSkip returns the count unchanged.
+ BufCompressedSkip returns 0.
+ That means it probably never gets called... */
+ int retval = c;
+ while(c--) {
+ int get = BufFileGet(f);
+ if (get == BUFFILEEOF) return get;
+ }
+ return retval;
+}
+
+/* now we need to duplicate check_header */
+/* contents:
+ 0x1f, 0x8b -- magic number
+ 1 byte -- method (Z_DEFLATED)
+ 1 byte -- flags (mask with RESERVED -> fail)
+ 4 byte -- time (discard)
+ 1 byte -- xflags (discard)
+ 1 byte -- "os" code (discard)
+ [if flags & EXTRA_FIELD:
+ 2 bytes -- LSBfirst length n
+ n bytes -- extra data (discard)]
+ [if flags & ORIG_NAME:
+ n bytes -- null terminated name (discard)]
+ [if flags & COMMENT:
+ n bytes -- null terminated comment (discard)]
+ [if flags & HEAD_CRC:
+ 2 bytes -- crc of headers? (discard)]
+ */
+
+/* gzip flag byte -- from gzio.c */
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define RESERVED 0xE0 /* bits 5..7: reserved */
+
+#define GET(f) do {c = BufFileGet(f); if (c == BUFFILEEOF) return c;} while(0)
+static int
+BufCheckZipHeader(BufFilePtr f)
+{
+ int c, flags;
+ GET(f); if (c != 0x1f) return 1; /* magic 1 */
+ GET(f); if (c != 0x8b) return 2; /* magic 2 */
+ GET(f); if (c != Z_DEFLATED) return 3; /* method */
+ GET(f); if (c & RESERVED) return 4; /* reserved flags */
+ flags = c;
+ GET(f); GET(f); GET(f); GET(f); /* time */
+ GET(f); /* xflags */
+ GET(f); /* os code */
+ if (flags & EXTRA_FIELD) {
+ int len;
+ GET(f); len = c;
+ GET(f); len += (c<<8);
+ while (len-- >= 0) {
+ GET(f);
+ }
+ }
+ if (flags & ORIG_NAME) {
+ do { GET(f); } while (c != 0);
+ }
+ if (flags & COMMENT) {
+ do { GET(f); } while (c != 0);
+ }
+ if (flags & HEAD_CRC) {
+ GET(f); GET(f); /* header crc */
+ }
+ return 0;
+}
diff --git a/libXfont/src/fontfile/printerfont.c b/libXfont/src/fontfile/printerfont.c
new file mode 100644
index 000000000..0b6c19c62
--- /dev/null
+++ b/libXfont/src/fontfile/printerfont.c
@@ -0,0 +1,178 @@
+/* $Xorg: printerfont.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.5tsi Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+
+/*
+ * Map FPE functions to renderer functions
+ */
+
+#define PRINTERPATHPREFIX "PRINTER:"
+
+/* STUB
+int XpClientIsPrintClient(client,fpe)
+pointer client;
+FontPathElementPtr fpe;
+{ return 1; }
+ */
+
+static int
+PrinterFontNameCheck (char *name)
+{
+ if (strncmp(name,PRINTERPATHPREFIX,strlen(PRINTERPATHPREFIX)) != 0)
+ return 0;
+ name += strlen(PRINTERPATHPREFIX);
+#ifndef NCD
+ return *name == '/';
+#else
+ return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
+#endif
+}
+
+static int
+PrinterFontInitFPE (FontPathElementPtr fpe)
+{
+ int status;
+ FontDirectoryPtr dir;
+ char * name;
+
+ name = fpe->name + strlen(PRINTERPATHPREFIX);
+ status = FontFileReadDirectory (name, &dir);
+ if (status == Successful)
+ {
+ if (dir->nonScalable.used > 0)
+ if (!FontFileRegisterBitmapSource (fpe))
+ {
+ FontFileFreeFPE (fpe);
+ return AllocError;
+ }
+ fpe->private = (pointer) dir;
+ }
+ return status;
+}
+
+/* Here we must check the client to see if it has a context attached to
+ * it that allows us to access the printer fonts
+ */
+
+static int
+PrinterFontOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
+ char *name, int namelen,
+ fsBitmapFormat format, fsBitmapFormatMask fmask,
+ XID id, FontPtr *pFont, char **aliasName,
+ FontPtr non_cachable_font)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return (FontFileOpenFont (client, fpe, flags, name, namelen, format,
+ fmask, id, pFont, aliasName, non_cachable_font));
+ return BadFontName;
+}
+
+static int
+PrinterFontListFonts (pointer client, FontPathElementPtr fpe, char *pat,
+ int len, int max, FontNamesPtr names)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListFonts (client, fpe, pat, len, max, names);
+ return BadFontName;
+}
+
+static int
+PrinterFontStartListFontsWithInfo(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileStartListFontsWithInfo(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+PrinterFontListNextFontWithInfo(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ FontInfoPtr *pFontInfo,
+ int *numFonts, pointer private)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListNextFontWithInfo(client, fpe, namep, namelenp,
+ pFontInfo, numFonts, private);
+ return BadFontName;
+}
+
+static int
+PrinterFontStartListFontsAndAliases(pointer client, FontPathElementPtr fpe,
+ char *pat, int len, int max,
+ pointer *privatep)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileStartListFontsAndAliases(client, fpe, pat, len,
+ max, privatep);
+ return BadFontName;
+}
+
+static int
+PrinterFontListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
+ char **namep, int *namelenp,
+ char **resolvedp, int *resolvedlenp,
+ pointer private)
+{
+ if (XpClientIsPrintClient(client,fpe))
+ return FontFileListNextFontOrAlias(client, fpe, namep, namelenp,
+ resolvedp, resolvedlenp, private);
+ return BadFontName;
+}
+
+void
+PrinterFontRegisterFpeFunctions (void)
+{
+ RegisterFPEFunctions(PrinterFontNameCheck,
+ PrinterFontInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ PrinterFontOpenFont,
+ FontFileCloseFont,
+ PrinterFontListFonts,
+ PrinterFontStartListFontsWithInfo,
+ PrinterFontListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ PrinterFontStartListFontsAndAliases,
+ PrinterFontListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
+}
diff --git a/libXfont/src/fontfile/register.c b/libXfont/src/fontfile/register.c
new file mode 100644
index 000000000..5b70df76a
--- /dev/null
+++ b/libXfont/src/fontfile/register.c
@@ -0,0 +1,124 @@
+/* $Xorg: register.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/register.c,v 1.14 2001/01/17 19:43:30 dawes Exp $ */
+
+/*
+ * This is in a separate source file so that small programs
+ * such as mkfontdir that want to use the fontfile utilities don't
+ * end up dragging in code from all the renderers, which is not small.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#else
+#define XFONT_BITMAP 1
+#endif
+
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fntfilst.h>
+#include <X11/fonts/bitmap.h>
+#include <X11/fonts/fontmod.h>
+
+/*
+ * Translate monolithic build symbols to modular build symbols.
+ * I chose to make the modular symbols 'canonical' because they
+ * are prefixed with XFONT_, neatly avoiding name collisions
+ * with other packages.
+ */
+
+#ifndef CRAY
+# ifdef BUILD_SPEEDO
+# define XFONT_SPEEDO 1
+# endif
+# ifdef BUILD_TYPE1
+# define XFONT_TYPE1 1
+# endif
+#endif
+
+#ifdef BUILD_FREETYPE
+# define XFONT_FREETYPE 1
+#endif
+
+/* Font renderers to initialize when not linked into something like
+ Xorg that provides its own module configuration options */
+static const FontModule builtinFontModuleList[] = {
+#ifdef XFONT_SPEEDO
+ {
+ SpeedoRegisterFontFileFunctions,
+ "speedo",
+ NULL
+ },
+#endif
+#ifdef XFONT_TYPE1
+ {
+ Type1RegisterFontFileFunctions,
+ "type1",
+ NULL
+ },
+#endif
+#ifdef XFONT_FREETYPE
+ {
+ FreeTypeRegisterFontFileFunctions,
+ "freetype",
+ NULL
+ },
+#endif
+ /* List terminator - must be last entry */
+ { NULL, NULL, NULL }
+};
+
+void
+FontFileRegisterFpeFunctions(void)
+{
+ const FontModule *fmlist = builtinFontModuleList;
+
+#ifdef XFONT_BITMAP
+ /* bitmap is always builtin to libXfont now */
+ BitmapRegisterFontFileFunctions ();
+#endif
+
+#ifdef LOADABLEFONTS
+ if (FontModuleList) {
+ fmlist = FontModuleList;
+ }
+#endif
+
+ if (fmlist) {
+ int i;
+
+ for (i = 0; fmlist[i].name; i++) {
+ if (fmlist[i].initFunc) {
+ fmlist[i].initFunc();
+ }
+ }
+ }
+
+ FontFileRegisterLocalFpeFunctions ();
+ CatalogueRegisterLocalFpeFunctions ();
+}
+
diff --git a/libXfont/src/fontfile/renderers.c b/libXfont/src/fontfile/renderers.c
new file mode 100644
index 000000000..f110ba817
--- /dev/null
+++ b/libXfont/src/fontfile/renderers.c
@@ -0,0 +1,117 @@
+/* $Xorg: renderers.c,v 1.4 2001/02/09 02:04:03 xorgcvs Exp $ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+/* $XFree86: xc/lib/font/fontfile/renderers.c,v 1.7 2002/12/09 17:30:00 dawes Exp $ */
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fntfilst.h>
+extern void ErrorF(const char *f, ...);
+
+static FontRenderersRec renderers;
+
+/*
+ * XXX Maybe should allow unregistering renders. For now, just clear the
+ * list at each new generation.
+ */
+extern unsigned long serverGeneration;
+static unsigned long rendererGeneration = 0;
+
+Bool
+FontFileRegisterRenderer (FontRendererPtr renderer)
+{
+ return FontFilePriorityRegisterRenderer(renderer, 0);
+}
+
+Bool
+FontFilePriorityRegisterRenderer (FontRendererPtr renderer, int priority)
+{
+ int i;
+ struct _FontRenderersElement *new;
+
+ if (rendererGeneration != serverGeneration) {
+ rendererGeneration = serverGeneration;
+ renderers.number = 0;
+ if (renderers.renderers)
+ xfree(renderers.renderers);
+ renderers.renderers = NULL;
+ }
+
+ for (i = 0; i < renderers.number; i++) {
+ if (!strcmp (renderers.renderers[i].renderer->fileSuffix,
+ renderer->fileSuffix)) {
+ if(renderers.renderers[i].priority >= priority) {
+ if(renderers.renderers[i].priority == priority) {
+ if (rendererGeneration == 1)
+ ErrorF("Warning: font renderer for \"%s\" "
+ "already registered at priority %d\n",
+ renderer->fileSuffix, priority);
+ }
+ return TRUE;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if(i >= renderers.number) {
+ new = xrealloc (renderers.renderers, sizeof(*new) * (i + 1));
+ if (!new)
+ return FALSE;
+ renderers.renderers = new;
+ renderers.number = i + 1;
+ }
+ renderer->number = i;
+ renderers.renderers[i].renderer = renderer;
+ renderers.renderers[i].priority = priority;
+ return TRUE;
+}
+
+FontRendererPtr
+FontFileMatchRenderer (char *fileName)
+{
+ int i;
+ int fileLen;
+ FontRendererPtr r;
+
+ fileLen = strlen (fileName);
+ for (i = 0; i < renderers.number; i++)
+ {
+ r = renderers.renderers[i].renderer;
+ if (fileLen >= r->fileSuffixLen &&
+ !strcmp (fileName + fileLen - r->fileSuffixLen, r->fileSuffix))
+ {
+ return r;
+ }
+ }
+ return 0;
+}