diff options
author | marha <marha@users.sourceforge.net> | 2011-03-25 15:37:13 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-03-25 15:37:13 +0000 |
commit | 41a502478a2972358dec934d82ee401c61a5cd36 (patch) | |
tree | 3fda8100e6da9b4a2863789e393016a750502067 /libXfont/src/util | |
parent | 81aeaf653a832c4054d9a40b1cc796911521a739 (diff) | |
parent | 272e57235cd60a2e65ac8258d96a02eb3939b687 (diff) | |
download | vcxsrv-41a502478a2972358dec934d82ee401c61a5cd36.tar.gz vcxsrv-41a502478a2972358dec934d82ee401c61a5cd36.tar.bz2 vcxsrv-41a502478a2972358dec934d82ee401c61a5cd36.zip |
svn merge ^/branches/released .
Diffstat (limited to 'libXfont/src/util')
-rw-r--r-- | libXfont/src/util/Makefile.in | 494 | ||||
-rw-r--r-- | libXfont/src/util/atom.c | 487 | ||||
-rw-r--r-- | libXfont/src/util/fontaccel.c | 211 | ||||
-rw-r--r-- | libXfont/src/util/fontnames.c | 242 | ||||
-rw-r--r-- | libXfont/src/util/fontutil.c | 823 | ||||
-rw-r--r-- | libXfont/src/util/fontxlfd.c | 1267 | ||||
-rw-r--r-- | libXfont/src/util/format.c | 250 | ||||
-rw-r--r-- | libXfont/src/util/miscutil.c | 125 | ||||
-rw-r--r-- | libXfont/src/util/patcache.c | 439 | ||||
-rw-r--r-- | libXfont/src/util/private.c | 213 | ||||
-rw-r--r-- | libXfont/src/util/utilbitmap.c | 371 |
11 files changed, 2200 insertions, 2722 deletions
diff --git a/libXfont/src/util/Makefile.in b/libXfont/src/util/Makefile.in deleted file mode 100644 index 72d653bdf..000000000 --- a/libXfont/src/util/Makefile.in +++ /dev/null @@ -1,494 +0,0 @@ -# Makefile.in generated by automake 1.10.2 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008 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@ -subdir = src/util -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) -libutil_la_LIBADD = -am_libutil_la_OBJECTS = atom.lo fontaccel.lo fontnames.lo fontutil.lo \ - fontxlfd.lo format.lo miscutil.lo patcache.lo private.lo \ - utilbitmap.lo -libutil_la_OBJECTS = $(am_libutil_la_OBJECTS) -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/include/X11/fonts -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 = $(libutil_la_SOURCES) -DIST_SOURCES = $(libutil_la_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ -ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -APP_MAN_DIR = @APP_MAN_DIR@ -APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ -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@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ -DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ -DSYMUTIL = @DSYMUTIL@ -DUMPBIN = @DUMPBIN@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -FGREP = @FGREP@ -FILE_MAN_DIR = @FILE_MAN_DIR@ -FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ -FOP = @FOP@ -FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ -FREETYPE_LIBS = @FREETYPE_LIBS@ -FREETYPE_REQUIRES = @FREETYPE_REQUIRES@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_CMD = @INSTALL_CMD@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LD = @LD@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LIB_MAN_DIR = @LIB_MAN_DIR@ -LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ -LIPO = @LIPO@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAN_SUBSTS = @MAN_SUBSTS@ -MATH_LIBS = @MATH_LIBS@ -MISC_MAN_DIR = @MISC_MAN_DIR@ -MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ -MKDIR_P = @MKDIR_P@ -NM = @NM@ -NMEDIT = @NMEDIT@ -OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ -OS_CFLAGS = @OS_CFLAGS@ -OTOOL = @OTOOL@ -OTOOL64 = @OTOOL64@ -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@ -SED = @SED@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -VERSION = @VERSION@ -XFONT_CFLAGS = @XFONT_CFLAGS@ -XFONT_LIBS = @XFONT_LIBS@ -XMLTO = @XMLTO@ -XORG_MAN_PAGE = @XORG_MAN_PAGE@ -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_DUMPBIN = @ac_ct_DUMPBIN@ -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@ -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@ -lt_ECHO = @lt_ECHO@ -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_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -INCLUDES = \ - -I${top_srcdir}/include \ - -I$(top_srcdir)/src/stubs - -AM_CFLAGS = $(XFONT_CFLAGS) $(OS_CFLAGS) $(CWARNFLAGS) -noinst_LTLIBRARIES = libutil.la -libutil_la_SOURCES = \ - atom.c \ - fontaccel.c \ - fontnames.c \ - fontutil.c \ - fontxlfd.c \ - format.c \ - miscutil.c \ - patcache.c \ - private.c \ - utilbitmap.c - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/util/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --foreign src/util/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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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 -libutil.la: $(libutil_la_OBJECTS) $(libutil_la_DEPENDENCIES) - $(LINK) $(libutil_la_OBJECTS) $(libutil_la_LIBADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontaccel.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontnames.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontxlfd.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/format.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/miscutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/patcache.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/private.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utilbitmap.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; nonempty = 1; } \ - END { if (nonempty) { 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; nonempty = 1; } \ - END { if (nonempty) { 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=; \ - 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; nonempty = 1; } \ - END { if (nonempty) { 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/util/atom.c b/libXfont/src/util/atom.c index bfb05ccbd..d2d628ece 100644 --- a/libXfont/src/util/atom.c +++ b/libXfont/src/util/atom.c @@ -1,245 +1,242 @@ -/* $Xorg: atom.c,v 1.5 2001/02/09 02:04:04 xorgcvs Exp $ */ - -/* - -Copyright 1990, 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/util/atom.c,v 1.9 2002/09/19 13:22:00 tsi Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -/* lame atom replacement routines for font applications */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include "stubs.h" - -typedef struct _AtomList { - char *name; - int len; - int hash; - Atom atom; -} AtomListRec, *AtomListPtr; - -static AtomListPtr *hashTable; - -static int hashSize, hashUsed; -static int hashMask; -static int rehash; - -static AtomListPtr *reverseMap; -static int reverseMapSize; -static Atom lastAtom; - -static int -Hash(char *string, int len) -{ - int h; - - h = 0; - while (len--) - h = (h << 3) ^ *string++; - if (h < 0) - return -h; - return h; -} - -static int -ResizeHashTable (void) -{ - int newHashSize; - int newHashMask; - AtomListPtr *newHashTable; - int i; - int h; - int newRehash; - int r; - - if (hashSize == 0) - newHashSize = 1024; - else - newHashSize = hashSize * 2; - newHashTable = calloc (newHashSize, sizeof (AtomListPtr)); - if (!newHashTable) { - fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate" - " newHashTable (%ld)\n", - newHashSize * (unsigned long)sizeof (AtomListPtr)); - return FALSE; - } - newHashMask = newHashSize - 1; - newRehash = (newHashMask - 2); - for (i = 0; i < hashSize; i++) - { - if (hashTable[i]) - { - h = (hashTable[i]->hash) & newHashMask; - if (newHashTable[h]) - { - r = hashTable[i]->hash % newRehash | 1; - do { - h += r; - if (h >= newHashSize) - h -= newHashSize; - } while (newHashTable[h]); - } - newHashTable[h] = hashTable[i]; - } - } - free (hashTable); - hashTable = newHashTable; - hashSize = newHashSize; - hashMask = newHashMask; - rehash = newRehash; - return TRUE; -} - -static int -ResizeReverseMap (void) -{ - int ret = TRUE; - if (reverseMapSize == 0) - reverseMapSize = 1000; - else - reverseMapSize *= 2; - reverseMap = realloc (reverseMap, reverseMapSize * sizeof (AtomListPtr)); - if (!reverseMap) { - fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate" - " reverseMap (%ld)\n", - reverseMapSize * (unsigned long)sizeof(AtomListPtr)); - ret = FALSE; - } - return ret; -} - -static int -NameEqual (const char *a, const char *b, int l) -{ - while (l--) - if (*a++ != *b++) - return FALSE; - return TRUE; -} - -#ifdef __SUNPRO_C -#pragma weak MakeAtom -#endif - -weak Atom -MakeAtom(char *string, unsigned len, int makeit) -{ - AtomListPtr a; - int hash; - int h = 0; - int r; - - hash = Hash (string, len); - if (hashTable) - { - h = hash & hashMask; - if (hashTable[h]) - { - if (hashTable[h]->hash == hash && hashTable[h]->len == len && - NameEqual (hashTable[h]->name, string, len)) - { - return hashTable[h]->atom; - } - r = (hash % rehash) | 1; - for (;;) - { - h += r; - if (h >= hashSize) - h -= hashSize; - if (!hashTable[h]) - break; - if (hashTable[h]->hash == hash && hashTable[h]->len == len && - NameEqual (hashTable[h]->name, string, len)) - { - return hashTable[h]->atom; - } - } - } - } - if (!makeit) - return None; - a = malloc (sizeof (AtomListRec) + len + 1); - if (a == NULL) { - fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec" - " (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1); - return None; - } - a->name = (char *) (a + 1); - a->len = len; - strncpy (a->name, string, len); - a->name[len] = '\0'; - a->atom = ++lastAtom; - a->hash = hash; - if (hashUsed >= hashSize / 2) - { - ResizeHashTable (); - h = hash & hashMask; - if (hashTable[h]) - { - r = (hash % rehash) | 1; - do { - h += r; - if (h >= hashSize) - h -= hashSize; - } while (hashTable[h]); - } - } - hashTable[h] = a; - hashUsed++; - if (reverseMapSize <= a->atom) { - if (!ResizeReverseMap()) - return None; - } - reverseMap[a->atom] = a; - return a->atom; -} - -#ifdef __SUNPRO_C -#pragma weak ValidAtom -#endif - -weak int -ValidAtom(Atom atom) -{ - return (atom != None) && (atom <= lastAtom); -} - -#ifdef __SUNPRO_C -#pragma weak NameForAtom -#endif - -weak char * -NameForAtom(Atom atom) -{ - if (atom != None && atom <= lastAtom) - return reverseMap[atom]->name; - return NULL; -} +/*
+
+Copyright 1990, 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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+/* lame atom replacement routines for font applications */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include "stubs.h"
+
+typedef struct _AtomList {
+ char *name;
+ int len;
+ int hash;
+ Atom atom;
+} AtomListRec, *AtomListPtr;
+
+static AtomListPtr *hashTable;
+
+static int hashSize, hashUsed;
+static int hashMask;
+static int rehash;
+
+static AtomListPtr *reverseMap;
+static int reverseMapSize;
+static Atom lastAtom;
+
+static int
+Hash(char *string, int len)
+{
+ int h;
+
+ h = 0;
+ while (len--)
+ h = (h << 3) ^ *string++;
+ if (h < 0)
+ return -h;
+ return h;
+}
+
+static int
+ResizeHashTable (void)
+{
+ int newHashSize;
+ int newHashMask;
+ AtomListPtr *newHashTable;
+ int i;
+ int h;
+ int newRehash;
+ int r;
+
+ if (hashSize == 0)
+ newHashSize = 1024;
+ else
+ newHashSize = hashSize * 2;
+ newHashTable = calloc (newHashSize, sizeof (AtomListPtr));
+ if (!newHashTable) {
+ fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
+ " newHashTable (%ld)\n",
+ newHashSize * (unsigned long)sizeof (AtomListPtr));
+ return FALSE;
+ }
+ newHashMask = newHashSize - 1;
+ newRehash = (newHashMask - 2);
+ for (i = 0; i < hashSize; i++)
+ {
+ if (hashTable[i])
+ {
+ h = (hashTable[i]->hash) & newHashMask;
+ if (newHashTable[h])
+ {
+ r = hashTable[i]->hash % newRehash | 1;
+ do {
+ h += r;
+ if (h >= newHashSize)
+ h -= newHashSize;
+ } while (newHashTable[h]);
+ }
+ newHashTable[h] = hashTable[i];
+ }
+ }
+ free (hashTable);
+ hashTable = newHashTable;
+ hashSize = newHashSize;
+ hashMask = newHashMask;
+ rehash = newRehash;
+ return TRUE;
+}
+
+static int
+ResizeReverseMap (void)
+{
+ int ret = TRUE;
+ if (reverseMapSize == 0)
+ reverseMapSize = 1000;
+ else
+ reverseMapSize *= 2;
+ reverseMap = realloc (reverseMap, reverseMapSize * sizeof (AtomListPtr));
+ if (!reverseMap) {
+ fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
+ " reverseMap (%ld)\n",
+ reverseMapSize * (unsigned long)sizeof(AtomListPtr));
+ ret = FALSE;
+ }
+ return ret;
+}
+
+static int
+NameEqual (const char *a, const char *b, int l)
+{
+ while (l--)
+ if (*a++ != *b++)
+ return FALSE;
+ return TRUE;
+}
+
+#ifdef __SUNPRO_C
+#pragma weak MakeAtom
+#endif
+
+weak Atom
+MakeAtom(char *string, unsigned len, int makeit)
+{
+ AtomListPtr a;
+ int hash;
+ int h = 0;
+ int r;
+
+ hash = Hash (string, len);
+ if (hashTable)
+ {
+ h = hash & hashMask;
+ if (hashTable[h])
+ {
+ if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+ NameEqual (hashTable[h]->name, string, len))
+ {
+ return hashTable[h]->atom;
+ }
+ r = (hash % rehash) | 1;
+ for (;;)
+ {
+ h += r;
+ if (h >= hashSize)
+ h -= hashSize;
+ if (!hashTable[h])
+ break;
+ if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
+ NameEqual (hashTable[h]->name, string, len))
+ {
+ return hashTable[h]->atom;
+ }
+ }
+ }
+ }
+ if (!makeit)
+ return None;
+ a = malloc (sizeof (AtomListRec) + len + 1);
+ if (a == NULL) {
+ fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
+ " (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
+ return None;
+ }
+ a->name = (char *) (a + 1);
+ a->len = len;
+ strncpy (a->name, string, len);
+ a->name[len] = '\0';
+ a->atom = ++lastAtom;
+ a->hash = hash;
+ if (hashUsed >= hashSize / 2)
+ {
+ ResizeHashTable ();
+ h = hash & hashMask;
+ if (hashTable[h])
+ {
+ r = (hash % rehash) | 1;
+ do {
+ h += r;
+ if (h >= hashSize)
+ h -= hashSize;
+ } while (hashTable[h]);
+ }
+ }
+ hashTable[h] = a;
+ hashUsed++;
+ if (reverseMapSize <= a->atom) {
+ if (!ResizeReverseMap())
+ return None;
+ }
+ reverseMap[a->atom] = a;
+ return a->atom;
+}
+
+#ifdef __SUNPRO_C
+#pragma weak ValidAtom
+#endif
+
+weak int
+ValidAtom(Atom atom)
+{
+ return (atom != None) && (atom <= lastAtom);
+}
+
+#ifdef __SUNPRO_C
+#pragma weak NameForAtom
+#endif
+
+weak char *
+NameForAtom(Atom atom)
+{
+ if (atom != None && atom <= lastAtom)
+ return reverseMap[atom]->name;
+ return NULL;
+}
diff --git a/libXfont/src/util/fontaccel.c b/libXfont/src/util/fontaccel.c index c37f69a39..4848aac75 100644 --- a/libXfont/src/util/fontaccel.c +++ b/libXfont/src/util/fontaccel.c @@ -1,107 +1,104 @@ -/* $Xorg: fontaccel.c,v 1.4 2001/02/09 02:04:04 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/util/fontaccel.c,v 1.6 2001/01/17 19:43:33 dawes Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> -#include <X11/fonts/fontutil.h> - -void -FontComputeInfoAccelerators(FontInfoPtr pFontInfo) -{ - pFontInfo->noOverlap = FALSE; - if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing) - pFontInfo->noOverlap = TRUE; - - if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) && - (pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) && - (pFontInfo->minbounds.leftSideBearing == - pFontInfo->maxbounds.leftSideBearing) && - (pFontInfo->minbounds.rightSideBearing == - pFontInfo->maxbounds.rightSideBearing) && - (pFontInfo->minbounds.characterWidth == - pFontInfo->maxbounds.characterWidth) && - (pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) { - pFontInfo->constantMetrics = TRUE; - if ((pFontInfo->maxbounds.leftSideBearing == 0) && - (pFontInfo->maxbounds.rightSideBearing == - pFontInfo->maxbounds.characterWidth) && - (pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) && - (pFontInfo->maxbounds.descent == pFontInfo->fontDescent)) - pFontInfo->terminalFont = TRUE; - else - pFontInfo->terminalFont = FALSE; - } else { - pFontInfo->constantMetrics = FALSE; - pFontInfo->terminalFont = FALSE; - } - if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) - pFontInfo->constantWidth = TRUE; - else - pFontInfo->constantWidth = FALSE; - - if ((pFontInfo->minbounds.leftSideBearing >= 0) && - (pFontInfo->maxOverlap <= 0) && - (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) && - (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && - (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) && - (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent)) - pFontInfo->inkInside = TRUE; - else - pFontInfo->inkInside = FALSE; -} - -int -FontCouldBeTerminal(FontInfoPtr pFontInfo) -{ - if ((pFontInfo->minbounds.leftSideBearing >= 0) && - (pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) && - (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) && - (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && - (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) && - (pFontInfo->maxbounds.leftSideBearing != 0 || - pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth || - pFontInfo->minbounds.ascent != pFontInfo->fontAscent || - pFontInfo->minbounds.descent != pFontInfo->fontDescent)) { - /* blow off font with nothing but a SPACE */ - if (pFontInfo->maxbounds.ascent == 0 && - pFontInfo->maxbounds.descent == 0) - return FALSE; - return TRUE; - } - return FALSE; -} +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontutil.h>
+
+void
+FontComputeInfoAccelerators(FontInfoPtr pFontInfo)
+{
+ pFontInfo->noOverlap = FALSE;
+ if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing)
+ pFontInfo->noOverlap = TRUE;
+
+ if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) &&
+ (pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) &&
+ (pFontInfo->minbounds.leftSideBearing ==
+ pFontInfo->maxbounds.leftSideBearing) &&
+ (pFontInfo->minbounds.rightSideBearing ==
+ pFontInfo->maxbounds.rightSideBearing) &&
+ (pFontInfo->minbounds.characterWidth ==
+ pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) {
+ pFontInfo->constantMetrics = TRUE;
+ if ((pFontInfo->maxbounds.leftSideBearing == 0) &&
+ (pFontInfo->maxbounds.rightSideBearing ==
+ pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent == pFontInfo->fontDescent))
+ pFontInfo->terminalFont = TRUE;
+ else
+ pFontInfo->terminalFont = FALSE;
+ } else {
+ pFontInfo->constantMetrics = FALSE;
+ pFontInfo->terminalFont = FALSE;
+ }
+ if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth)
+ pFontInfo->constantWidth = TRUE;
+ else
+ pFontInfo->constantWidth = FALSE;
+
+ if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
+ (pFontInfo->maxOverlap <= 0) &&
+ (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) &&
+ (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
+ (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent))
+ pFontInfo->inkInside = TRUE;
+ else
+ pFontInfo->inkInside = FALSE;
+}
+
+int
+FontCouldBeTerminal(FontInfoPtr pFontInfo)
+{
+ if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
+ (pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) &&
+ (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
+ (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) &&
+ (pFontInfo->maxbounds.leftSideBearing != 0 ||
+ pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth ||
+ pFontInfo->minbounds.ascent != pFontInfo->fontAscent ||
+ pFontInfo->minbounds.descent != pFontInfo->fontDescent)) {
+ /* blow off font with nothing but a SPACE */
+ if (pFontInfo->maxbounds.ascent == 0 &&
+ pFontInfo->maxbounds.descent == 0)
+ return FALSE;
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/libXfont/src/util/fontnames.c b/libXfont/src/util/fontnames.c index d03cea773..3beaf0fd5 100644 --- a/libXfont/src/util/fontnames.c +++ b/libXfont/src/util/fontnames.c @@ -1,123 +1,119 @@ -/* $Xorg: fontnames.c,v 1.4 2001/02/09 02:04:04 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/util/fontnames.c,v 1.4 2001/01/17 19:43:33 dawes Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - * - * @(#)fontnames.c 3.1 91/04/10 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> - -void -FreeFontNames(FontNamesPtr pFN) -{ - int i; - - if (!pFN) - return; - for (i = 0; i < pFN->nnames; i++) { - free(pFN->names[i]); - } - free(pFN->names); - free(pFN->length); - free(pFN); -} - -FontNamesPtr -MakeFontNamesRecord(unsigned int size) -{ - FontNamesPtr pFN; - - pFN = malloc(sizeof(FontNamesRec)); - if (pFN) { - pFN->nnames = 0; - pFN->size = size; - if (size) - { - pFN->length = malloc(size * sizeof(int)); - pFN->names = malloc(size * sizeof(char *)); - if (!pFN->length || !pFN->names) { - free(pFN->length); - free(pFN->names); - free(pFN); - pFN = (FontNamesPtr) 0; - } - } - else - { - pFN->length = 0; - pFN->names = 0; - } - } - return pFN; -} - -int -AddFontNamesName(FontNamesPtr names, char *name, int length) -{ - int index = names->nnames; - char *nelt; - - nelt = malloc(length + 1); - if (!nelt) - return AllocError; - if (index >= names->size) { - int size = names->size << 1; - int *nlength; - char **nnames; - - if (size == 0) - size = 8; - nlength = realloc(names->length, size * sizeof(int)); - nnames = realloc(names->names, size * sizeof(char *)); - if (nlength && nnames) { - names->size = size; - names->length = nlength; - names->names = nnames; - } else { - free(nelt); - free(nlength); - free(nnames); - return AllocError; - } - } - names->length[index] = length; - names->names[index] = nelt; - strncpy(nelt, name, length); - nelt[length] = '\0'; - names->nnames++; - return Successful; -} +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+void
+FreeFontNames(FontNamesPtr pFN)
+{
+ int i;
+
+ if (!pFN)
+ return;
+ for (i = 0; i < pFN->nnames; i++) {
+ free(pFN->names[i]);
+ }
+ free(pFN->names);
+ free(pFN->length);
+ free(pFN);
+}
+
+FontNamesPtr
+MakeFontNamesRecord(unsigned int size)
+{
+ FontNamesPtr pFN;
+
+ pFN = malloc(sizeof(FontNamesRec));
+ if (pFN) {
+ pFN->nnames = 0;
+ pFN->size = size;
+ if (size)
+ {
+ pFN->length = malloc(size * sizeof(int));
+ pFN->names = malloc(size * sizeof(char *));
+ if (!pFN->length || !pFN->names) {
+ free(pFN->length);
+ free(pFN->names);
+ free(pFN);
+ pFN = (FontNamesPtr) 0;
+ }
+ }
+ else
+ {
+ pFN->length = 0;
+ pFN->names = 0;
+ }
+ }
+ return pFN;
+}
+
+int
+AddFontNamesName(FontNamesPtr names, char *name, int length)
+{
+ int index = names->nnames;
+ char *nelt;
+
+ nelt = malloc(length + 1);
+ if (!nelt)
+ return AllocError;
+ if (index >= names->size) {
+ int size = names->size << 1;
+ int *nlength;
+ char **nnames;
+
+ if (size == 0)
+ size = 8;
+ nlength = realloc(names->length, size * sizeof(int));
+ nnames = realloc(names->names, size * sizeof(char *));
+ if (nlength && nnames) {
+ names->size = size;
+ names->length = nlength;
+ names->names = nnames;
+ } else {
+ free(nelt);
+ free(nlength);
+ free(nnames);
+ return AllocError;
+ }
+ }
+ names->length[index] = length;
+ names->names[index] = nelt;
+ strncpy(nelt, name, length);
+ nelt[length] = '\0';
+ names->nnames++;
+ return Successful;
+}
diff --git a/libXfont/src/util/fontutil.c b/libXfont/src/util/fontutil.c index aa89ce01a..552a1e3df 100644 --- a/libXfont/src/util/fontutil.c +++ b/libXfont/src/util/fontutil.c @@ -1,413 +1,410 @@ -/* $Xorg: fontutil.c,v 1.4 2001/02/09 02:04:04 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/util/fontutil.c,v 3.6 2001/10/28 03:32:46 tsi Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> -#include <X11/fonts/FSproto.h> -#include <X11/fonts/fontutil.h> - -/* Define global here... doesn't hurt the servers, and avoids - unresolved references in font clients. */ - -static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE; -int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE; - -void -GetGlyphs(FontPtr font, - unsigned long count, - unsigned char *chars, - FontEncoding fontEncoding, - unsigned long *glyphcount, /* RETURN */ - CharInfoPtr *glyphs) /* RETURN */ -{ - (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs); -} - -#define MIN(a,b) ((a)<(b)?(a):(b)) -#define MAX(a,b) ((a)>(b)?(a):(b)) - -void -QueryGlyphExtents(FontPtr pFont, - CharInfoPtr *charinfo, - unsigned long count, - ExtentInfoRec *info) -{ - register unsigned long i; - xCharInfo *pCI; - - info->drawDirection = pFont->info.drawDirection; - - info->fontAscent = pFont->info.fontAscent; - info->fontDescent = pFont->info.fontDescent; - - if (count != 0) { - - pCI = &((*charinfo)->metrics); charinfo++; - /* ignore nonexisting characters when calculating text extents */ - if ( !((pCI->characterWidth == 0) - && (pCI->rightSideBearing == 0) - && (pCI->leftSideBearing == 0) - && (pCI->ascent == 0) - && (pCI->descent == 0)) ) { - info->overallAscent = pCI->ascent; - info->overallDescent = pCI->descent; - info->overallLeft = pCI->leftSideBearing; - info->overallRight = pCI->rightSideBearing; - info->overallWidth = pCI->characterWidth; - } - - if (pFont->info.constantMetrics && pFont->info.noOverlap) { - info->overallWidth *= count; - info->overallRight += (info->overallWidth - - pCI->characterWidth); - } else { - for (i = 1; i < count; i++) { - pCI = &((*charinfo)->metrics); charinfo++; - /* ignore nonexisting characters when calculating extents */ - if ( !((pCI->characterWidth == 0) - && (pCI->rightSideBearing == 0) - && (pCI->leftSideBearing == 0) - && (pCI->ascent == 0) - && (pCI->descent == 0)) ) { - info->overallAscent = MAX( - info->overallAscent, - pCI->ascent); - info->overallDescent = MAX( - info->overallDescent, - pCI->descent); - info->overallLeft = MIN( - info->overallLeft, - info->overallWidth + pCI->leftSideBearing); - info->overallRight = MAX( - info->overallRight, - info->overallWidth + pCI->rightSideBearing); - /* - * yes, this order is correct; overallWidth IS incremented - * last - */ - info->overallWidth += pCI->characterWidth; - } - } - } - } else { - info->overallAscent = 0; - info->overallDescent = 0; - info->overallWidth = 0; - info->overallLeft = 0; - info->overallRight = 0; - } -} - -Bool -QueryTextExtents(FontPtr pFont, - unsigned long count, - unsigned char *chars, - ExtentInfoRec *info) -{ - xCharInfo **charinfo; - unsigned long n; - FontEncoding encoding; - int cm; - int i; - unsigned long t; - xCharInfo *defaultChar = 0; - unsigned char defc[2]; - int firstReal; - - charinfo = malloc(count * sizeof(xCharInfo *)); - if (!charinfo) - return FALSE; - encoding = TwoD16Bit; - if (pFont->info.lastRow == 0) - encoding = Linear16Bit; - (*pFont->get_metrics) (pFont, count, chars, encoding, &n, charinfo); - - /* Do default character substitution as get_metrics doesn't */ - -#define IsNonExistentChar(ci) (!(ci) || \ - ((ci)->ascent == 0 && \ - (ci)->descent == 0 && \ - (ci)->leftSideBearing == 0 && \ - (ci)->rightSideBearing == 0 && \ - (ci)->characterWidth == 0)) - - firstReal = n; - defc[0] = pFont->info.defaultCh >> 8; - defc[1] = pFont->info.defaultCh; - (*pFont->get_metrics) (pFont, 1, defc, encoding, &t, &defaultChar); - if ((IsNonExistentChar (defaultChar))) - defaultChar = 0; - for (i = 0; i < n; i++) - { - if ((IsNonExistentChar (charinfo[i]))) - { - if (!defaultChar) - continue; - charinfo[i] = defaultChar; - } - if (firstReal == n) - firstReal = i; - } - cm = pFont->info.constantMetrics; - pFont->info.constantMetrics = FALSE; - QueryGlyphExtents(pFont, (CharInfoPtr*) charinfo + firstReal, - n - firstReal, info); - pFont->info.constantMetrics = cm; - free(charinfo); - return TRUE; -} - -Bool -ParseGlyphCachingMode(char *str) -{ - if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF; - else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS; - else if (!strcmp(str, "16")) defaultGlyphCachingMode = CACHE_16_BIT_GLYPHS; - else return FALSE; - return TRUE; -} - -void -InitGlyphCaching(void) -{ - /* Set glyphCachingMode to the mode the server hopes to - support. DDX drivers that do not support the requested level - of glyph caching can call SetGlyphCachingMode to lower the - level of support. - */ - - glyphCachingMode = defaultGlyphCachingMode; -} - -/* ddxen can call SetGlyphCachingMode to inform us of what level of glyph - * caching they can support. - */ -void -SetGlyphCachingMode(int newmode) -{ - if ( (glyphCachingMode > newmode) && (newmode >= 0) ) - glyphCachingMode = newmode; -} - -#define range_alloc_granularity 16 -#define mincharp(p) ((p)->min_char_low + ((p)->min_char_high << 8)) -#define maxcharp(p) ((p)->max_char_low + ((p)->max_char_high << 8)) - -/* add_range(): Add range to a list of ranges, with coalescence */ -int -add_range(fsRange *newrange, - int *nranges, - fsRange **range, - Bool charset_subset) -{ - int first, last, middle; - unsigned long keymin, keymax; - unsigned long ptrmin = 0, ptrmax = 0; - fsRange *ptr = NULL, *ptr1, *ptr2, *endptr; - - /* There are two different ways to treat ranges: - - 1) Charset subsetting (support of the HP XLFD enhancements), in - which a range of 0x1234,0x3456 means all numbers between - 0x1234 and 0x3456, and in which min and max might be swapped. - - 2) Row/column ranges, in which a range of 0x1234,0x3456 means the - ranges 0x1234-0x1256, 0x1334-0x1356, ... , 0x3434-0x3456. - This is for support of glyph caching. - - The choice of treatment is selected with the "charset_subset" - flag */ - - /* If newrange covers multiple rows; break up the rows */ - if (!charset_subset && newrange->min_char_high != newrange->max_char_high) - { - int i, err = 0; - fsRange temprange; - for (i = newrange->min_char_high; - i <= newrange->max_char_high; - i++) - { - temprange.min_char_low = newrange->min_char_low; - temprange.max_char_low = newrange->max_char_low; - temprange.min_char_high = temprange.max_char_high = i; - err = add_range(&temprange, nranges, range, charset_subset); - if (err != Successful) break; - } - return err; - } - - keymin = mincharp(newrange); - keymax = maxcharp(newrange); - - if (charset_subset && keymin > keymax) - { - unsigned long temp = keymin; - keymin = keymax; - keymax = temp; - } - - /* add_range() maintains a sorted list; this makes possible coalescence - and binary searches */ - - /* Binary search for a range with which the new range can merge */ - - first = middle = 0; - last = *nranges - 1; - while (last >= first) - { - middle = (first + last) / 2; - ptr = (*range) + middle; - ptrmin = mincharp(ptr); - ptrmax = maxcharp(ptr); - - if (ptrmin > 0 && keymax < ptrmin - 1) last = middle - 1; - else if (keymin > ptrmax + 1) first = middle + 1; - else if (!charset_subset) - { - /* We might have a range with which to merge... IF the - result doesn't cross rows */ - if (newrange->min_char_high != ptr->min_char_high) - last = first - 1; /* Force adding a new range */ - break; - } - else break; /* We have at least one range with which we can merge */ - } - - if (last < first) - { - /* Search failed; we need to add a new range to the list. */ - - /* Grow the list if necessary */ - if (*nranges == 0 || *range == (fsRange *)0) - { - *range = malloc(range_alloc_granularity * SIZEOF(fsRange)); - *nranges = 0; - } - else if (!(*nranges % range_alloc_granularity)) - { - *range = realloc(*range, (*nranges + range_alloc_granularity) * - SIZEOF(fsRange)); - } - - /* If alloc failed, just return a null list */ - if (*range == (fsRange *)0) - { - *nranges = 0; - return AllocError; - } - - /* Should new entry go *at* or *after* ptr? */ - ptr = (*range) + middle; - if (middle < *nranges && keymin > ptrmin) ptr++; /* after */ - - /* Open up a space for our new range */ - memmove((char *)(ptr + 1), - (char *)ptr, - (char *)(*range + *nranges) - (char *)ptr); - - /* Insert the new range */ - ptr->min_char_low = keymin & 0xff; - ptr->min_char_high = keymin >> 8; - ptr->max_char_low = keymax & 0xff; - ptr->max_char_high = keymax >> 8; - - /* Update range count */ - (*nranges)++; - - /* Done */ - return Successful; - } - - /* Join our new range to that pointed to by "ptr" */ - if (keymin < ptrmin) - { - ptr->min_char_low = keymin & 0xff; - ptr->min_char_high = keymin >> 8; - } - if (keymax > ptrmax) - { - ptr->max_char_low = keymax & 0xff; - ptr->max_char_high = keymax >> 8; - } - - ptrmin = mincharp(ptr); - ptrmax = maxcharp(ptr); - - endptr = *range + *nranges; - - for (ptr1 = ptr; ptr1 >= *range; ptr1--) - { - if (ptrmin <= maxcharp(ptr1) + 1) - { - if (!charset_subset && ptr->min_char_high != ptr1->min_char_high) - break; - if (ptrmin >= mincharp(ptr1)) - ptrmin = mincharp(ptr1); - } - else break; - } - for (ptr2 = ptr; ptr2 < endptr; ptr2++) - { - if ((ptr2->min_char_low == 0 && ptr2->min_char_high == 0) || - ptrmax >= mincharp(ptr2) - 1) - { - if (!charset_subset && ptr->min_char_high != ptr2->min_char_high) - break; - if (ptrmax <= maxcharp(ptr2)) - ptrmax = maxcharp(ptr2); - } - else break; - } - - /* We need to coalesce ranges between ptr1 and ptr2 exclusive */ - ptr1++; - ptr2--; - if (ptr1 != ptr2) - { - memmove(ptr1, ptr2, (char *)endptr - (char *)ptr2); - *nranges -= (ptr2 - ptr1); - } - - /* Write the new range into the range list */ - ptr1->min_char_low = ptrmin & 0xff; - ptr1->min_char_high = ptrmin >> 8; - ptr1->max_char_low = ptrmax & 0xff; - ptr1->max_char_high = ptrmax >> 8; - - return Successful; -} +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/fontutil.h>
+
+/* Define global here... doesn't hurt the servers, and avoids
+ unresolved references in font clients. */
+
+static int defaultGlyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
+int glyphCachingMode = DEFAULT_GLYPH_CACHING_MODE;
+
+void
+GetGlyphs(FontPtr font,
+ unsigned long count,
+ unsigned char *chars,
+ FontEncoding fontEncoding,
+ unsigned long *glyphcount, /* RETURN */
+ CharInfoPtr *glyphs) /* RETURN */
+{
+ (*font->get_glyphs) (font, count, chars, fontEncoding, glyphcount, glyphs);
+}
+
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+void
+QueryGlyphExtents(FontPtr pFont,
+ CharInfoPtr *charinfo,
+ unsigned long count,
+ ExtentInfoRec *info)
+{
+ register unsigned long i;
+ xCharInfo *pCI;
+
+ info->drawDirection = pFont->info.drawDirection;
+
+ info->fontAscent = pFont->info.fontAscent;
+ info->fontDescent = pFont->info.fontDescent;
+
+ if (count != 0) {
+
+ pCI = &((*charinfo)->metrics); charinfo++;
+ /* ignore nonexisting characters when calculating text extents */
+ if ( !((pCI->characterWidth == 0)
+ && (pCI->rightSideBearing == 0)
+ && (pCI->leftSideBearing == 0)
+ && (pCI->ascent == 0)
+ && (pCI->descent == 0)) ) {
+ info->overallAscent = pCI->ascent;
+ info->overallDescent = pCI->descent;
+ info->overallLeft = pCI->leftSideBearing;
+ info->overallRight = pCI->rightSideBearing;
+ info->overallWidth = pCI->characterWidth;
+ }
+
+ if (pFont->info.constantMetrics && pFont->info.noOverlap) {
+ info->overallWidth *= count;
+ info->overallRight += (info->overallWidth -
+ pCI->characterWidth);
+ } else {
+ for (i = 1; i < count; i++) {
+ pCI = &((*charinfo)->metrics); charinfo++;
+ /* ignore nonexisting characters when calculating extents */
+ if ( !((pCI->characterWidth == 0)
+ && (pCI->rightSideBearing == 0)
+ && (pCI->leftSideBearing == 0)
+ && (pCI->ascent == 0)
+ && (pCI->descent == 0)) ) {
+ info->overallAscent = MAX(
+ info->overallAscent,
+ pCI->ascent);
+ info->overallDescent = MAX(
+ info->overallDescent,
+ pCI->descent);
+ info->overallLeft = MIN(
+ info->overallLeft,
+ info->overallWidth + pCI->leftSideBearing);
+ info->overallRight = MAX(
+ info->overallRight,
+ info->overallWidth + pCI->rightSideBearing);
+ /*
+ * yes, this order is correct; overallWidth IS incremented
+ * last
+ */
+ info->overallWidth += pCI->characterWidth;
+ }
+ }
+ }
+ } else {
+ info->overallAscent = 0;
+ info->overallDescent = 0;
+ info->overallWidth = 0;
+ info->overallLeft = 0;
+ info->overallRight = 0;
+ }
+}
+
+Bool
+QueryTextExtents(FontPtr pFont,
+ unsigned long count,
+ unsigned char *chars,
+ ExtentInfoRec *info)
+{
+ xCharInfo **charinfo;
+ unsigned long n;
+ FontEncoding encoding;
+ int cm;
+ int i;
+ unsigned long t;
+ xCharInfo *defaultChar = 0;
+ unsigned char defc[2];
+ int firstReal;
+
+ charinfo = malloc(count * sizeof(xCharInfo *));
+ if (!charinfo)
+ return FALSE;
+ encoding = TwoD16Bit;
+ if (pFont->info.lastRow == 0)
+ encoding = Linear16Bit;
+ (*pFont->get_metrics) (pFont, count, chars, encoding, &n, charinfo);
+
+ /* Do default character substitution as get_metrics doesn't */
+
+#define IsNonExistentChar(ci) (!(ci) || \
+ ((ci)->ascent == 0 && \
+ (ci)->descent == 0 && \
+ (ci)->leftSideBearing == 0 && \
+ (ci)->rightSideBearing == 0 && \
+ (ci)->characterWidth == 0))
+
+ firstReal = n;
+ defc[0] = pFont->info.defaultCh >> 8;
+ defc[1] = pFont->info.defaultCh;
+ (*pFont->get_metrics) (pFont, 1, defc, encoding, &t, &defaultChar);
+ if ((IsNonExistentChar (defaultChar)))
+ defaultChar = 0;
+ for (i = 0; i < n; i++)
+ {
+ if ((IsNonExistentChar (charinfo[i])))
+ {
+ if (!defaultChar)
+ continue;
+ charinfo[i] = defaultChar;
+ }
+ if (firstReal == n)
+ firstReal = i;
+ }
+ cm = pFont->info.constantMetrics;
+ pFont->info.constantMetrics = FALSE;
+ QueryGlyphExtents(pFont, (CharInfoPtr*) charinfo + firstReal,
+ n - firstReal, info);
+ pFont->info.constantMetrics = cm;
+ free(charinfo);
+ return TRUE;
+}
+
+Bool
+ParseGlyphCachingMode(char *str)
+{
+ if (!strcmp(str, "none")) defaultGlyphCachingMode = CACHING_OFF;
+ else if (!strcmp(str, "all")) defaultGlyphCachingMode = CACHE_ALL_GLYPHS;
+ else if (!strcmp(str, "16")) defaultGlyphCachingMode = CACHE_16_BIT_GLYPHS;
+ else return FALSE;
+ return TRUE;
+}
+
+void
+InitGlyphCaching(void)
+{
+ /* Set glyphCachingMode to the mode the server hopes to
+ support. DDX drivers that do not support the requested level
+ of glyph caching can call SetGlyphCachingMode to lower the
+ level of support.
+ */
+
+ glyphCachingMode = defaultGlyphCachingMode;
+}
+
+/* ddxen can call SetGlyphCachingMode to inform us of what level of glyph
+ * caching they can support.
+ */
+void
+SetGlyphCachingMode(int newmode)
+{
+ if ( (glyphCachingMode > newmode) && (newmode >= 0) )
+ glyphCachingMode = newmode;
+}
+
+#define range_alloc_granularity 16
+#define mincharp(p) ((p)->min_char_low + ((p)->min_char_high << 8))
+#define maxcharp(p) ((p)->max_char_low + ((p)->max_char_high << 8))
+
+/* add_range(): Add range to a list of ranges, with coalescence */
+int
+add_range(fsRange *newrange,
+ int *nranges,
+ fsRange **range,
+ Bool charset_subset)
+{
+ int first, last, middle;
+ unsigned long keymin, keymax;
+ unsigned long ptrmin = 0, ptrmax = 0;
+ fsRange *ptr = NULL, *ptr1, *ptr2, *endptr;
+
+ /* There are two different ways to treat ranges:
+
+ 1) Charset subsetting (support of the HP XLFD enhancements), in
+ which a range of 0x1234,0x3456 means all numbers between
+ 0x1234 and 0x3456, and in which min and max might be swapped.
+
+ 2) Row/column ranges, in which a range of 0x1234,0x3456 means the
+ ranges 0x1234-0x1256, 0x1334-0x1356, ... , 0x3434-0x3456.
+ This is for support of glyph caching.
+
+ The choice of treatment is selected with the "charset_subset"
+ flag */
+
+ /* If newrange covers multiple rows; break up the rows */
+ if (!charset_subset && newrange->min_char_high != newrange->max_char_high)
+ {
+ int i, err = 0;
+ fsRange temprange;
+ for (i = newrange->min_char_high;
+ i <= newrange->max_char_high;
+ i++)
+ {
+ temprange.min_char_low = newrange->min_char_low;
+ temprange.max_char_low = newrange->max_char_low;
+ temprange.min_char_high = temprange.max_char_high = i;
+ err = add_range(&temprange, nranges, range, charset_subset);
+ if (err != Successful) break;
+ }
+ return err;
+ }
+
+ keymin = mincharp(newrange);
+ keymax = maxcharp(newrange);
+
+ if (charset_subset && keymin > keymax)
+ {
+ unsigned long temp = keymin;
+ keymin = keymax;
+ keymax = temp;
+ }
+
+ /* add_range() maintains a sorted list; this makes possible coalescence
+ and binary searches */
+
+ /* Binary search for a range with which the new range can merge */
+
+ first = middle = 0;
+ last = *nranges - 1;
+ while (last >= first)
+ {
+ middle = (first + last) / 2;
+ ptr = (*range) + middle;
+ ptrmin = mincharp(ptr);
+ ptrmax = maxcharp(ptr);
+
+ if (ptrmin > 0 && keymax < ptrmin - 1) last = middle - 1;
+ else if (keymin > ptrmax + 1) first = middle + 1;
+ else if (!charset_subset)
+ {
+ /* We might have a range with which to merge... IF the
+ result doesn't cross rows */
+ if (newrange->min_char_high != ptr->min_char_high)
+ last = first - 1; /* Force adding a new range */
+ break;
+ }
+ else break; /* We have at least one range with which we can merge */
+ }
+
+ if (last < first)
+ {
+ /* Search failed; we need to add a new range to the list. */
+
+ /* Grow the list if necessary */
+ if (*nranges == 0 || *range == (fsRange *)0)
+ {
+ *range = malloc(range_alloc_granularity * SIZEOF(fsRange));
+ *nranges = 0;
+ }
+ else if (!(*nranges % range_alloc_granularity))
+ {
+ *range = realloc(*range, (*nranges + range_alloc_granularity) *
+ SIZEOF(fsRange));
+ }
+
+ /* If alloc failed, just return a null list */
+ if (*range == (fsRange *)0)
+ {
+ *nranges = 0;
+ return AllocError;
+ }
+
+ /* Should new entry go *at* or *after* ptr? */
+ ptr = (*range) + middle;
+ if (middle < *nranges && keymin > ptrmin) ptr++; /* after */
+
+ /* Open up a space for our new range */
+ memmove((char *)(ptr + 1),
+ (char *)ptr,
+ (char *)(*range + *nranges) - (char *)ptr);
+
+ /* Insert the new range */
+ ptr->min_char_low = keymin & 0xff;
+ ptr->min_char_high = keymin >> 8;
+ ptr->max_char_low = keymax & 0xff;
+ ptr->max_char_high = keymax >> 8;
+
+ /* Update range count */
+ (*nranges)++;
+
+ /* Done */
+ return Successful;
+ }
+
+ /* Join our new range to that pointed to by "ptr" */
+ if (keymin < ptrmin)
+ {
+ ptr->min_char_low = keymin & 0xff;
+ ptr->min_char_high = keymin >> 8;
+ }
+ if (keymax > ptrmax)
+ {
+ ptr->max_char_low = keymax & 0xff;
+ ptr->max_char_high = keymax >> 8;
+ }
+
+ ptrmin = mincharp(ptr);
+ ptrmax = maxcharp(ptr);
+
+ endptr = *range + *nranges;
+
+ for (ptr1 = ptr; ptr1 >= *range; ptr1--)
+ {
+ if (ptrmin <= maxcharp(ptr1) + 1)
+ {
+ if (!charset_subset && ptr->min_char_high != ptr1->min_char_high)
+ break;
+ if (ptrmin >= mincharp(ptr1))
+ ptrmin = mincharp(ptr1);
+ }
+ else break;
+ }
+ for (ptr2 = ptr; ptr2 < endptr; ptr2++)
+ {
+ if ((ptr2->min_char_low == 0 && ptr2->min_char_high == 0) ||
+ ptrmax >= mincharp(ptr2) - 1)
+ {
+ if (!charset_subset && ptr->min_char_high != ptr2->min_char_high)
+ break;
+ if (ptrmax <= maxcharp(ptr2))
+ ptrmax = maxcharp(ptr2);
+ }
+ else break;
+ }
+
+ /* We need to coalesce ranges between ptr1 and ptr2 exclusive */
+ ptr1++;
+ ptr2--;
+ if (ptr1 != ptr2)
+ {
+ memmove(ptr1, ptr2, (char *)endptr - (char *)ptr2);
+ *nranges -= (ptr2 - ptr1);
+ }
+
+ /* Write the new range into the range list */
+ ptr1->min_char_low = ptrmin & 0xff;
+ ptr1->min_char_high = ptrmin >> 8;
+ ptr1->max_char_low = ptrmax & 0xff;
+ ptr1->max_char_high = ptrmax >> 8;
+
+ return Successful;
+}
diff --git a/libXfont/src/util/fontxlfd.c b/libXfont/src/util/fontxlfd.c index 664d7598f..26ef042e7 100644 --- a/libXfont/src/util/fontxlfd.c +++ b/libXfont/src/util/fontxlfd.c @@ -1,635 +1,632 @@ -/* $Xorg: fontxlfd.c,v 1.4 2001/02/09 02:04:04 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/util/fontxlfd.c,v 3.16tsi Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <float.h> -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> -#include <X11/fonts/fontxlfd.h> -#include <X11/fonts/fontutil.h> -#include <X11/Xos.h> -#include <math.h> -#include <stdlib.h> -#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV) -#define NO_LOCALE -#endif -#ifndef NO_LOCALE -#include <locale.h> -#endif -#include <ctype.h> -#include <stdio.h> /* for sprintf() */ - -static char * -GetInt(char *ptr, int *val) -{ - if (*ptr == '*') { - *val = -1; - ptr++; - } else - for (*val = 0; *ptr >= '0' && *ptr <= '9';) - *val = *val * 10 + *ptr++ - '0'; - if (*ptr == '-') - return ptr; - return (char *) 0; -} - -#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8)) -#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8)) - - -#ifndef NO_LOCALE -static struct lconv *locale = 0; -#endif -static char *radix = ".", *plus = "+", *minus = "-"; - -static char * -readreal(char *ptr, double *result) -{ - char buffer[80], *p1, *p2; - -#ifndef NO_LOCALE - /* Figure out what symbols apply in this locale */ - - if (!locale) - { - locale = localeconv(); - if (locale->decimal_point && *locale->decimal_point) - radix = locale->decimal_point; - if (locale->positive_sign && *locale->positive_sign) - plus = locale->positive_sign; - if (locale->negative_sign && *locale->negative_sign) - minus = locale->negative_sign; - } -#endif - /* Copy the first 80 chars of ptr into our local buffer, changing - symbols as needed. */ - for (p1 = ptr, p2 = buffer; - *p1 && (p2 - buffer) < sizeof(buffer) - 1; - p1++, p2++) - { - switch(*p1) - { - case '~': *p2 = *minus; break; - case '+': *p2 = *plus; break; - case '.': *p2 = *radix; break; - default: *p2 = *p1; - } - } - *p2 = 0; - - /* Now we have something that strtod() can interpret... do it. */ - *result = strtod(buffer, &p1); - /* Return NULL if failure, pointer past number if success */ - return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer)); -} - -static char * -xlfd_double_to_text(double value, char *buffer, int space_required) -{ - char formatbuf[40]; - register char *p1; - int ndigits, exponent; - -#ifndef NO_LOCALE - if (!locale) - { - locale = localeconv(); - if (locale->decimal_point && *locale->decimal_point) - radix = locale->decimal_point; - if (locale->positive_sign && *locale->positive_sign) - plus = locale->positive_sign; - if (locale->negative_sign && *locale->negative_sign) - minus = locale->negative_sign; - } -#endif - /* Compute a format to use to render the number */ - sprintf(formatbuf, "%%.%dle", XLFD_NDIGITS); - - if (space_required) - *buffer++ = ' '; - - /* Render the number using printf's idea of formatting */ - sprintf(buffer, formatbuf, value); - - /* Find and read the exponent value */ - for (p1 = buffer + strlen(buffer); - *p1-- != 'e' && p1[1] != 'E';); - exponent = atoi(p1 + 2); - if (value == 0.0) exponent = 0; - - /* Figure out how many digits are significant */ - while (p1 >= buffer && (!isdigit(*p1) || *p1 == '0')) p1--; - ndigits = 0; - while (p1 >= buffer) if (isdigit(*p1--)) ndigits++; - - /* Figure out notation to use */ - if (exponent >= XLFD_NDIGITS || ndigits - exponent > XLFD_NDIGITS + 1) - { - /* Scientific */ - sprintf(formatbuf, "%%.%dle", ndigits - 1); - sprintf(buffer, formatbuf, value); - } - else - { - /* Fixed */ - ndigits -= exponent + 1; - if (ndigits < 0) ndigits = 0; - sprintf(formatbuf, "%%.%dlf", ndigits); - sprintf(buffer, formatbuf, value); - if (exponent < 0) - { - p1 = buffer; - while (*p1 && *p1 != '0') p1++; - while (*p1++) p1[-1] = *p1; - } - } - - /* Last step, convert the locale-specific sign and radix characters - to our own. */ - for (p1 = buffer; *p1; p1++) - { - if (*p1 == *minus) *p1 = '~'; - else if (*p1 == *plus) *p1 = '+'; - else if (*p1 == *radix) *p1 = '.'; - } - - return buffer - space_required; -} - -double -xlfd_round_double(double x) -{ - /* Utility for XLFD users to round numbers to XLFD_NDIGITS - significant digits. How do you round to n significant digits on - a binary machine? */ - -#if defined(i386) || defined(__i386__) || \ - defined(ia64) || defined(__ia64__) || \ - defined(__alpha__) || defined(__alpha) || \ - defined(__hppa__) || \ - defined(__amd64__) || defined(__amd64) || \ - defined(sgi) - -/* if we have IEEE 754 fp, we can round to binary digits... */ - -#if (FLT_RADIX == 2) && (DBL_DIG == 15) && (DBL_MANT_DIG == 53) - -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 -#endif -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 -#endif - -/* convert # of decimal digits to # of binary digits */ -#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5)) - - union conv_d { - double d; - unsigned char b[8]; - } d; - int i,j,k,d_exp; - - if (x == 0) - return x; - - /* do minor sanity check for IEEE 754 fp and correct byte order */ - d.d = 1.0; - if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) { - - /* - * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits - */ - - d.d = x; - d_exp = (d.b[7] << 4) | (d.b[6] >> 4); - - i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3; - j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07); - for (; i<7; i++) { - k = d.b[i] + j; - d.b[i] = k&0xff; - if (k & 0x100) j = 1; - else break; - } - if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) { - /* mantissa overflow: increment exponent */ - d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1); - d.b[7] = d_exp >> 4; - d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4); - } - - i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3; - j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07); - d.b[i] &= ~(j-1); - for (;--i>=0;) d.b[i] = 0; - - return d.d; - } - else -#endif -#endif /* i386 || __i386__ */ - { - /* - * If not IEEE 754: Let printf() do it for you. - */ - - char formatbuf[40], buffer[40]; - - sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS); - sprintf(buffer, formatbuf, x); - return atof(buffer); - } -} - -static char * -GetMatrix(char *ptr, FontScalablePtr vals, int which) -{ - double *matrix; - - if (which == PIXELSIZE_MASK) - matrix = vals->pixel_matrix; - else if (which == POINTSIZE_MASK) - matrix = vals->point_matrix; - else return (char *)0; - - while (isspace(*ptr)) ptr++; - if (*ptr == '[') - { - /* This is a matrix containing real numbers. It would be nice - to use strtod() or sscanf() to read the numbers, but those - don't handle '~' for minus and we cannot force them to use a - "." for the radix. We'll have to do the hard work ourselves - (in readreal()). */ - - if ((ptr = readreal(++ptr, matrix + 0)) && - (ptr = readreal(ptr, matrix + 1)) && - (ptr = readreal(ptr, matrix + 2)) && - (ptr = readreal(ptr, matrix + 3))) - { - while (isspace(*ptr)) ptr++; - if (*ptr != ']') - ptr = (char *)0; - else - { - ptr++; - while (isspace(*ptr)) ptr++; - if (*ptr == '-') - { - if (which == POINTSIZE_MASK) - vals->values_supplied |= POINTSIZE_ARRAY; - else - vals->values_supplied |= PIXELSIZE_ARRAY; - } - else ptr = (char *)0; - } - } - } - else - { - int value; - if ((ptr = GetInt(ptr, &value))) - { - vals->values_supplied &= ~which; - if (value > 0) - { - matrix[3] = (double)value; - if (which == POINTSIZE_MASK) - { - matrix[3] /= 10.0; - vals->values_supplied |= POINTSIZE_SCALAR; - } - else - vals->values_supplied |= PIXELSIZE_SCALAR; - /* If we're concocting the pixelsize array from a scalar, - we will need to normalize element 0 for the pixel shape. - This is done in FontFileCompleteXLFD(). */ - matrix[0] = matrix[3]; - matrix[1] = matrix[2] = 0.0; - } - else if (value < 0) - { - if (which == POINTSIZE_MASK) - vals->values_supplied |= POINTSIZE_WILDCARD; - else - vals->values_supplied |= PIXELSIZE_WILDCARD; - } - } - } - return ptr; -} - - -static void -append_ranges(char *fname, int nranges, fsRange *ranges) -{ - if (nranges) - { - int i; - - strcat(fname, "["); - for (i = 0; i < nranges && strlen(fname) < 1010; i++) - { - if (i) strcat(fname, " "); - sprintf(fname + strlen(fname), "%d", - minchar(ranges[i])); - if (ranges[i].min_char_low == - ranges[i].max_char_low && - ranges[i].min_char_high == - ranges[i].max_char_high) continue; - sprintf(fname + strlen(fname), "_%d", - maxchar(ranges[i])); - } - strcat(fname, "]"); - } -} - -Bool -FontParseXLFDName(char *fname, FontScalablePtr vals, int subst) -{ - register char *ptr; - register char *ptr1, - *ptr2, - *ptr3, - *ptr4; - register char *ptr5; - FontScalableRec tmpvals; - char replaceChar = '0'; - char tmpBuf[1024]; - int spacingLen; - int l; - char *p; - - bzero(&tmpvals, sizeof(tmpvals)); - if (subst != FONT_XLFD_REPLACE_VALUE) - *vals = tmpvals; - - if (!(*(ptr = fname) == '-' || (*ptr++ == '*' && *ptr == '-')) || /* fndry */ - !(ptr = strchr(ptr + 1, '-')) || /* family_name */ - !(ptr1 = ptr = strchr(ptr + 1, '-')) || /* weight_name */ - !(ptr = strchr(ptr + 1, '-')) || /* slant */ - !(ptr = strchr(ptr + 1, '-')) || /* setwidth_name */ - !(ptr = strchr(ptr + 1, '-')) || /* add_style_name */ - !(ptr = strchr(ptr + 1, '-')) || /* pixel_size */ - !(ptr = GetMatrix(ptr + 1, &tmpvals, PIXELSIZE_MASK)) || - !(ptr2 = ptr = GetMatrix(ptr + 1, &tmpvals, POINTSIZE_MASK)) || - !(ptr = GetInt(ptr + 1, &tmpvals.x)) || /* resolution_x */ - !(ptr3 = ptr = GetInt(ptr + 1, &tmpvals.y)) || /* resolution_y */ - !(ptr4 = ptr = strchr(ptr + 1, '-')) || /* spacing */ - !(ptr5 = ptr = GetInt(ptr + 1, &tmpvals.width)) || /* average_width */ - !(ptr = strchr(ptr + 1, '-')) || /* charset_registry */ - strchr(ptr + 1, '-'))/* charset_encoding */ - return FALSE; - - /* Lop off HP charset subsetting enhancement. Interpreting this - field requires allocating some space in which to return the - results. So, to prevent memory leaks, this procedure will simply - lop off and ignore charset subsetting, and initialize the - relevant vals fields to zero. It's up to the caller to make its - own call to FontParseRanges() if it's interested in the charset - subsetting. */ - - if (subst != FONT_XLFD_REPLACE_NONE && - (p = strchr(strrchr(fname, '-'), '['))) - { - tmpvals.values_supplied |= CHARSUBSET_SPECIFIED; - *p = '\0'; - } - - /* Fill in deprecated fields for the benefit of rasterizers that care - about them. */ - tmpvals.pixel = (tmpvals.pixel_matrix[3] >= 0) ? - (int)(tmpvals.pixel_matrix[3] + .5) : - (int)(tmpvals.pixel_matrix[3] - .5); - tmpvals.point = (tmpvals.point_matrix[3] >= 0) ? - (int)(tmpvals.point_matrix[3] * 10 + .5) : - (int)(tmpvals.point_matrix[3] * 10 - .5); - - spacingLen = ptr4 - ptr3 + 1; - - switch (subst) { - case FONT_XLFD_REPLACE_NONE: - *vals = tmpvals; - break; - case FONT_XLFD_REPLACE_STAR: - replaceChar = '*'; - case FONT_XLFD_REPLACE_ZERO: - strcpy(tmpBuf, ptr2); - ptr5 = tmpBuf + (ptr5 - ptr2); - ptr3 = tmpBuf + (ptr3 - ptr2); - ptr2 = tmpBuf; - ptr = ptr1 + 1; - - ptr = strchr(ptr, '-') + 1; /* skip weight */ - ptr = strchr(ptr, '-') + 1; /* skip slant */ - ptr = strchr(ptr, '-') + 1; /* skip setwidth_name */ - ptr = strchr(ptr, '-') + 1; /* skip add_style_name */ - - if ((ptr - fname) + spacingLen + strlen(ptr5) + 10 >= (unsigned)1024) - return FALSE; - *ptr++ = replaceChar; - *ptr++ = '-'; - *ptr++ = replaceChar; - *ptr++ = '-'; - *ptr++ = '*'; - *ptr++ = '-'; - *ptr++ = '*'; - if (spacingLen > 2) - { - memmove(ptr, ptr3, spacingLen); - ptr += spacingLen; - } - else - { - *ptr++ = '-'; - *ptr++ = '*'; - *ptr++ = '-'; - } - *ptr++ = replaceChar; - strcpy(ptr, ptr5); - *vals = tmpvals; - break; - case FONT_XLFD_REPLACE_VALUE: - if (vals->values_supplied & PIXELSIZE_MASK) - { - 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) - { - 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->x >= 0) - tmpvals.x = vals->x; - if (vals->y >= 0) - tmpvals.y = vals->y; - if (vals->width >= 0) - tmpvals.width = vals->width; - else if (vals->width < -1) /* overload: -1 means wildcard */ - tmpvals.width = -vals->width; - - - p = ptr1 + 1; /* weight field */ - l = strchr(p, '-') - p; - sprintf(tmpBuf, "%*.*s", l, l, p); - - p += l + 1; /* slant field */ - l = strchr(p, '-') - p; - sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p); - - p += l + 1; /* setwidth_name */ - l = strchr(p, '-') - p; - sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p); - - p += l + 1; /* add_style_name field */ - l = strchr(p, '-') - p; - sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p); - - strcat(tmpBuf, "-"); - if ((tmpvals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY) - { - char buffer[80]; - strcat(tmpBuf, "["); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0], - buffer, 0)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1], - buffer, 1)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2], - buffer, 1)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3], - buffer, 1)); - strcat(tmpBuf, "]"); - } - else - { - sprintf(tmpBuf + strlen(tmpBuf), "%d", - (int)(tmpvals.pixel_matrix[3] + .5)); - } - strcat(tmpBuf, "-"); - if ((tmpvals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY) - { - char buffer[80]; - strcat(tmpBuf, "["); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0], - buffer, 0)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1], - buffer, 1)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2], - buffer, 1)); - strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3], - buffer, 1)); - strcat(tmpBuf, "]"); - } - else - { - sprintf(tmpBuf + strlen(tmpBuf), "%d", - (int)(tmpvals.point_matrix[3] * 10.0 + .5)); - } - sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s", - tmpvals.x, tmpvals.y, - spacingLen, spacingLen, ptr3, tmpvals.width, ptr5); - strcpy(ptr1 + 1, tmpBuf); - if ((vals->values_supplied & CHARSUBSET_SPECIFIED) && !vals->nranges) - strcat(fname, "[]"); - else - append_ranges(fname, vals->nranges, vals->ranges); - break; - } - return TRUE; -} - -fsRange *FontParseRanges(char *name, int *nranges) -{ - int n; - unsigned long l; - char *p1, *p2; - fsRange *result = (fsRange *)0; - - name = strchr(name, '-'); - for (n = 1; name && n < 14; n++) - name = strchr(name + 1, '-'); - - *nranges = 0; - if (!name || !(p1 = strchr(name, '['))) return (fsRange *)0; - p1++; - - while (*p1 && *p1 != ']') - { - fsRange thisrange; - - l = strtol(p1, &p2, 0); - if (p2 == p1 || l > 0xffff) break; - thisrange.max_char_low = thisrange.min_char_low = l & 0xff; - thisrange.max_char_high = thisrange.min_char_high = l >> 8; - - p1 = p2; - if (*p1 == ']' || *p1 == ' ') - { - while (*p1 == ' ') p1++; - if (add_range(&thisrange, nranges, &result, TRUE) != Successful) - break; - } - else if (*p1 == '_') - { - l = strtol(++p1, &p2, 0); - if (p2 == p1 || l > 0xffff) break; - thisrange.max_char_low = l & 0xff; - thisrange.max_char_high = l >> 8; - p1 = p2; - if (*p1 == ']' || *p1 == ' ') - { - while (*p1 == ' ') p1++; - if (add_range(&thisrange, nranges, &result, TRUE) != Successful) - break; - } - } - else break; - } - - return result; -} +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <float.h>
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontxlfd.h>
+#include <X11/fonts/fontutil.h>
+#include <X11/Xos.h>
+#include <math.h>
+#include <stdlib.h>
+#if defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV)
+#define NO_LOCALE
+#endif
+#ifndef NO_LOCALE
+#include <locale.h>
+#endif
+#include <ctype.h>
+#include <stdio.h> /* for sprintf() */
+
+static char *
+GetInt(char *ptr, int *val)
+{
+ if (*ptr == '*') {
+ *val = -1;
+ ptr++;
+ } else
+ for (*val = 0; *ptr >= '0' && *ptr <= '9';)
+ *val = *val * 10 + *ptr++ - '0';
+ if (*ptr == '-')
+ return ptr;
+ return (char *) 0;
+}
+
+#define minchar(p) ((p).min_char_low + ((p).min_char_high << 8))
+#define maxchar(p) ((p).max_char_low + ((p).max_char_high << 8))
+
+
+#ifndef NO_LOCALE
+static struct lconv *locale = 0;
+#endif
+static char *radix = ".", *plus = "+", *minus = "-";
+
+static char *
+readreal(char *ptr, double *result)
+{
+ char buffer[80], *p1, *p2;
+
+#ifndef NO_LOCALE
+ /* Figure out what symbols apply in this locale */
+
+ if (!locale)
+ {
+ locale = localeconv();
+ if (locale->decimal_point && *locale->decimal_point)
+ radix = locale->decimal_point;
+ if (locale->positive_sign && *locale->positive_sign)
+ plus = locale->positive_sign;
+ if (locale->negative_sign && *locale->negative_sign)
+ minus = locale->negative_sign;
+ }
+#endif
+ /* Copy the first 80 chars of ptr into our local buffer, changing
+ symbols as needed. */
+ for (p1 = ptr, p2 = buffer;
+ *p1 && (p2 - buffer) < sizeof(buffer) - 1;
+ p1++, p2++)
+ {
+ switch(*p1)
+ {
+ case '~': *p2 = *minus; break;
+ case '+': *p2 = *plus; break;
+ case '.': *p2 = *radix; break;
+ default: *p2 = *p1;
+ }
+ }
+ *p2 = 0;
+
+ /* Now we have something that strtod() can interpret... do it. */
+ *result = strtod(buffer, &p1);
+ /* Return NULL if failure, pointer past number if success */
+ return (p1 == buffer) ? (char *)0 : (ptr + (p1 - buffer));
+}
+
+static char *
+xlfd_double_to_text(double value, char *buffer, int space_required)
+{
+ char formatbuf[40];
+ register char *p1;
+ int ndigits, exponent;
+
+#ifndef NO_LOCALE
+ if (!locale)
+ {
+ locale = localeconv();
+ if (locale->decimal_point && *locale->decimal_point)
+ radix = locale->decimal_point;
+ if (locale->positive_sign && *locale->positive_sign)
+ plus = locale->positive_sign;
+ if (locale->negative_sign && *locale->negative_sign)
+ minus = locale->negative_sign;
+ }
+#endif
+ /* Compute a format to use to render the number */
+ sprintf(formatbuf, "%%.%dle", XLFD_NDIGITS);
+
+ if (space_required)
+ *buffer++ = ' ';
+
+ /* Render the number using printf's idea of formatting */
+ sprintf(buffer, formatbuf, value);
+
+ /* Find and read the exponent value */
+ for (p1 = buffer + strlen(buffer);
+ *p1-- != 'e' && p1[1] != 'E';);
+ exponent = atoi(p1 + 2);
+ if (value == 0.0) exponent = 0;
+
+ /* Figure out how many digits are significant */
+ while (p1 >= buffer && (!isdigit(*p1) || *p1 == '0')) p1--;
+ ndigits = 0;
+ while (p1 >= buffer) if (isdigit(*p1--)) ndigits++;
+
+ /* Figure out notation to use */
+ if (exponent >= XLFD_NDIGITS || ndigits - exponent > XLFD_NDIGITS + 1)
+ {
+ /* Scientific */
+ sprintf(formatbuf, "%%.%dle", ndigits - 1);
+ sprintf(buffer, formatbuf, value);
+ }
+ else
+ {
+ /* Fixed */
+ ndigits -= exponent + 1;
+ if (ndigits < 0) ndigits = 0;
+ sprintf(formatbuf, "%%.%dlf", ndigits);
+ sprintf(buffer, formatbuf, value);
+ if (exponent < 0)
+ {
+ p1 = buffer;
+ while (*p1 && *p1 != '0') p1++;
+ while (*p1++) p1[-1] = *p1;
+ }
+ }
+
+ /* Last step, convert the locale-specific sign and radix characters
+ to our own. */
+ for (p1 = buffer; *p1; p1++)
+ {
+ if (*p1 == *minus) *p1 = '~';
+ else if (*p1 == *plus) *p1 = '+';
+ else if (*p1 == *radix) *p1 = '.';
+ }
+
+ return buffer - space_required;
+}
+
+double
+xlfd_round_double(double x)
+{
+ /* Utility for XLFD users to round numbers to XLFD_NDIGITS
+ significant digits. How do you round to n significant digits on
+ a binary machine? */
+
+#if defined(i386) || defined(__i386__) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__alpha__) || defined(__alpha) || \
+ defined(__hppa__) || \
+ defined(__amd64__) || defined(__amd64) || \
+ defined(sgi)
+
+/* if we have IEEE 754 fp, we can round to binary digits... */
+
+#if (FLT_RADIX == 2) && (DBL_DIG == 15) && (DBL_MANT_DIG == 53)
+
+#ifndef M_LN2
+#define M_LN2 0.69314718055994530942
+#endif
+#ifndef M_LN10
+#define M_LN10 2.30258509299404568402
+#endif
+
+/* convert # of decimal digits to # of binary digits */
+#define XLFD_NDIGITS_2 ((int)(XLFD_NDIGITS * M_LN10 / M_LN2 + 0.5))
+
+ union conv_d {
+ double d;
+ unsigned char b[8];
+ } d;
+ int i,j,k,d_exp;
+
+ if (x == 0)
+ return x;
+
+ /* do minor sanity check for IEEE 754 fp and correct byte order */
+ d.d = 1.0;
+ if (sizeof(double) == 8 && d.b[7] == 0x3f && d.b[6] == 0xf0) {
+
+ /*
+ * this code will round IEEE 754 double to XLFD_NDIGITS_2 binary digits
+ */
+
+ d.d = x;
+ d_exp = (d.b[7] << 4) | (d.b[6] >> 4);
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ for (; i<7; i++) {
+ k = d.b[i] + j;
+ d.b[i] = k&0xff;
+ if (k & 0x100) j = 1;
+ else break;
+ }
+ if ((i==7) && ((d.b[6] & 0xf0) != ((d_exp<<4) & 0xf0))) {
+ /* mantissa overflow: increment exponent */
+ d_exp = (d_exp & 0x800 ) | ((d_exp & 0x7ff) + 1);
+ d.b[7] = d_exp >> 4;
+ d.b[6] = (d.b[6] & 0x0f) | (d_exp << 4);
+ }
+
+ i = (DBL_MANT_DIG-XLFD_NDIGITS_2) >> 3;
+ j = 1 << ((DBL_MANT_DIG-XLFD_NDIGITS_2) & 0x07);
+ d.b[i] &= ~(j-1);
+ for (;--i>=0;) d.b[i] = 0;
+
+ return d.d;
+ }
+ else
+#endif
+#endif /* i386 || __i386__ */
+ {
+ /*
+ * If not IEEE 754: Let printf() do it for you.
+ */
+
+ char formatbuf[40], buffer[40];
+
+ sprintf(formatbuf, "%%.%dlg", XLFD_NDIGITS);
+ sprintf(buffer, formatbuf, x);
+ return atof(buffer);
+ }
+}
+
+static char *
+GetMatrix(char *ptr, FontScalablePtr vals, int which)
+{
+ double *matrix;
+
+ if (which == PIXELSIZE_MASK)
+ matrix = vals->pixel_matrix;
+ else if (which == POINTSIZE_MASK)
+ matrix = vals->point_matrix;
+ else return (char *)0;
+
+ while (isspace(*ptr)) ptr++;
+ if (*ptr == '[')
+ {
+ /* This is a matrix containing real numbers. It would be nice
+ to use strtod() or sscanf() to read the numbers, but those
+ don't handle '~' for minus and we cannot force them to use a
+ "." for the radix. We'll have to do the hard work ourselves
+ (in readreal()). */
+
+ if ((ptr = readreal(++ptr, matrix + 0)) &&
+ (ptr = readreal(ptr, matrix + 1)) &&
+ (ptr = readreal(ptr, matrix + 2)) &&
+ (ptr = readreal(ptr, matrix + 3)))
+ {
+ while (isspace(*ptr)) ptr++;
+ if (*ptr != ']')
+ ptr = (char *)0;
+ else
+ {
+ ptr++;
+ while (isspace(*ptr)) ptr++;
+ if (*ptr == '-')
+ {
+ if (which == POINTSIZE_MASK)
+ vals->values_supplied |= POINTSIZE_ARRAY;
+ else
+ vals->values_supplied |= PIXELSIZE_ARRAY;
+ }
+ else ptr = (char *)0;
+ }
+ }
+ }
+ else
+ {
+ int value;
+ if ((ptr = GetInt(ptr, &value)))
+ {
+ vals->values_supplied &= ~which;
+ if (value > 0)
+ {
+ matrix[3] = (double)value;
+ if (which == POINTSIZE_MASK)
+ {
+ matrix[3] /= 10.0;
+ vals->values_supplied |= POINTSIZE_SCALAR;
+ }
+ else
+ vals->values_supplied |= PIXELSIZE_SCALAR;
+ /* If we're concocting the pixelsize array from a scalar,
+ we will need to normalize element 0 for the pixel shape.
+ This is done in FontFileCompleteXLFD(). */
+ matrix[0] = matrix[3];
+ matrix[1] = matrix[2] = 0.0;
+ }
+ else if (value < 0)
+ {
+ if (which == POINTSIZE_MASK)
+ vals->values_supplied |= POINTSIZE_WILDCARD;
+ else
+ vals->values_supplied |= PIXELSIZE_WILDCARD;
+ }
+ }
+ }
+ return ptr;
+}
+
+
+static void
+append_ranges(char *fname, int nranges, fsRange *ranges)
+{
+ if (nranges)
+ {
+ int i;
+
+ strcat(fname, "[");
+ for (i = 0; i < nranges && strlen(fname) < 1010; i++)
+ {
+ if (i) strcat(fname, " ");
+ sprintf(fname + strlen(fname), "%d",
+ minchar(ranges[i]));
+ if (ranges[i].min_char_low ==
+ ranges[i].max_char_low &&
+ ranges[i].min_char_high ==
+ ranges[i].max_char_high) continue;
+ sprintf(fname + strlen(fname), "_%d",
+ maxchar(ranges[i]));
+ }
+ strcat(fname, "]");
+ }
+}
+
+Bool
+FontParseXLFDName(char *fname, FontScalablePtr vals, int subst)
+{
+ register char *ptr;
+ register char *ptr1,
+ *ptr2,
+ *ptr3,
+ *ptr4;
+ register char *ptr5;
+ FontScalableRec tmpvals;
+ char replaceChar = '0';
+ char tmpBuf[1024];
+ int spacingLen;
+ int l;
+ char *p;
+
+ bzero(&tmpvals, sizeof(tmpvals));
+ if (subst != FONT_XLFD_REPLACE_VALUE)
+ *vals = tmpvals;
+
+ if (!(*(ptr = fname) == '-' || (*ptr++ == '*' && *ptr == '-')) || /* fndry */
+ !(ptr = strchr(ptr + 1, '-')) || /* family_name */
+ !(ptr1 = ptr = strchr(ptr + 1, '-')) || /* weight_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* slant */
+ !(ptr = strchr(ptr + 1, '-')) || /* setwidth_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* add_style_name */
+ !(ptr = strchr(ptr + 1, '-')) || /* pixel_size */
+ !(ptr = GetMatrix(ptr + 1, &tmpvals, PIXELSIZE_MASK)) ||
+ !(ptr2 = ptr = GetMatrix(ptr + 1, &tmpvals, POINTSIZE_MASK)) ||
+ !(ptr = GetInt(ptr + 1, &tmpvals.x)) || /* resolution_x */
+ !(ptr3 = ptr = GetInt(ptr + 1, &tmpvals.y)) || /* resolution_y */
+ !(ptr4 = ptr = strchr(ptr + 1, '-')) || /* spacing */
+ !(ptr5 = ptr = GetInt(ptr + 1, &tmpvals.width)) || /* average_width */
+ !(ptr = strchr(ptr + 1, '-')) || /* charset_registry */
+ strchr(ptr + 1, '-'))/* charset_encoding */
+ return FALSE;
+
+ /* Lop off HP charset subsetting enhancement. Interpreting this
+ field requires allocating some space in which to return the
+ results. So, to prevent memory leaks, this procedure will simply
+ lop off and ignore charset subsetting, and initialize the
+ relevant vals fields to zero. It's up to the caller to make its
+ own call to FontParseRanges() if it's interested in the charset
+ subsetting. */
+
+ if (subst != FONT_XLFD_REPLACE_NONE &&
+ (p = strchr(strrchr(fname, '-'), '[')))
+ {
+ tmpvals.values_supplied |= CHARSUBSET_SPECIFIED;
+ *p = '\0';
+ }
+
+ /* Fill in deprecated fields for the benefit of rasterizers that care
+ about them. */
+ tmpvals.pixel = (tmpvals.pixel_matrix[3] >= 0) ?
+ (int)(tmpvals.pixel_matrix[3] + .5) :
+ (int)(tmpvals.pixel_matrix[3] - .5);
+ tmpvals.point = (tmpvals.point_matrix[3] >= 0) ?
+ (int)(tmpvals.point_matrix[3] * 10 + .5) :
+ (int)(tmpvals.point_matrix[3] * 10 - .5);
+
+ spacingLen = ptr4 - ptr3 + 1;
+
+ switch (subst) {
+ case FONT_XLFD_REPLACE_NONE:
+ *vals = tmpvals;
+ break;
+ case FONT_XLFD_REPLACE_STAR:
+ replaceChar = '*';
+ case FONT_XLFD_REPLACE_ZERO:
+ strcpy(tmpBuf, ptr2);
+ ptr5 = tmpBuf + (ptr5 - ptr2);
+ ptr3 = tmpBuf + (ptr3 - ptr2);
+ ptr2 = tmpBuf;
+ ptr = ptr1 + 1;
+
+ ptr = strchr(ptr, '-') + 1; /* skip weight */
+ ptr = strchr(ptr, '-') + 1; /* skip slant */
+ ptr = strchr(ptr, '-') + 1; /* skip setwidth_name */
+ ptr = strchr(ptr, '-') + 1; /* skip add_style_name */
+
+ if ((ptr - fname) + spacingLen + strlen(ptr5) + 10 >= (unsigned)1024)
+ return FALSE;
+ *ptr++ = replaceChar;
+ *ptr++ = '-';
+ *ptr++ = replaceChar;
+ *ptr++ = '-';
+ *ptr++ = '*';
+ *ptr++ = '-';
+ *ptr++ = '*';
+ if (spacingLen > 2)
+ {
+ memmove(ptr, ptr3, spacingLen);
+ ptr += spacingLen;
+ }
+ else
+ {
+ *ptr++ = '-';
+ *ptr++ = '*';
+ *ptr++ = '-';
+ }
+ *ptr++ = replaceChar;
+ strcpy(ptr, ptr5);
+ *vals = tmpvals;
+ break;
+ case FONT_XLFD_REPLACE_VALUE:
+ if (vals->values_supplied & PIXELSIZE_MASK)
+ {
+ 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)
+ {
+ 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->x >= 0)
+ tmpvals.x = vals->x;
+ if (vals->y >= 0)
+ tmpvals.y = vals->y;
+ if (vals->width >= 0)
+ tmpvals.width = vals->width;
+ else if (vals->width < -1) /* overload: -1 means wildcard */
+ tmpvals.width = -vals->width;
+
+
+ p = ptr1 + 1; /* weight field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf, "%*.*s", l, l, p);
+
+ p += l + 1; /* slant field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ p += l + 1; /* setwidth_name */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ p += l + 1; /* add_style_name field */
+ l = strchr(p, '-') - p;
+ sprintf(tmpBuf + strlen(tmpBuf), "-%*.*s", l, l, p);
+
+ strcat(tmpBuf, "-");
+ if ((tmpvals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY)
+ {
+ char buffer[80];
+ strcat(tmpBuf, "[");
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[0],
+ buffer, 0));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[1],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[2],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.pixel_matrix[3],
+ buffer, 1));
+ strcat(tmpBuf, "]");
+ }
+ else
+ {
+ sprintf(tmpBuf + strlen(tmpBuf), "%d",
+ (int)(tmpvals.pixel_matrix[3] + .5));
+ }
+ strcat(tmpBuf, "-");
+ if ((tmpvals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY)
+ {
+ char buffer[80];
+ strcat(tmpBuf, "[");
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[0],
+ buffer, 0));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[1],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[2],
+ buffer, 1));
+ strcat(tmpBuf, xlfd_double_to_text(tmpvals.point_matrix[3],
+ buffer, 1));
+ strcat(tmpBuf, "]");
+ }
+ else
+ {
+ sprintf(tmpBuf + strlen(tmpBuf), "%d",
+ (int)(tmpvals.point_matrix[3] * 10.0 + .5));
+ }
+ sprintf(tmpBuf + strlen(tmpBuf), "-%d-%d%*.*s%d%s",
+ tmpvals.x, tmpvals.y,
+ spacingLen, spacingLen, ptr3, tmpvals.width, ptr5);
+ strcpy(ptr1 + 1, tmpBuf);
+ if ((vals->values_supplied & CHARSUBSET_SPECIFIED) && !vals->nranges)
+ strcat(fname, "[]");
+ else
+ append_ranges(fname, vals->nranges, vals->ranges);
+ break;
+ }
+ return TRUE;
+}
+
+fsRange *FontParseRanges(char *name, int *nranges)
+{
+ int n;
+ unsigned long l;
+ char *p1, *p2;
+ fsRange *result = (fsRange *)0;
+
+ name = strchr(name, '-');
+ for (n = 1; name && n < 14; n++)
+ name = strchr(name + 1, '-');
+
+ *nranges = 0;
+ if (!name || !(p1 = strchr(name, '['))) return (fsRange *)0;
+ p1++;
+
+ while (*p1 && *p1 != ']')
+ {
+ fsRange thisrange;
+
+ l = strtol(p1, &p2, 0);
+ if (p2 == p1 || l > 0xffff) break;
+ thisrange.max_char_low = thisrange.min_char_low = l & 0xff;
+ thisrange.max_char_high = thisrange.min_char_high = l >> 8;
+
+ p1 = p2;
+ if (*p1 == ']' || *p1 == ' ')
+ {
+ while (*p1 == ' ') p1++;
+ if (add_range(&thisrange, nranges, &result, TRUE) != Successful)
+ break;
+ }
+ else if (*p1 == '_')
+ {
+ l = strtol(++p1, &p2, 0);
+ if (p2 == p1 || l > 0xffff) break;
+ thisrange.max_char_low = l & 0xff;
+ thisrange.max_char_high = l >> 8;
+ p1 = p2;
+ if (*p1 == ']' || *p1 == ' ')
+ {
+ while (*p1 == ' ') p1++;
+ if (add_range(&thisrange, nranges, &result, TRUE) != Successful)
+ break;
+ }
+ }
+ else break;
+ }
+
+ return result;
+}
diff --git a/libXfont/src/util/format.c b/libXfont/src/util/format.c index 6700721f9..60afac9b8 100644 --- a/libXfont/src/util/format.c +++ b/libXfont/src/util/format.c @@ -1,126 +1,124 @@ -/* $Xorg: format.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */ -/* - * Copyright 1990, 1991 Network Computing Devices; - * Portions Copyright 1987 by Digital Equipment Corporation - * - * 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, and that the names of Network Computing Devices or Digital - * not be used in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. Network Computing - * Devices and Digital make no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - * - * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE - * LIABLE FOR 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. - */ - -/* - -Copyright 1987, 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/util/format.c,v 1.4 2001/01/17 19:43:33 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/FSproto.h> -#include <X11/fonts/font.h> -#include <X11/fonts/fontstruct.h> -#include <X11/fonts/fontutil.h> - -int -CheckFSFormat(fsBitmapFormat format, - fsBitmapFormatMask fmask, - int *bit_order, - int *byte_order, - int *scan, - int *glyph, - int *image) -{ - /* convert format to what the low levels want */ - if (fmask & BitmapFormatMaskBit) { - *bit_order = format & BitmapFormatBitOrderMask; - *bit_order = (*bit_order == BitmapFormatBitOrderMSB) - ? MSBFirst : LSBFirst; - } - if (fmask & BitmapFormatMaskByte) { - *byte_order = format & BitmapFormatByteOrderMask; - *byte_order = (*byte_order == BitmapFormatByteOrderMSB) - ? MSBFirst : LSBFirst; - } - if (fmask & BitmapFormatMaskScanLineUnit) { - *scan = format & BitmapFormatScanlineUnitMask; - /* convert byte paddings into byte counts */ - switch (*scan) { - case BitmapFormatScanlineUnit8: - *scan = 1; - break; - case BitmapFormatScanlineUnit16: - *scan = 2; - break; - case BitmapFormatScanlineUnit32: - *scan = 4; - break; - default: - return BadFontFormat; - } - } - if (fmask & BitmapFormatMaskScanLinePad) { - *glyph = format & BitmapFormatScanlinePadMask; - /* convert byte paddings into byte counts */ - switch (*glyph) { - case BitmapFormatScanlinePad8: - *glyph = 1; - break; - case BitmapFormatScanlinePad16: - *glyph = 2; - break; - case BitmapFormatScanlinePad32: - *glyph = 4; - break; - default: - return BadFontFormat; - } - } - if (fmask & BitmapFormatMaskImageRectangle) { - *image = format & BitmapFormatImageRectMask; - - if (*image != BitmapFormatImageRectMin && - *image != BitmapFormatImageRectMaxWidth && - *image != BitmapFormatImageRectMax) - return BadFontFormat; - } - return Successful; -} +/*
+ * Copyright 1990, 1991 Network Computing Devices;
+ * Portions Copyright 1987 by Digital Equipment Corporation
+ *
+ * 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, and that the names of Network Computing Devices or Digital
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Network Computing
+ * Devices and Digital make no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE
+ * LIABLE FOR 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.
+ */
+
+/*
+
+Copyright 1987, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/FSproto.h>
+#include <X11/fonts/font.h>
+#include <X11/fonts/fontstruct.h>
+#include <X11/fonts/fontutil.h>
+
+int
+CheckFSFormat(fsBitmapFormat format,
+ fsBitmapFormatMask fmask,
+ int *bit_order,
+ int *byte_order,
+ int *scan,
+ int *glyph,
+ int *image)
+{
+ /* convert format to what the low levels want */
+ if (fmask & BitmapFormatMaskBit) {
+ *bit_order = format & BitmapFormatBitOrderMask;
+ *bit_order = (*bit_order == BitmapFormatBitOrderMSB)
+ ? MSBFirst : LSBFirst;
+ }
+ if (fmask & BitmapFormatMaskByte) {
+ *byte_order = format & BitmapFormatByteOrderMask;
+ *byte_order = (*byte_order == BitmapFormatByteOrderMSB)
+ ? MSBFirst : LSBFirst;
+ }
+ if (fmask & BitmapFormatMaskScanLineUnit) {
+ *scan = format & BitmapFormatScanlineUnitMask;
+ /* convert byte paddings into byte counts */
+ switch (*scan) {
+ case BitmapFormatScanlineUnit8:
+ *scan = 1;
+ break;
+ case BitmapFormatScanlineUnit16:
+ *scan = 2;
+ break;
+ case BitmapFormatScanlineUnit32:
+ *scan = 4;
+ break;
+ default:
+ return BadFontFormat;
+ }
+ }
+ if (fmask & BitmapFormatMaskScanLinePad) {
+ *glyph = format & BitmapFormatScanlinePadMask;
+ /* convert byte paddings into byte counts */
+ switch (*glyph) {
+ case BitmapFormatScanlinePad8:
+ *glyph = 1;
+ break;
+ case BitmapFormatScanlinePad16:
+ *glyph = 2;
+ break;
+ case BitmapFormatScanlinePad32:
+ *glyph = 4;
+ break;
+ default:
+ return BadFontFormat;
+ }
+ }
+ if (fmask & BitmapFormatMaskImageRectangle) {
+ *image = format & BitmapFormatImageRectMask;
+
+ if (*image != BitmapFormatImageRectMin &&
+ *image != BitmapFormatImageRectMaxWidth &&
+ *image != BitmapFormatImageRectMax)
+ return BadFontFormat;
+ }
+ return Successful;
+}
diff --git a/libXfont/src/util/miscutil.c b/libXfont/src/util/miscutil.c index d87f9a0c1..9e6cc3ffa 100644 --- a/libXfont/src/util/miscutil.c +++ b/libXfont/src/util/miscutil.c @@ -1,64 +1,61 @@ -/* $Xorg: miscutil.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */ - -/* - -Copyright 1991, 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/util/miscutil.c,v 1.7 2001/07/25 15:04:57 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xosdefs.h> -#include <stdlib.h> -#include <X11/fonts/fontmisc.h> -#include "stubs.h" - -#define XK_LATIN1 -#include <X11/keysymdef.h> - - -#ifdef __SUNPRO_C -#pragma weak serverGeneration -#pragma weak register_fpe_functions -#endif - -extern void BuiltinRegisterFpeFunctions(void); - -#ifndef _MSC_VER -/* make sure everything initializes themselves at least once */ -weak long serverGeneration = 1; -#endif - -weak void -register_fpe_functions (void) -{ - BuiltinRegisterFpeFunctions(); - FontFileRegisterFpeFunctions(); -#ifdef XFONT_FC - fs_register_fpe_functions(); -#endif -} +/*
+
+Copyright 1991, 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.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xosdefs.h>
+#include <stdlib.h>
+#include <X11/fonts/fontmisc.h>
+#include "stubs.h"
+
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+
+
+#ifdef __SUNPRO_C
+#pragma weak serverGeneration
+#pragma weak register_fpe_functions
+#endif
+
+extern void BuiltinRegisterFpeFunctions(void);
+
+#ifndef NO_WEAK_SYMBOLS
+/* make sure everything initializes themselves at least once */
+weak long serverGeneration = 1;
+#endif
+
+weak void
+register_fpe_functions (void)
+{
+ BuiltinRegisterFpeFunctions();
+ FontFileRegisterFpeFunctions();
+#ifdef XFONT_FC
+ fs_register_fpe_functions();
+#endif
+}
diff --git a/libXfont/src/util/patcache.c b/libXfont/src/util/patcache.c index 5411810d6..f1a203683 100644 --- a/libXfont/src/util/patcache.c +++ b/libXfont/src/util/patcache.c @@ -1,221 +1,218 @@ -/* $Xorg: patcache.c,v 1.4 2001/02/09 02:04:04 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/util/patcache.c,v 3.4 2001/01/17 19:43:33 dawes Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> - -/* - * Static sized hash table for looking up font name patterns - * - * LRU entries, reusing old entries - */ - -#define NBUCKETS 16 -#define NENTRIES 64 - -#define UNSET (NENTRIES+1) - -typedef unsigned char EntryPtr; - -typedef struct _FontPatternCacheEntry { - struct _FontPatternCacheEntry *next, **prev; - short patlen; - char *pattern; - int hash; - FontPtr pFont; /* associated font */ -} FontPatternCacheEntryRec, *FontPatternCacheEntryPtr; - -typedef struct _FontPatternCache { - FontPatternCacheEntryPtr buckets[NBUCKETS]; - FontPatternCacheEntryRec entries[NENTRIES]; - FontPatternCacheEntryPtr free; -} FontPatternCacheRec; - -/* Empty cache (for rehash) */ -void -EmptyFontPatternCache (FontPatternCachePtr cache) -{ - int i; - - for (i = 0; i < NBUCKETS; i++) - cache->buckets[i] = 0; - for (i = 0; i < NENTRIES; i++) - { - cache->entries[i].next = &cache->entries[i+1]; - cache->entries[i].prev = 0; - cache->entries[i].pFont = 0; - free (cache->entries[i].pattern); - cache->entries[i].pattern = 0; - cache->entries[i].patlen = 0; - } - cache->free = &cache->entries[0]; - cache->entries[NENTRIES - 1].next = 0; -} - -/* Create and initialize cache */ -FontPatternCachePtr -MakeFontPatternCache (void) -{ - FontPatternCachePtr cache; - int i; - cache = malloc (sizeof *cache); - if (!cache) - return 0; - for (i = 0; i < NENTRIES; i++) { - cache->entries[i].patlen = 0; - cache->entries[i].pattern = 0; - cache->entries[i].pFont = 0; - } - EmptyFontPatternCache (cache); - return cache; -} - -/* toss cache */ -void -FreeFontPatternCache (FontPatternCachePtr cache) -{ - int i; - - for (i = 0; i < NENTRIES; i++) - free (cache->entries[i].pattern); - free (cache); -} - -/* compute id for string */ -static int -Hash (const char *string, int len) -{ - int hash; - - hash = 0; - while (len--) - hash = (hash << 1) ^ *string++; - if (hash < 0) - hash = -hash; - return hash; -} - -/* add entry */ -void -CacheFontPattern (FontPatternCachePtr cache, - char *pattern, - int patlen, - FontPtr pFont) -{ - FontPatternCacheEntryPtr e; - char *newpat; - int i; - - newpat = malloc (patlen); - if (!newpat) - return; - if (cache->free) - { - e = cache->free; - cache->free = e->next; - } - else - { - i = rand (); - if (i < 0) - i = -i; - i %= NENTRIES; - e = &cache->entries[i]; - if (e->next) - e->next->prev = e->prev; - *e->prev = e->next; - free (e->pattern); - } - /* set pattern */ - memcpy (newpat, pattern, patlen); - e->pattern = newpat; - e->patlen = patlen; - /* link to new hash chain */ - e->hash = Hash (pattern, patlen); - i = e->hash % NBUCKETS; - e->next = cache->buckets[i]; - if (e->next) - e->next->prev = &(e->next); - cache->buckets[i] = e; - e->prev = &(cache->buckets[i]); - e->pFont = pFont; -} - -/* find matching entry */ -FontPtr -FindCachedFontPattern (FontPatternCachePtr cache, - char *pattern, - int patlen) -{ - int hash; - int i; - FontPatternCacheEntryPtr e; - - hash = Hash (pattern, patlen); - i = hash % NBUCKETS; - for (e = cache->buckets[i]; e; e = e->next) - { - if (e->patlen == patlen && e->hash == hash && - !memcmp (e->pattern, pattern, patlen)) - { - return e->pFont; - } - } - return 0; -} - -void -RemoveCachedFontPattern (FontPatternCachePtr cache, - FontPtr pFont) -{ - FontPatternCacheEntryPtr e; - int i; - - for (i = 0; i < NENTRIES; i++) - { - if ((e = &cache->entries[i])->pFont == pFont) - { - e->pFont = 0; - if (e->next) - e->next->prev = e->prev; - *e->prev = e->next; - e->next = cache->free; - cache->free = e; - free (e->pattern); - e->pattern = 0; - } - } -} +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+/*
+ * Static sized hash table for looking up font name patterns
+ *
+ * LRU entries, reusing old entries
+ */
+
+#define NBUCKETS 16
+#define NENTRIES 64
+
+#define UNSET (NENTRIES+1)
+
+typedef unsigned char EntryPtr;
+
+typedef struct _FontPatternCacheEntry {
+ struct _FontPatternCacheEntry *next, **prev;
+ short patlen;
+ char *pattern;
+ int hash;
+ FontPtr pFont; /* associated font */
+} FontPatternCacheEntryRec, *FontPatternCacheEntryPtr;
+
+typedef struct _FontPatternCache {
+ FontPatternCacheEntryPtr buckets[NBUCKETS];
+ FontPatternCacheEntryRec entries[NENTRIES];
+ FontPatternCacheEntryPtr free;
+} FontPatternCacheRec;
+
+/* Empty cache (for rehash) */
+void
+EmptyFontPatternCache (FontPatternCachePtr cache)
+{
+ int i;
+
+ for (i = 0; i < NBUCKETS; i++)
+ cache->buckets[i] = 0;
+ for (i = 0; i < NENTRIES; i++)
+ {
+ cache->entries[i].next = &cache->entries[i+1];
+ cache->entries[i].prev = 0;
+ cache->entries[i].pFont = 0;
+ free (cache->entries[i].pattern);
+ cache->entries[i].pattern = 0;
+ cache->entries[i].patlen = 0;
+ }
+ cache->free = &cache->entries[0];
+ cache->entries[NENTRIES - 1].next = 0;
+}
+
+/* Create and initialize cache */
+FontPatternCachePtr
+MakeFontPatternCache (void)
+{
+ FontPatternCachePtr cache;
+ int i;
+ cache = malloc (sizeof *cache);
+ if (!cache)
+ return 0;
+ for (i = 0; i < NENTRIES; i++) {
+ cache->entries[i].patlen = 0;
+ cache->entries[i].pattern = 0;
+ cache->entries[i].pFont = 0;
+ }
+ EmptyFontPatternCache (cache);
+ return cache;
+}
+
+/* toss cache */
+void
+FreeFontPatternCache (FontPatternCachePtr cache)
+{
+ int i;
+
+ for (i = 0; i < NENTRIES; i++)
+ free (cache->entries[i].pattern);
+ free (cache);
+}
+
+/* compute id for string */
+static int
+Hash (const char *string, int len)
+{
+ int hash;
+
+ hash = 0;
+ while (len--)
+ hash = (hash << 1) ^ *string++;
+ if (hash < 0)
+ hash = -hash;
+ return hash;
+}
+
+/* add entry */
+void
+CacheFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen,
+ FontPtr pFont)
+{
+ FontPatternCacheEntryPtr e;
+ char *newpat;
+ int i;
+
+ newpat = malloc (patlen);
+ if (!newpat)
+ return;
+ if (cache->free)
+ {
+ e = cache->free;
+ cache->free = e->next;
+ }
+ else
+ {
+ i = rand ();
+ if (i < 0)
+ i = -i;
+ i %= NENTRIES;
+ e = &cache->entries[i];
+ if (e->next)
+ e->next->prev = e->prev;
+ *e->prev = e->next;
+ free (e->pattern);
+ }
+ /* set pattern */
+ memcpy (newpat, pattern, patlen);
+ e->pattern = newpat;
+ e->patlen = patlen;
+ /* link to new hash chain */
+ e->hash = Hash (pattern, patlen);
+ i = e->hash % NBUCKETS;
+ e->next = cache->buckets[i];
+ if (e->next)
+ e->next->prev = &(e->next);
+ cache->buckets[i] = e;
+ e->prev = &(cache->buckets[i]);
+ e->pFont = pFont;
+}
+
+/* find matching entry */
+FontPtr
+FindCachedFontPattern (FontPatternCachePtr cache,
+ char *pattern,
+ int patlen)
+{
+ int hash;
+ int i;
+ FontPatternCacheEntryPtr e;
+
+ hash = Hash (pattern, patlen);
+ i = hash % NBUCKETS;
+ for (e = cache->buckets[i]; e; e = e->next)
+ {
+ if (e->patlen == patlen && e->hash == hash &&
+ !memcmp (e->pattern, pattern, patlen))
+ {
+ return e->pFont;
+ }
+ }
+ return 0;
+}
+
+void
+RemoveCachedFontPattern (FontPatternCachePtr cache,
+ FontPtr pFont)
+{
+ FontPatternCacheEntryPtr e;
+ int i;
+
+ for (i = 0; i < NENTRIES; i++)
+ {
+ if ((e = &cache->entries[i])->pFont == pFont)
+ {
+ e->pFont = 0;
+ if (e->next)
+ e->next->prev = e->prev;
+ *e->prev = e->next;
+ e->next = cache->free;
+ cache->free = e;
+ free (e->pattern);
+ e->pattern = 0;
+ }
+ }
+}
diff --git a/libXfont/src/util/private.c b/libXfont/src/util/private.c index 6b760b4c3..f28ec6ab5 100644 --- a/libXfont/src/util/private.c +++ b/libXfont/src/util/private.c @@ -1,108 +1,105 @@ -/* $Xorg: private.c,v 1.4 2001/02/09 02:04:04 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/util/private.c,v 1.8tsi Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> -#include <X11/fonts/fontstruct.h> - -static int _FontPrivateAllocateIndex = 0; - -int -AllocateFontPrivateIndex (void) -{ - return _FontPrivateAllocateIndex++; -} - -FontPtr -CreateFontRec (void) -{ - FontPtr pFont; - int size; - - size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex); - - pFont = malloc(size); - - if(pFont) { - bzero((char*)pFont, size); - pFont->maxPrivate = _FontPrivateAllocateIndex - 1; - if(_FontPrivateAllocateIndex) - pFont->devPrivates = (pointer)(&pFont[1]); - } - - return pFont; -} - -void -DestroyFontRec (FontPtr pFont) -{ - if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) - free(pFont->devPrivates); - free(pFont); -} - -void -ResetFontPrivateIndex (void) -{ - _FontPrivateAllocateIndex = 0; -} - -Bool -_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr) -{ - pointer *new; - - if (n > pFont->maxPrivate) { - if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) { - new = realloc (pFont->devPrivates, (n + 1) * sizeof (pointer)); - if (!new) - return FALSE; - } else { - /* omg realloc */ - new = malloc ((n + 1) * sizeof (pointer)); - if (!new) - return FALSE; - if (pFont->devPrivates) - memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer)); - } - pFont->devPrivates = new; - /* zero out new, uninitialized privates */ - while(++pFont->maxPrivate < n) - pFont->devPrivates[pFont->maxPrivate] = (pointer)0; - } - pFont->devPrivates[n] = ptr; - return TRUE; -} - +/*
+
+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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+#include <X11/fonts/fontstruct.h>
+
+static int _FontPrivateAllocateIndex = 0;
+
+int
+AllocateFontPrivateIndex (void)
+{
+ return _FontPrivateAllocateIndex++;
+}
+
+FontPtr
+CreateFontRec (void)
+{
+ FontPtr pFont;
+ int size;
+
+ size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
+
+ pFont = malloc(size);
+
+ if(pFont) {
+ bzero((char*)pFont, size);
+ pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
+ if(_FontPrivateAllocateIndex)
+ pFont->devPrivates = (pointer)(&pFont[1]);
+ }
+
+ return pFont;
+}
+
+void
+DestroyFontRec (FontPtr pFont)
+{
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
+ free(pFont->devPrivates);
+ free(pFont);
+}
+
+void
+ResetFontPrivateIndex (void)
+{
+ _FontPrivateAllocateIndex = 0;
+}
+
+Bool
+_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr)
+{
+ pointer *new;
+
+ if (n > pFont->maxPrivate) {
+ if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
+ new = realloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ } else {
+ /* omg realloc */
+ new = malloc ((n + 1) * sizeof (pointer));
+ if (!new)
+ return FALSE;
+ if (pFont->devPrivates)
+ memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer));
+ }
+ pFont->devPrivates = new;
+ /* zero out new, uninitialized privates */
+ while(++pFont->maxPrivate < n)
+ pFont->devPrivates[pFont->maxPrivate] = (pointer)0;
+ }
+ pFont->devPrivates[n] = ptr;
+ return TRUE;
+}
+
diff --git a/libXfont/src/util/utilbitmap.c b/libXfont/src/util/utilbitmap.c index 978db89c8..070cd5801 100644 --- a/libXfont/src/util/utilbitmap.c +++ b/libXfont/src/util/utilbitmap.c @@ -1,186 +1,185 @@ -/* - -Copyright 1990, 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/util/utilbitmap.c,v 1.4 2001/01/17 19:43:34 dawes Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/fonts/fontmisc.h> - -/* Utility functions for reformating font bitmaps */ - -static const unsigned char _reverse_byte[0x100] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; - -/* - * Invert bit order within each BYTE of an array. - */ -void -BitOrderInvert(unsigned char *buf, int nbytes) -{ - const unsigned char *rev = _reverse_byte; - - for (; --nbytes >= 0; buf++) - *buf = rev[*buf]; -} - -/* - * Invert byte order within each 16-bits of an array. - */ -void -TwoByteSwap(unsigned char *buf, int nbytes) -{ - unsigned char c; - - for (; nbytes > 0; nbytes -= 2, buf += 2) - { - c = buf[0]; - buf[0] = buf[1]; - buf[1] = c; - } -} - -/* - * Invert byte order within each 32-bits of an array. - */ -void -FourByteSwap(unsigned char *buf, int nbytes) -{ - unsigned char c; - - for (; nbytes > 0; nbytes -= 4, buf += 4) - { - c = buf[0]; - buf[0] = buf[3]; - buf[3] = c; - c = buf[1]; - buf[1] = buf[2]; - buf[2] = c; - } -} - -/* - * Repad a bitmap - */ - -int -RepadBitmap (char *pSrc, char *pDst, - unsigned int srcPad, unsigned int dstPad, - int width, int height) -{ - int srcWidthBytes,dstWidthBytes; - int row,col; - char *pTmpSrc,*pTmpDst; - - switch (srcPad) { - case 1: - srcWidthBytes = (width+7)>>3; - break; - case 2: - srcWidthBytes = ((width+15)>>4)<<1; - break; - case 4: - srcWidthBytes = ((width+31)>>5)<<2; - break; - case 8: - srcWidthBytes = ((width+63)>>6)<<3; - break; - default: - return 0; - } - switch (dstPad) { - case 1: - dstWidthBytes = (width+7)>>3; - break; - case 2: - dstWidthBytes = ((width+15)>>4)<<1; - break; - case 4: - dstWidthBytes = ((width+31)>>5)<<2; - break; - case 8: - dstWidthBytes = ((width+63)>>6)<<3; - break; - default: - return 0; - } - - width = srcWidthBytes; - if (width > dstWidthBytes) - width = dstWidthBytes; - pTmpSrc= pSrc; - pTmpDst= pDst; - for (row = 0; row < height; row++) - { - for (col = 0; col < width; col++) - *pTmpDst++ = *pTmpSrc++; - while (col < dstWidthBytes) - { - *pTmpDst++ = '\0'; - col++; - } - pTmpSrc += srcWidthBytes - width; - } - return dstWidthBytes * height; -} - - +/*
+
+Copyright 1990, 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.
+
+*/
+
+/*
+ * Author: Keith Packard, MIT X Consortium
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/fonts/fontmisc.h>
+
+/* Utility functions for reformating font bitmaps */
+
+static const unsigned char _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+/*
+ * Invert bit order within each BYTE of an array.
+ */
+void
+BitOrderInvert(unsigned char *buf, int nbytes)
+{
+ const unsigned char *rev = _reverse_byte;
+
+ for (; --nbytes >= 0; buf++)
+ *buf = rev[*buf];
+}
+
+/*
+ * Invert byte order within each 16-bits of an array.
+ */
+void
+TwoByteSwap(unsigned char *buf, int nbytes)
+{
+ unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 2, buf += 2)
+ {
+ c = buf[0];
+ buf[0] = buf[1];
+ buf[1] = c;
+ }
+}
+
+/*
+ * Invert byte order within each 32-bits of an array.
+ */
+void
+FourByteSwap(unsigned char *buf, int nbytes)
+{
+ unsigned char c;
+
+ for (; nbytes > 0; nbytes -= 4, buf += 4)
+ {
+ c = buf[0];
+ buf[0] = buf[3];
+ buf[3] = c;
+ c = buf[1];
+ buf[1] = buf[2];
+ buf[2] = c;
+ }
+}
+
+/*
+ * Repad a bitmap
+ */
+
+int
+RepadBitmap (char *pSrc, char *pDst,
+ unsigned int srcPad, unsigned int dstPad,
+ int width, int height)
+{
+ int srcWidthBytes,dstWidthBytes;
+ int row,col;
+ char *pTmpSrc,*pTmpDst;
+
+ switch (srcPad) {
+ case 1:
+ srcWidthBytes = (width+7)>>3;
+ break;
+ case 2:
+ srcWidthBytes = ((width+15)>>4)<<1;
+ break;
+ case 4:
+ srcWidthBytes = ((width+31)>>5)<<2;
+ break;
+ case 8:
+ srcWidthBytes = ((width+63)>>6)<<3;
+ break;
+ default:
+ return 0;
+ }
+ switch (dstPad) {
+ case 1:
+ dstWidthBytes = (width+7)>>3;
+ break;
+ case 2:
+ dstWidthBytes = ((width+15)>>4)<<1;
+ break;
+ case 4:
+ dstWidthBytes = ((width+31)>>5)<<2;
+ break;
+ case 8:
+ dstWidthBytes = ((width+63)>>6)<<3;
+ break;
+ default:
+ return 0;
+ }
+
+ width = srcWidthBytes;
+ if (width > dstWidthBytes)
+ width = dstWidthBytes;
+ pTmpSrc= pSrc;
+ pTmpDst= pDst;
+ for (row = 0; row < height; row++)
+ {
+ for (col = 0; col < width; col++)
+ *pTmpDst++ = *pTmpSrc++;
+ while (col < dstWidthBytes)
+ {
+ *pTmpDst++ = '\0';
+ col++;
+ }
+ pTmpSrc += srcWidthBytes - width;
+ }
+ return dstWidthBytes * height;
+}
+
+
|