aboutsummaryrefslogtreecommitdiff
path: root/libfontenc/src
diff options
context:
space:
mode:
Diffstat (limited to 'libfontenc/src')
-rw-r--r--libfontenc/src/Makefile.am63
-rw-r--r--libfontenc/src/Makefile.in593
-rw-r--r--libfontenc/src/encparse.c1923
-rw-r--r--libfontenc/src/fontenc.c1891
-rw-r--r--libfontenc/src/fontencI.h90
5 files changed, 1965 insertions, 2595 deletions
diff --git a/libfontenc/src/Makefile.am b/libfontenc/src/Makefile.am
index 8cd09112d..54b735584 100644
--- a/libfontenc/src/Makefile.am
+++ b/libfontenc/src/Makefile.am
@@ -1,31 +1,32 @@
-lib_LTLIBRARIES = libfontenc.la
-
-libfontenc_la_SOURCES = \
- encparse.c \
- fontenc.c \
- fontencI.h
-
-AM_CFLAGS = @FONTENC_CFLAGS@
-
-FONTENCDIR=@ENCODINGSDIR@
-FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTENCDIR)/encodings.dir\"
-
-INCLUDES = -I$(top_srcdir)/include \
- -DFONTENC_NO_LIBFONT $(FONTENCDEFS)
-
-
-libfontenc_la_LIBADD = @FONTENC_LIBS@
-
-libfontenc_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-
-libfontencincludedir = $(includedir)/X11/fonts
-libfontencinclude_HEADERS = \
- $(top_srcdir)/include/X11/fonts/fontenc.h
-
-if LINT
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS)
-
-lint:
- $(LINT) $(ALL_LINT_FLAGS) $(libfontenc_la_SOURCES) $(libfontenc_la_LIBADD) $(LIBS)
-endif LINT
+lib_LTLIBRARIES = libfontenc.la
+
+libfontenc_la_SOURCES = \
+ encparse.c \
+ fontenc.c \
+ fontencI.h
+
+AM_CFLAGS = \
+ $(FONTENC_CFLAGS) \
+ $(CWARNFLAGS)
+
+FONTENCDIR=@ENCODINGSDIR@
+FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTENCDIR)/encodings.dir\"
+
+INCLUDES = -I$(top_srcdir)/include $(FONTENCDEFS)
+
+
+libfontenc_la_LIBADD = @FONTENC_LIBS@
+
+libfontenc_la_LDFLAGS = -version-number 1:0:0 -no-undefined
+
+libfontencincludedir = $(includedir)/X11/fonts
+libfontencinclude_HEADERS = \
+ $(top_srcdir)/include/X11/fonts/fontenc.h
+
+if LINT
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) $(libfontenc_la_SOURCES) $(libfontenc_la_LIBADD) $(LIBS)
+endif LINT
diff --git a/libfontenc/src/Makefile.in b/libfontenc/src/Makefile.in
deleted file mode 100644
index e299702c5..000000000
--- a/libfontenc/src/Makefile.in
+++ /dev/null
@@ -1,593 +0,0 @@
-# Makefile.in generated by automake 1.11 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@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
-DIST_COMMON = $(libfontencinclude_HEADERS) $(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
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(libdir)" \
- "$(DESTDIR)$(libfontencincludedir)"
-LTLIBRARIES = $(lib_LTLIBRARIES)
-libfontenc_la_DEPENDENCIES =
-am_libfontenc_la_OBJECTS = encparse.lo fontenc.lo
-libfontenc_la_OBJECTS = $(am_libfontenc_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-libfontenc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(libfontenc_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
- $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libfontenc_la_SOURCES)
-DIST_SOURCES = $(libfontenc_la_SOURCES)
-HEADERS = $(libfontencinclude_HEADERS)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-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@
-DSYMUTIL = @DSYMUTIL@
-DUMPBIN = @DUMPBIN@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-ENCODINGSDIR = @ENCODINGSDIR@
-EXEEXT = @EXEEXT@
-FGREP = @FGREP@
-FONTENC_CFLAGS = @FONTENC_CFLAGS@
-FONTENC_LIBS = @FONTENC_LIBS@
-GREP = @GREP@
-INSTALL = @INSTALL@
-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@
-LINT = @LINT@
-LINT_FLAGS = @LINT_FLAGS@
-LIPO = @LIPO@
-LN_S = @LN_S@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MKDIR_P = @MKDIR_P@
-NM = @NM@
-NMEDIT = @NMEDIT@
-OBJDUMP = @OBJDUMP@
-OBJEXT = @OBJEXT@
-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@
-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@
-distcleancheck_listfiles = @distcleancheck_listfiles@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-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@
-lib_LTLIBRARIES = libfontenc.la
-libfontenc_la_SOURCES = \
- encparse.c \
- fontenc.c \
- fontencI.h
-
-AM_CFLAGS = @FONTENC_CFLAGS@
-FONTENCDIR = @ENCODINGSDIR@
-FONTENCDEFS = -DFONT_ENCODINGS_DIRECTORY=\"$(FONTENCDIR)/encodings.dir\"
-INCLUDES = -I$(top_srcdir)/include \
- -DFONTENC_NO_LIBFONT $(FONTENCDEFS)
-
-libfontenc_la_LIBADD = @FONTENC_LIBS@
-libfontenc_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libfontencincludedir = $(includedir)/X11/fonts
-libfontencinclude_HEADERS = \
- $(top_srcdir)/include/X11/fonts/fontenc.h
-
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS)
-
-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) --gnu src/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnu src/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
-$(am__aclocal_m4_deps):
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
- @$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
- list2=; for p in $$list; do \
- if test -f $$p; then \
- list2="$$list2 $$p"; \
- else :; fi; \
- done; \
- test -z "$$list2" || { \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
- }
-
-uninstall-libLTLIBRARIES:
- @$(NORMAL_UNINSTALL)
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
- done
-
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
- @list='$(lib_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
-libfontenc.la: $(libfontenc_la_OBJECTS) $(libfontenc_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libfontenc_la_LINK) -rpath $(libdir) $(libfontenc_la_OBJECTS) $(libfontenc_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encparse.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fontenc.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@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@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@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@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@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
-install-libfontencincludeHEADERS: $(libfontencinclude_HEADERS)
- @$(NORMAL_INSTALL)
- test -z "$(libfontencincludedir)" || $(MKDIR_P) "$(DESTDIR)$(libfontencincludedir)"
- @list='$(libfontencinclude_HEADERS)'; test -n "$(libfontencincludedir)" || list=; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libfontencincludedir)'"; \
- $(INSTALL_HEADER) $$files "$(DESTDIR)$(libfontencincludedir)" || exit $$?; \
- done
-
-uninstall-libfontencincludeHEADERS:
- @$(NORMAL_UNINSTALL)
- @list='$(libfontencinclude_HEADERS)'; test -n "$(libfontencincludedir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(libfontencincludedir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(libfontencincludedir)" && rm -f $$files
-
-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)
- set x; \
- 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; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- 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)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__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 "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$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) $(HEADERS)
-installdirs:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libfontencincludedir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
- done
-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)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_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-libLTLIBRARIES clean-libtool \
- 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
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am: install-libfontencincludeHEADERS
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am: install-libLTLIBRARIES
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-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: uninstall-libLTLIBRARIES \
- uninstall-libfontencincludeHEADERS
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libLTLIBRARIES clean-libtool 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-libLTLIBRARIES install-libfontencincludeHEADERS \
- 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 uninstall-libLTLIBRARIES \
- uninstall-libfontencincludeHEADERS
-
-
-@LINT_TRUE@lint:
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $(libfontenc_la_SOURCES) $(libfontenc_la_LIBADD) $(LIBS)
-
-# 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/libfontenc/src/encparse.c b/libfontenc/src/encparse.c
index 217bf7827..efc766bf3 100644
--- a/libfontenc/src/encparse.c
+++ b/libfontenc/src/encparse.c
@@ -1,972 +1,951 @@
-/* $XdotOrg: lib/fontenc/src/encparse.c,v 1.6 2006/04/10 16:15:12 alanc Exp $ */
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */
-
-/* Parser for encoding files */
-
-/* This code assumes that we are using ASCII. We don't use the ctype
- functions, as they depend on the current locale. On the other
- hand, we do use strcasecmp, but only on strings that we've checked
- to be pure ASCII. Bloody ``Code Set Independence''. */
-
-#include <string.h>
-#include <stdio.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <strings.h>
-#endif
-
-#ifndef FONTENC_NO_LIBFONT
-
-#include <X11/fonts/fntfilio.h>
-#include <X11/fonts/fntfilst.h>
-
-#else
-
-#include <stdlib.h>
-#define xalloc(n) malloc(n)
-#define xrealloc(p, n) realloc(p, n)
-#define xfree(p) free(p)
-
-#include "zlib.h"
-typedef gzFile FontFilePtr;
-#define FontFileGetc(f) gzgetc(f)
-#define FontFileOpen(filename) gzopen(filename, "rb")
-#define FontFileClose(f) gzclose(f)
-
-#define MAXFONTFILENAMELEN 1024
-#define MAXFONTNAMELEN 1024
-
-#endif
-
-#include <X11/fonts/fontenc.h>
-#include "fontencI.h"
-
-#define MAXALIASES 20
-
-#define EOF_TOKEN -1
-#define ERROR_TOKEN -2
-#define EOL_TOKEN 0
-#define NUMBER_TOKEN 1
-#define KEYWORD_TOKEN 2
-
-#define EOF_LINE -1
-#define ERROR_LINE -2
-#define STARTENCODING_LINE 1
-#define STARTMAPPING_LINE 2
-#define ENDMAPPING_LINE 3
-#define CODE_LINE 4
-#define CODE_RANGE_LINE 5
-#define CODE_UNDEFINE_LINE 6
-#define NAME_LINE 7
-#define SIZE_LINE 8
-#define ALIAS_LINE 9
-#define FIRSTINDEX_LINE 10
-
-/* Return from lexer */
-#define MAXKEYWORDLEN 100
-
-static long number_value;
-static char keyword_value[MAXKEYWORDLEN+1];
-
-static long value1, value2, value3;
-
-/* Lexer code */
-
-/* Skip to the beginning of new line */
-static void
-skipEndOfLine(FontFilePtr f, int c)
-{
- if(c == 0)
- c = FontFileGetc(f);
-
- for(;;)
- if(c <= 0 || c == '\n')
- return;
- else
- c = FontFileGetc(f);
-}
-
-/* Get a number; we're at the first digit. */
-static unsigned
-getnum(FontFilePtr f, int c, int *cp)
-{
- unsigned n = 0;
- int base = 10;
-
- /* look for `0' or `0x' prefix */
- if(c == '0') {
- c = FontFileGetc(f);
- base = 8;
- if(c == 'x' || c == 'X') {
- base = 16;
- c = FontFileGetc(f);
- }
- }
-
- /* accumulate digits */
- for(;;) {
- if ('0' <= c && c <= '9') {
- n *= base; n += c - '0';
- } else if('a' <= c && c <= 'f') {
- n *= base; n += c - 'a' + 10;
- } else if('A' <=c && c <= 'F') {
- n *= base; n += c - 'A' + 10;
- } else
- break;
- c = FontFileGetc(f);
- }
-
- *cp = c; return n;
-}
-
-/* Skip to beginning of new line; return 1 if only whitespace was found. */
-static int
-endOfLine(FontFilePtr f, int c)
-{
- if(c == 0)
- c = FontFileGetc(f);
-
- for(;;) {
- if(c <= 0 || c == '\n')
- return 1;
- else if(c == '#') {
- skipEndOfLine(f,c);
- return 1;
- }
- else if(c == ' ' || c == '\t') {
- skipEndOfLine(f,c);
- return 0;
- }
- c = FontFileGetc(f);
- }
-}
-
-/* Get a token; we're at first char */
-static int
-gettoken(FontFilePtr f, int c, int *cp)
-{
- char *p;
-
- if(c <= 0)
- c = FontFileGetc(f);
-
- if(c <= 0) {
- return EOF_TOKEN;
- }
-
- while(c == ' ' || c == '\t')
- c = FontFileGetc(f);
-
- if(c=='\n') {
- return EOL_TOKEN;
- } else if(c == '#') {
- skipEndOfLine(f,c);
- return EOL_TOKEN;
- } else if(c >= '0' && c <= '9') {
- number_value = getnum(f,c,cp);
- return NUMBER_TOKEN;
- } else if((c >= 'A' && c <= 'Z') ||
- (c >= 'a' && c <= 'z') ||
- c == '/' || c == '_' || c == '-' || c == '.') {
- p = keyword_value;
- *p++ = c;
- while(p-keyword_value < MAXKEYWORDLEN) {
- c = FontFileGetc(f);
- if(c <= ' ' || c > '~' || c == '#')
- break;
- *p++ = c;
- }
- *cp = c;
- *p = '\0';
- return KEYWORD_TOKEN;
- } else {
- *cp = c;
- return ERROR_TOKEN;
- }
-}
-
-/* Parse a line.
- * Always skips to the beginning of a new line, even if an error occurs */
-static int
-getnextline(FontFilePtr f)
-{
- int c, token;
- c = FontFileGetc(f);
- if(c <= 0)
- return EOF_LINE;
-
- again:
- token=gettoken(f,c,&c);
-
- switch(token) {
- case EOF_TOKEN:
- return EOF_LINE;
- case EOL_TOKEN:
- /* empty line */
- c = FontFileGetc(f);
- goto again;
- case NUMBER_TOKEN:
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value3 = number_value;
- return CODE_RANGE_LINE;
- case EOL_TOKEN:
- return CODE_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- case KEYWORD_TOKEN:
- if(!endOfLine(f,c))
- return ERROR_LINE;
- else
- return NAME_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- case KEYWORD_TOKEN:
- if(!strcasecmp(keyword_value, "STARTENCODING")) {
- token = gettoken(f,c,&c);
- if(token == KEYWORD_TOKEN) {
- if(endOfLine(f,c))
- return STARTENCODING_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "ALIAS")) {
- token = gettoken(f,c,&c);
- if(token == KEYWORD_TOKEN) {
- if(endOfLine(f,c))
- return ALIAS_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "SIZE")) {
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- return SIZE_LINE;
- case EOL_TOKEN:
- value2=0;
- return SIZE_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- token = gettoken(f,c,&c);
- switch(token) {
- case NUMBER_TOKEN:
- value2 = number_value;
- return FIRSTINDEX_LINE;
- case EOL_TOKEN:
- value2 = 0;
- return FIRSTINDEX_LINE;
- default:
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
- keyword_value[0] = 0;
- value1 = 0; value1 = 0;
- /* first a keyword */
- token = gettoken(f,c,&c);
- if(token != KEYWORD_TOKEN) {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- /* optional first integer */
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value1 = number_value;
- } else if(token == EOL_TOKEN) {
- return STARTMAPPING_LINE;
- } else {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- /* optional second integer */
- token = gettoken(f,c,&c);
- if(token == NUMBER_TOKEN) {
- value2 = number_value;
- } else if(token == EOL_TOKEN) {
- return STARTMAPPING_LINE;
- } else {
- skipEndOfLine(f, c);
- return ERROR_LINE;
- }
-
- if(!endOfLine(f,c))
- return ERROR_LINE;
- else {
- return STARTMAPPING_LINE;
- }
- } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
- /* first integer */
- token = gettoken(f,c,&c);
- if(token != NUMBER_TOKEN) {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- value1 = number_value;
- /* optional second integer */
- token = gettoken(f,c,&c);
- if(token == EOL_TOKEN) {
- value2 = value1;
- return CODE_UNDEFINE_LINE;
- } else if(token == NUMBER_TOKEN) {
- value2 = number_value;
- if(endOfLine(f,c)) {
- return CODE_UNDEFINE_LINE;
- } else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
- if(endOfLine(f,c))
- return EOF_LINE;
- else
- return ERROR_LINE;
- } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
- if(endOfLine(f,c))
- return ENDMAPPING_LINE;
- else
- return ERROR_LINE;
- } else {
- skipEndOfLine(f,c);
- return ERROR_LINE;
- }
- default:
- return ERROR_LINE;
- }
-}
-
-static void
-install_mapping(FontEncPtr encoding, FontMapPtr mapping)
-{
- FontMapPtr m;
-
- if(encoding->mappings == NULL)
- encoding->mappings = mapping;
- else {
- m = encoding->mappings;
- while(m->next != NULL)
- m = m->next;
- m->next = mapping;
- }
- mapping->next = NULL;
- mapping->encoding = encoding;
-}
-
-static int
-setCode(unsigned from, unsigned to, unsigned row_size,
- unsigned *first, unsigned *last,
- unsigned *encsize, unsigned short **enc)
-{
- unsigned index, i;
- unsigned short *newenc;
-
- if(from>0xFFFF)
- return 0; /* success */
-
- if(row_size==0)
- index=from;
- else {
- if((value1 & 0xFF) >= row_size)
- return 0; /* ignore out of range mappings */
- index = (from>>8) * row_size + (from&0xFF);
- }
-
- /* Optimize away useless identity mappings. This is only expected
- to be useful with linear encodings. */
- if(index == to && (index < *first || index > *last))
- return 0;
- if(*encsize == 0) {
- *encsize = (index < 256) ? 256 : 0x10000;
- *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short));
- if(*enc == NULL) {
- *encsize = 0;
- return 1;
- }
- } else if(*encsize <= index) {
- *encsize = 0x10000;
- if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL)
- return 1;
- *enc = newenc;
- }
- if(*first > *last) {
- *first = *last = index;
- }
- if(index < *first) {
- for(i = index; i < *first; i++)
- (*enc)[i] = i;
- *first = index;
- }
- if(index > *last) {
- for(i = *last + 1; i <= index; i++)
- (*enc)[i] = i;
- *last = index;
- }
- (*enc)[index] = to;
- return 0;
-}
-
-/* Parser. If headerOnly is true, we're only interested in the
- data contained in the encoding file's header. */
-
-/* As font encodings are currently never freed, the allocations done
- by this function are mostly its private business. Note, however,
- that FontEncIdentify needs to free the header fields -- so if you
- change this function, you may need to change FontEncIdentify. */
-
-/* I want a garbage collector. */
-
-static FontEncPtr
-parseEncodingFile(FontFilePtr f, int headerOnly)
-{
- int line;
-
- unsigned short *enc=NULL;
- char **nam = NULL, **newnam;
- unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
- FontEncPtr encoding = NULL;
- FontMapPtr mapping = NULL;
- FontEncSimpleMapPtr sm;
- FontEncSimpleNamePtr sn;
- char *aliases[MAXALIASES];
- int numaliases=0;
-
-#if 0
- /* GCC complains about unused labels. Please fix GCC rather than
- obfuscating my code. */
- no_encoding:
-#endif
- line = getnextline(f);
- switch(line) {
- case EOF_LINE:
- goto error;
- case STARTENCODING_LINE:
- encoding = (FontEncPtr)xalloc(sizeof(FontEncRec));
- if(encoding == NULL)
- goto error;
- encoding->name = (char*)xalloc(strlen(keyword_value)+1);
- if(encoding->name == NULL)
- goto error;
- strcpy(encoding->name, keyword_value);
- encoding->size = 256;
- encoding->row_size = 0;
- encoding->mappings = NULL;
- encoding->next = NULL;
- encoding->first = encoding->first_col=0;
- goto no_mapping;
- default:
- goto error;
- }
-
- no_mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto done;
- case ALIAS_LINE:
- if(numaliases < MAXALIASES) {
- aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1);
- if(aliases[numaliases] == NULL)
- goto error;
- strcpy(aliases[numaliases], keyword_value);
- numaliases++;
- }
- goto no_mapping;
- case SIZE_LINE:
- encoding->size = value1;
- encoding->row_size = value2;
- goto no_mapping;
- case FIRSTINDEX_LINE:
- encoding->first = value1;
- encoding->first_col = value2;
- goto no_mapping;
- case STARTMAPPING_LINE:
- if(headerOnly)
- goto done;
- if(!strcasecmp(keyword_value, "unicode")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_UNICODE;
- mapping->pid = 0;
- mapping->eid = 0;
- mapping->recode = NULL;
- mapping->name = NULL;
- mapping->client_data = NULL;
- mapping->next = NULL;
- goto mapping;
- } else if(!strcasecmp(keyword_value, "cmap")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_TRUETYPE;
- mapping->pid = value1;
- mapping->eid = value2;
- mapping->recode = NULL;
- mapping->name = NULL;
- mapping->client_data = NULL;
- mapping->next = NULL;
- goto mapping;
- } else if(!strcasecmp(keyword_value, "postscript")) {
- mapping = (FontMapPtr)xalloc(sizeof(FontMapRec));
- if(mapping == NULL)
- goto error;
- mapping->type = FONT_ENCODING_POSTSCRIPT;
- mapping->pid = 0;
- mapping->eid = 0;
- mapping->recode = NULL;
- mapping->name = NULL;
- mapping->client_data = NULL;
- mapping->next = NULL;
- goto string_mapping;
- } else { /* unknown mapping type -- ignore */
- goto skipmapping;
- }
- /* NOTREACHED */
- goto error;
- default: goto no_mapping; /* ignore unknown lines */
- }
-
- skipmapping:
- line = getnextline(f);
- switch(line) {
- case ENDMAPPING_LINE:
- goto no_mapping;
- case EOF_LINE:
- goto error;
- default:
- goto skipmapping;
- }
-
- mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto error;
- case ENDMAPPING_LINE:
- mapping->recode = FontEncSimpleRecode;
- mapping->name = FontEncUndefinedName;
- mapping->client_data = sm =
- (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec));
- if(sm == NULL)
- goto error;
- sm->row_size = encoding->row_size;
- if(first <= last) {
- unsigned short *newmap;
-
- sm->first = first;
- sm->len=last-first+1;
- newmap =
- (unsigned short*)xalloc(sm->len * sizeof(unsigned short));
- if(newmap == NULL) {
- xfree(sm);
- mapping->client_data = sm = NULL;
- goto error;
- }
- for(i=0; i < sm->len; i++)
- newmap[i] = enc[first+i];
- sm->map = newmap;
- } else {
- sm->first = 0;
- sm->len = 0;
- sm->map = NULL;
- }
- install_mapping(encoding, mapping);
- mapping = NULL;
- first = 0xFFFF; last=0;
- goto no_mapping;
-
- case CODE_LINE:
- if(setCode(value1, value2, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- goto mapping;
-
- case CODE_RANGE_LINE:
- if(value1 > 0x10000)
- value1 = 0x10000;
- if(value2 > 0x10000)
- value2 = 0x10000;
- if(value2 < value1)
- goto mapping;
- /* Do the last value first to avoid having to realloc() */
- if(setCode(value2, value3+(value2-value1), encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- for(i=value1; i<value2; i++) {
- if(setCode(i, value3+(i-value1), encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- }
- goto mapping;
-
- case CODE_UNDEFINE_LINE:
- if(value1 > 0x10000)
- value1 = 0x10000;
- if(value2 > 0x10000)
- value2 = 0x10000;
- if(value2 < value1)
- goto mapping;
- /* Do the last value first to avoid having to realloc() */
- if(setCode(value2, 0, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- for(i = value1; i < value2; i++) {
- if(setCode(i, 0, encoding->row_size,
- &first, &last, &encsize, &enc))
- goto error;
- }
- goto mapping;
-
- default: goto mapping; /* ignore unknown lines */
- }
-
- string_mapping:
- line = getnextline(f);
- switch(line) {
- case EOF_LINE: goto error;
- case ENDMAPPING_LINE:
- mapping->recode = FontEncUndefinedRecode;
- mapping->name = FontEncSimpleName;
- mapping->client_data = sn =
- (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec));
- if(sn == NULL)
- goto error;
- if(first > last) {
- xfree(sn);
- mapping->client_data = sn = NULL;
- goto error;
- }
- sn->first = first;
- sn->len = last - first + 1;
- sn->map = (char**)xalloc(sn->len*sizeof(char*));
- if(sn->map == NULL) {
- xfree(sn);
- mapping->client_data = sn = NULL;
- goto error;
- }
- for(i = 0; i < sn->len; i++)
- sn->map[i] = nam[first+i];
- install_mapping(encoding,mapping);
- mapping = NULL;
- first = 0xFFFF; last=0;
- goto no_mapping;
- case NAME_LINE:
- if(value1 >= 0x10000) goto string_mapping;
- if(namsize == 0) {
- namsize = (value1) < 256 ? 256 : 0x10000;
- nam = (char**)xalloc(namsize * sizeof(char*));
- if(nam == NULL) {
- namsize=0;
- goto error;
- }
- } else if(namsize <= value1) {
- namsize = 0x10000;
- if((newnam = (char**)xrealloc(nam, namsize)) == NULL)
- goto error;
- nam = newnam;
- }
- if(first > last) {
- first = last = value1;
- }
- if(value1 < first) {
- for(i = value1; i < first; i++)
- nam[i] = NULL;
- first = value1;
- }
- if(value1 > last) {
- for(i=last+1; i <= value1; i++)
- nam[i]=NULL;
- last = value1;
- }
- nam[value1] = (char*)xalloc(strlen(keyword_value)+1);
- if(nam[value1] == NULL) {
- goto error;
- }
- strcpy(nam[value1], keyword_value);
- goto string_mapping;
-
- default: goto string_mapping; /* ignore unknown lines */
- }
-
- done:
- if(encsize) xfree(enc); encsize=0; enc = NULL;
- if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */
-
- encoding->aliases=NULL;
- if(numaliases) {
- encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*));
- if(encoding->aliases == NULL)
- goto error;
- for(i=0; i<numaliases; i++)
- encoding->aliases[i] = aliases[i];
- encoding->aliases[numaliases]=NULL;
- }
-
- return encoding;
-
-error:
- if(encsize) xfree(enc); encsize=0;
- if(namsize) {
- for(i = first; i <= last; i++)
- if(nam[i])
- xfree(nam[i]);
- xfree(nam);
- namsize = 0;
- }
- if(mapping) {
- if(mapping->client_data) xfree(mapping->client_data);
- xfree(mapping);
- }
- if(encoding) {
- FontMapPtr nextmap;
- if (encoding->name) xfree(encoding->name);
- for (mapping = encoding->mappings; mapping; mapping = nextmap) {
- if (mapping->client_data) xfree(mapping->client_data);
- nextmap = mapping->next;
- xfree(mapping);
- }
- xfree(encoding);
- }
- for(i = 0; i < numaliases; i++)
- xfree(aliases[i]);
- /* We don't need to free sn and sm as they handled locally in the body.*/
- return NULL;
-}
-
-char*
-FontEncDirectory(void)
-{
- static char* dir = NULL;
-
- if(dir == NULL) {
- char *c = getenv("FONT_ENCODINGS_DIRECTORY");
- if(c) {
- dir = malloc(strlen(c) + 1);
- if(!dir)
- return NULL;
- strcpy(dir, c);
- } else {
- dir = FONT_ENCODINGS_DIRECTORY;
- }
- }
- return dir;
-}
-
-static void
-parseFontFileName(const char *fontFileName, char *buf, char *dir)
-{
- const char *p;
- char *q, *lastslash;
-
- for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
- *q = *p;
- if(*p == '/')
- lastslash = q+1;
- }
-
- if(!lastslash)
- lastslash = dir;
-
- *lastslash = '\0';
-
- if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
- strcpy(buf, dir);
- strcat(buf, "encodings.dir");
- }
-}
-
-static FontEncPtr
-FontEncReallyReallyLoad(const char *charset,
- const char *dirname, const char *dir)
-{
- FontFilePtr f;
- FILE *file;
- FontEncPtr encoding;
- char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
- buf[MAXFONTFILENAMELEN];
- int count, n;
- static char format[24] = "";
-
- /* As we don't really expect to open encodings that often, we don't
- take the trouble of caching encodings directories. */
-
- if((file = fopen(dirname, "r")) == NULL) {
- return NULL;
- }
-
- count = fscanf(file, "%d\n", &n);
- if(count == EOF || count != 1) {
- fclose(file);
- return NULL;
- }
-
- encoding = NULL;
- if (!format[0]) {
- sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
- (int)sizeof(file_name) - 1);
- }
- for(;;) {
- count = fscanf(file, format, encoding_name, file_name);
- if(count == EOF)
- break;
- if(count != 2)
- break;
-
- if(!strcasecmp(encoding_name, charset)) {
- /* Found it */
- if(file_name[0] != '/') {
- if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) {
- fclose(file);
- return NULL;
- }
- strcpy(buf, dir);
- strcat(buf, file_name);
- } else {
- strcpy(buf , file_name);
- }
-
- f = FontFileOpen(buf);
- if(f == NULL) {
- fclose(file);
- return NULL;
- }
- encoding = parseEncodingFile(f, 0);
- FontFileClose(f);
- break;
- }
- }
-
- fclose(file);
-
- return encoding;
-}
-
-/* Parser ntrypoint -- used by FontEncLoad */
-FontEncPtr
-FontEncReallyLoad(const char *charset, const char *fontFileName)
-{
- FontEncPtr encoding;
- char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
- char *d;
-
- if(fontFileName) {
- parseFontFileName(fontFileName, dirname, dir);
- encoding = FontEncReallyReallyLoad(charset, dirname, dir);
- if(encoding)
- return(encoding);
- }
-
- d = FontEncDirectory();
- if(d) {
- parseFontFileName(d, NULL, dir);
- encoding = FontEncReallyReallyLoad(charset, d, dir);
- return encoding;
- }
-
- return NULL;
-}
-
-/* Return a NULL-terminated array of encoding names. Note that this
- * function has incestuous knowledge of the allocations done by
- * parseEncodingFile. */
-
-char **
-FontEncIdentify(const char *fileName)
-{
- FontFilePtr f;
- FontEncPtr encoding;
- char **names, **name, **alias;
- int numaliases;
-
- if((f = FontFileOpen(fileName))==NULL) {
- return NULL;
- }
- encoding = parseEncodingFile(f, 1);
- FontFileClose(f);
-
- if(!encoding)
- return NULL;
-
- numaliases = 0;
- if(encoding->aliases)
- for(alias = encoding->aliases; *alias; alias++)
- numaliases++;
-
- names = (char**)xalloc((numaliases+2)*sizeof(char*));
- if(names == NULL) {
- if(encoding->aliases)
- xfree(encoding->aliases);
- xfree(encoding);
- return NULL;
- }
-
- name = names;
- *(name++) = encoding->name;
- if(numaliases > 0)
- for(alias = encoding->aliases; *alias; alias++, name++)
- *name = *alias;
-
- *name = NULL;
- xfree(encoding->aliases);
- xfree(encoding);
-
- return names;
-}
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* Parser for encoding files */
+
+/* This code assumes that we are using ASCII. We don't use the ctype
+ functions, as they depend on the current locale. On the other
+ hand, we do use strcasecmp, but only on strings that we've checked
+ to be pure ASCII. Bloody ``Code Set Independence''. */
+
+#include <string.h>
+#include <stdio.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#include <stdlib.h>
+#ifdef _MSC_VER
+#define strdup _strdup
+#endif
+
+#include "zlib.h"
+typedef gzFile FontFilePtr;
+#define FontFileGetc(f) gzgetc(f)
+#define FontFileOpen(filename) gzopen(filename, "rb")
+#define FontFileClose(f) gzclose(f)
+
+#define MAXFONTFILENAMELEN 1024
+#define MAXFONTNAMELEN 1024
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+
+#define MAXALIASES 20
+
+#define EOF_TOKEN -1
+#define ERROR_TOKEN -2
+#define EOL_TOKEN 0
+#define NUMBER_TOKEN 1
+#define KEYWORD_TOKEN 2
+
+#define EOF_LINE -1
+#define ERROR_LINE -2
+#define STARTENCODING_LINE 1
+#define STARTMAPPING_LINE 2
+#define ENDMAPPING_LINE 3
+#define CODE_LINE 4
+#define CODE_RANGE_LINE 5
+#define CODE_UNDEFINE_LINE 6
+#define NAME_LINE 7
+#define SIZE_LINE 8
+#define ALIAS_LINE 9
+#define FIRSTINDEX_LINE 10
+
+/* Return from lexer */
+#define MAXKEYWORDLEN 100
+
+static long number_value;
+static char keyword_value[MAXKEYWORDLEN+1];
+
+static long value1, value2, value3;
+
+/* Lexer code */
+
+/* Skip to the beginning of new line */
+static void
+skipEndOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;)
+ if(c <= 0 || c == '\n')
+ return;
+ else
+ c = FontFileGetc(f);
+}
+
+/* Get a number; we're at the first digit. */
+static unsigned
+getnum(FontFilePtr f, int c, int *cp)
+{
+ unsigned n = 0;
+ int base = 10;
+
+ /* look for `0' or `0x' prefix */
+ if(c == '0') {
+ c = FontFileGetc(f);
+ base = 8;
+ if(c == 'x' || c == 'X') {
+ base = 16;
+ c = FontFileGetc(f);
+ }
+ }
+
+ /* accumulate digits */
+ for(;;) {
+ if ('0' <= c && c <= '9') {
+ n *= base; n += c - '0';
+ } else if('a' <= c && c <= 'f') {
+ n *= base; n += c - 'a' + 10;
+ } else if('A' <=c && c <= 'F') {
+ n *= base; n += c - 'A' + 10;
+ } else
+ break;
+ c = FontFileGetc(f);
+ }
+
+ *cp = c; return n;
+}
+
+/* Skip to beginning of new line; return 1 if only whitespace was found. */
+static int
+endOfLine(FontFilePtr f, int c)
+{
+ if(c == 0)
+ c = FontFileGetc(f);
+
+ for(;;) {
+ if(c <= 0 || c == '\n')
+ return 1;
+ else if(c == '#') {
+ skipEndOfLine(f,c);
+ return 1;
+ }
+ else if(c == ' ' || c == '\t') {
+ skipEndOfLine(f,c);
+ return 0;
+ }
+ c = FontFileGetc(f);
+ }
+}
+
+/* Get a token; we're at first char */
+static int
+gettoken(FontFilePtr f, int c, int *cp)
+{
+ char *p;
+
+ if(c <= 0)
+ c = FontFileGetc(f);
+
+ if(c <= 0) {
+ return EOF_TOKEN;
+ }
+
+ while(c == ' ' || c == '\t')
+ c = FontFileGetc(f);
+
+ if(c=='\n') {
+ return EOL_TOKEN;
+ } else if(c == '#') {
+ skipEndOfLine(f,c);
+ return EOL_TOKEN;
+ } else if(c >= '0' && c <= '9') {
+ number_value = getnum(f,c,cp);
+ return NUMBER_TOKEN;
+ } else if((c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ c == '/' || c == '_' || c == '-' || c == '.') {
+ p = keyword_value;
+ *p++ = c;
+ while(p-keyword_value < MAXKEYWORDLEN) {
+ c = FontFileGetc(f);
+ if(c <= ' ' || c > '~' || c == '#')
+ break;
+ *p++ = c;
+ }
+ *cp = c;
+ *p = '\0';
+ return KEYWORD_TOKEN;
+ } else {
+ *cp = c;
+ return ERROR_TOKEN;
+ }
+}
+
+/* Parse a line.
+ * Always skips to the beginning of a new line, even if an error occurs */
+static int
+getnextline(FontFilePtr f)
+{
+ int c, token;
+ c = FontFileGetc(f);
+ if(c <= 0)
+ return EOF_LINE;
+
+ again:
+ token=gettoken(f,c,&c);
+
+ switch(token) {
+ case EOF_TOKEN:
+ return EOF_LINE;
+ case EOL_TOKEN:
+ /* empty line */
+ c = FontFileGetc(f);
+ goto again;
+ case NUMBER_TOKEN:
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value3 = number_value;
+ return CODE_RANGE_LINE;
+ case EOL_TOKEN:
+ return CODE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else
+ return NAME_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ case KEYWORD_TOKEN:
+ if(!strcasecmp(keyword_value, "STARTENCODING")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return STARTENCODING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ALIAS")) {
+ token = gettoken(f,c,&c);
+ if(token == KEYWORD_TOKEN) {
+ if(endOfLine(f,c))
+ return ALIAS_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "SIZE")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return SIZE_LINE;
+ case EOL_TOKEN:
+ value2=0;
+ return SIZE_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) {
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ token = gettoken(f,c,&c);
+ switch(token) {
+ case NUMBER_TOKEN:
+ value2 = number_value;
+ return FIRSTINDEX_LINE;
+ case EOL_TOKEN:
+ value2 = 0;
+ return FIRSTINDEX_LINE;
+ default:
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "STARTMAPPING")) {
+ keyword_value[0] = 0;
+ value1 = 0; value1 = 0;
+ /* first a keyword */
+ token = gettoken(f,c,&c);
+ if(token != KEYWORD_TOKEN) {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional first integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value1 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ } else if(token == EOL_TOKEN) {
+ return STARTMAPPING_LINE;
+ } else {
+ skipEndOfLine(f, c);
+ return ERROR_LINE;
+ }
+
+ if(!endOfLine(f,c))
+ return ERROR_LINE;
+ else {
+ return STARTMAPPING_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "UNDEFINE")) {
+ /* first integer */
+ token = gettoken(f,c,&c);
+ if(token != NUMBER_TOKEN) {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ value1 = number_value;
+ /* optional second integer */
+ token = gettoken(f,c,&c);
+ if(token == EOL_TOKEN) {
+ value2 = value1;
+ return CODE_UNDEFINE_LINE;
+ } else if(token == NUMBER_TOKEN) {
+ value2 = number_value;
+ if(endOfLine(f,c)) {
+ return CODE_UNDEFINE_LINE;
+ } else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ } else if(!strcasecmp(keyword_value, "ENDENCODING")) {
+ if(endOfLine(f,c))
+ return EOF_LINE;
+ else
+ return ERROR_LINE;
+ } else if(!strcasecmp(keyword_value, "ENDMAPPING")) {
+ if(endOfLine(f,c))
+ return ENDMAPPING_LINE;
+ else
+ return ERROR_LINE;
+ } else {
+ skipEndOfLine(f,c);
+ return ERROR_LINE;
+ }
+ default:
+ return ERROR_LINE;
+ }
+}
+
+static void
+install_mapping(FontEncPtr encoding, FontMapPtr mapping)
+{
+ FontMapPtr m;
+
+ if(encoding->mappings == NULL)
+ encoding->mappings = mapping;
+ else {
+ m = encoding->mappings;
+ while(m->next != NULL)
+ m = m->next;
+ m->next = mapping;
+ }
+ mapping->next = NULL;
+ mapping->encoding = encoding;
+}
+
+static int
+setCode(unsigned from, unsigned to, unsigned row_size,
+ unsigned *first, unsigned *last,
+ unsigned *encsize, unsigned short **enc)
+{
+ unsigned index, i;
+ unsigned short *newenc;
+
+ if(from>0xFFFF)
+ return 0; /* success */
+
+ if(row_size==0)
+ index=from;
+ else {
+ if((value1 & 0xFF) >= row_size)
+ return 0; /* ignore out of range mappings */
+ index = (from>>8) * row_size + (from&0xFF);
+ }
+
+ /* Optimize away useless identity mappings. This is only expected
+ to be useful with linear encodings. */
+ if(index == to && (index < *first || index > *last))
+ return 0;
+ if(*encsize == 0) {
+ *encsize = (index < 256) ? 256 : 0x10000;
+ *enc = malloc((*encsize) * sizeof(unsigned short));
+ if(*enc == NULL) {
+ *encsize = 0;
+ return 1;
+ }
+ } else if(*encsize <= index) {
+ *encsize = 0x10000;
+ if((newenc = realloc(enc, *encsize))==NULL)
+ return 1;
+ *enc = newenc;
+ }
+ if(*first > *last) {
+ *first = *last = index;
+ }
+ if(index < *first) {
+ for(i = index; i < *first; i++)
+ (*enc)[i] = i;
+ *first = index;
+ }
+ if(index > *last) {
+ for(i = *last + 1; i <= index; i++)
+ (*enc)[i] = i;
+ *last = index;
+ }
+ (*enc)[index] = to;
+ return 0;
+}
+
+/* Parser. If headerOnly is true, we're only interested in the
+ data contained in the encoding file's header. */
+
+/* As font encodings are currently never freed, the allocations done
+ by this function are mostly its private business. Note, however,
+ that FontEncIdentify needs to free the header fields -- so if you
+ change this function, you may need to change FontEncIdentify. */
+
+/* I want a garbage collector. */
+
+static FontEncPtr
+parseEncodingFile(FontFilePtr f, int headerOnly)
+{
+ int line;
+
+ unsigned short *enc=NULL;
+ char **nam = NULL, **newnam;
+ unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0;
+ FontEncPtr encoding = NULL;
+ FontMapPtr mapping = NULL;
+ FontEncSimpleMapPtr sm;
+ FontEncSimpleNamePtr sn;
+ char *aliases[MAXALIASES];
+ int numaliases=0;
+
+#if 0
+ /* GCC complains about unused labels. Please fix GCC rather than
+ obfuscating my code. */
+ no_encoding:
+#endif
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE:
+ goto error;
+ case STARTENCODING_LINE:
+ encoding = malloc(sizeof(FontEncRec));
+ if(encoding == NULL)
+ goto error;
+ encoding->name = strdup(keyword_value);
+ if(encoding->name == NULL)
+ goto error;
+ encoding->size = 256;
+ encoding->row_size = 0;
+ encoding->mappings = NULL;
+ encoding->next = NULL;
+ encoding->first = encoding->first_col=0;
+ goto no_mapping;
+ default:
+ goto error;
+ }
+
+ no_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto done;
+ case ALIAS_LINE:
+ if(numaliases < MAXALIASES) {
+ aliases[numaliases] = strdup(keyword_value);
+ if(aliases[numaliases] == NULL)
+ goto error;
+ numaliases++;
+ }
+ goto no_mapping;
+ case SIZE_LINE:
+ encoding->size = value1;
+ encoding->row_size = value2;
+ goto no_mapping;
+ case FIRSTINDEX_LINE:
+ encoding->first = value1;
+ encoding->first_col = value2;
+ goto no_mapping;
+ case STARTMAPPING_LINE:
+ if(headerOnly)
+ goto done;
+ if(!strcasecmp(keyword_value, "unicode")) {
+ mapping = malloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_UNICODE;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = NULL;
+ mapping->name = NULL;
+ mapping->client_data = NULL;
+ mapping->next = NULL;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "cmap")) {
+ mapping = malloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_TRUETYPE;
+ mapping->pid = value1;
+ mapping->eid = value2;
+ mapping->recode = NULL;
+ mapping->name = NULL;
+ mapping->client_data = NULL;
+ mapping->next = NULL;
+ goto mapping;
+ } else if(!strcasecmp(keyword_value, "postscript")) {
+ mapping = malloc(sizeof(FontMapRec));
+ if(mapping == NULL)
+ goto error;
+ mapping->type = FONT_ENCODING_POSTSCRIPT;
+ mapping->pid = 0;
+ mapping->eid = 0;
+ mapping->recode = NULL;
+ mapping->name = NULL;
+ mapping->client_data = NULL;
+ mapping->next = NULL;
+ goto string_mapping;
+ } else { /* unknown mapping type -- ignore */
+ goto skipmapping;
+ }
+ /* NOTREACHED */
+ goto error;
+ default: goto no_mapping; /* ignore unknown lines */
+ }
+
+ skipmapping:
+ line = getnextline(f);
+ switch(line) {
+ case ENDMAPPING_LINE:
+ goto no_mapping;
+ case EOF_LINE:
+ goto error;
+ default:
+ goto skipmapping;
+ }
+
+ mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncSimpleRecode;
+ mapping->name = FontEncUndefinedName;
+ mapping->client_data = sm = malloc(sizeof(FontEncSimpleMapRec));
+ if(sm == NULL)
+ goto error;
+ sm->row_size = encoding->row_size;
+ if(first <= last) {
+ unsigned short *newmap;
+
+ sm->first = first;
+ sm->len=last-first+1;
+ newmap = malloc(sm->len * sizeof(unsigned short));
+ if(newmap == NULL) {
+ free(sm);
+ mapping->client_data = sm = NULL;
+ goto error;
+ }
+ for(i=0; i < sm->len; i++)
+ newmap[i] = enc[first+i];
+ sm->map = newmap;
+ } else {
+ sm->first = 0;
+ sm->len = 0;
+ sm->map = NULL;
+ }
+ install_mapping(encoding, mapping);
+ mapping = NULL;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+
+ case CODE_LINE:
+ if(setCode(value1, value2, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ goto mapping;
+
+ case CODE_RANGE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, value3+(value2-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i=value1; i<value2; i++) {
+ if(setCode(i, value3+(i-value1), encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ case CODE_UNDEFINE_LINE:
+ if(value1 > 0x10000)
+ value1 = 0x10000;
+ if(value2 > 0x10000)
+ value2 = 0x10000;
+ if(value2 < value1)
+ goto mapping;
+ /* Do the last value first to avoid having to realloc() */
+ if(setCode(value2, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ for(i = value1; i < value2; i++) {
+ if(setCode(i, 0, encoding->row_size,
+ &first, &last, &encsize, &enc))
+ goto error;
+ }
+ goto mapping;
+
+ default: goto mapping; /* ignore unknown lines */
+ }
+
+ string_mapping:
+ line = getnextline(f);
+ switch(line) {
+ case EOF_LINE: goto error;
+ case ENDMAPPING_LINE:
+ mapping->recode = FontEncUndefinedRecode;
+ mapping->name = FontEncSimpleName;
+ mapping->client_data = sn = malloc(sizeof(FontEncSimpleNameRec));
+ if(sn == NULL)
+ goto error;
+ if(first > last) {
+ free(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ sn->first = first;
+ sn->len = last - first + 1;
+ sn->map = malloc(sn->len*sizeof(char*));
+ if(sn->map == NULL) {
+ free(sn);
+ mapping->client_data = sn = NULL;
+ goto error;
+ }
+ for(i = 0; i < sn->len; i++)
+ sn->map[i] = nam[first+i];
+ install_mapping(encoding,mapping);
+ mapping = NULL;
+ first = 0xFFFF; last=0;
+ goto no_mapping;
+ case NAME_LINE:
+ if(value1 >= 0x10000) goto string_mapping;
+ if(namsize == 0) {
+ namsize = (value1) < 256 ? 256 : 0x10000;
+ nam = malloc(namsize * sizeof(char*));
+ if(nam == NULL) {
+ namsize=0;
+ goto error;
+ }
+ } else if(namsize <= value1) {
+ namsize = 0x10000;
+ if((newnam = (char**)realloc(nam, namsize)) == NULL)
+ goto error;
+ nam = newnam;
+ }
+ if(first > last) {
+ first = last = value1;
+ }
+ if(value1 < first) {
+ for(i = value1; i < first; i++)
+ nam[i] = NULL;
+ first = value1;
+ }
+ if(value1 > last) {
+ for(i=last+1; i <= value1; i++)
+ nam[i]=NULL;
+ last = value1;
+ }
+ nam[value1] = strdup(keyword_value);
+ if(nam[value1] == NULL) {
+ goto error;
+ }
+ goto string_mapping;
+
+ default: goto string_mapping; /* ignore unknown lines */
+ }
+
+ done:
+ if(encsize) free(enc); encsize=0; enc = NULL;
+ if(namsize) free(nam); namsize=0; nam = NULL; /* don't free entries! */
+
+ encoding->aliases=NULL;
+ if(numaliases) {
+ encoding->aliases = malloc((numaliases+1)*sizeof(char*));
+ if(encoding->aliases == NULL)
+ goto error;
+ for(i=0; i<numaliases; i++)
+ encoding->aliases[i] = aliases[i];
+ encoding->aliases[numaliases]=NULL;
+ }
+
+ return encoding;
+
+error:
+ if(encsize) free(enc); encsize=0;
+ if(namsize) {
+ for(i = first; i <= last; i++)
+ free(nam[i]);
+ free(nam);
+ namsize = 0;
+ }
+ if(mapping) {
+ free(mapping->client_data);
+ free(mapping);
+ }
+ if(encoding) {
+ FontMapPtr nextmap;
+ free(encoding->name);
+ for (mapping = encoding->mappings; mapping; mapping = nextmap) {
+ free(mapping->client_data);
+ nextmap = mapping->next;
+ free(mapping);
+ }
+ free(encoding);
+ }
+ for(i = 0; i < numaliases; i++)
+ free(aliases[i]);
+ /* We don't need to free sn and sm as they handled locally in the body.*/
+ return NULL;
+}
+
+char*
+FontEncDirectory(void)
+{
+ static char* dir = NULL;
+
+ if(dir == NULL) {
+ char *c = getenv("FONT_ENCODINGS_DIRECTORY");
+ if(c) {
+ dir = strdup(c);
+ if(!dir)
+ return NULL;
+ } else {
+ dir = FONT_ENCODINGS_DIRECTORY;
+ }
+ }
+ return dir;
+}
+
+static void
+parseFontFileName(const char *fontFileName, char *buf, char *dir)
+{
+ const char *p;
+ char *q, *lastslash;
+
+ for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) {
+ *q = *p;
+ if(*p == '/')
+ lastslash = q+1;
+ }
+
+ if(!lastslash)
+ lastslash = dir;
+
+ *lastslash = '\0';
+
+ if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) {
+ strcpy(buf, dir);
+ strcat(buf, "encodings.dir");
+ }
+}
+
+static FontEncPtr
+FontEncReallyReallyLoad(const char *charset,
+ const char *dirname, const char *dir)
+{
+ FontFilePtr f;
+ FILE *file;
+ FontEncPtr encoding;
+ char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN],
+ buf[MAXFONTFILENAMELEN];
+ int count, n;
+ static char format[24] = "";
+
+ /* As we don't really expect to open encodings that often, we don't
+ take the trouble of caching encodings directories. */
+
+ if((file = fopen(dirname, "r")) == NULL) {
+ return NULL;
+ }
+
+ count = fscanf(file, "%d\n", &n);
+ if(count == EOF || count != 1) {
+ fclose(file);
+ return NULL;
+ }
+
+ encoding = NULL;
+ if (!format[0]) {
+ sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1,
+ (int)sizeof(file_name) - 1);
+ }
+ for(;;) {
+ count = fscanf(file, format, encoding_name, file_name);
+ if(count == EOF)
+ break;
+ if(count != 2)
+ break;
+
+ if(!strcasecmp(encoding_name, charset)) {
+ /* Found it */
+ if(file_name[0] != '/') {
+ if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) {
+ fclose(file);
+ return NULL;
+ }
+ strcpy(buf, dir);
+ strcat(buf, file_name);
+ } else {
+ strcpy(buf , file_name);
+ }
+
+ f = FontFileOpen(buf);
+ if(f == NULL) {
+ fclose(file);
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 0);
+ FontFileClose(f);
+ break;
+ }
+ }
+
+ fclose(file);
+
+ return encoding;
+}
+
+/* Parser ntrypoint -- used by FontEncLoad */
+FontEncPtr
+FontEncReallyLoad(const char *charset, const char *fontFileName)
+{
+ FontEncPtr encoding;
+ char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
+ char *d;
+
+ if(fontFileName) {
+ parseFontFileName(fontFileName, dirname, dir);
+ encoding = FontEncReallyReallyLoad(charset, dirname, dir);
+ if(encoding)
+ return(encoding);
+ }
+
+ d = FontEncDirectory();
+ if(d) {
+ parseFontFileName(d, NULL, dir);
+ encoding = FontEncReallyReallyLoad(charset, d, dir);
+ return encoding;
+ }
+
+ return NULL;
+}
+
+/* Return a NULL-terminated array of encoding names. Note that this
+ * function has incestuous knowledge of the allocations done by
+ * parseEncodingFile. */
+
+char **
+FontEncIdentify(const char *fileName)
+{
+ FontFilePtr f;
+ FontEncPtr encoding;
+ char **names, **name, **alias;
+ int numaliases;
+
+ if((f = FontFileOpen(fileName))==NULL) {
+ return NULL;
+ }
+ encoding = parseEncodingFile(f, 1);
+ FontFileClose(f);
+
+ if(!encoding)
+ return NULL;
+
+ numaliases = 0;
+ if(encoding->aliases)
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+
+ names = malloc((numaliases+2)*sizeof(char*));
+ if(names == NULL) {
+ free(encoding->aliases);
+ free(encoding);
+ return NULL;
+ }
+
+ name = names;
+ *(name++) = encoding->name;
+ if(numaliases > 0)
+ for(alias = encoding->aliases; *alias; alias++, name++)
+ *name = *alias;
+
+ *name = NULL;
+ free(encoding->aliases);
+ free(encoding);
+
+ return names;
+}
diff --git a/libfontenc/src/fontenc.c b/libfontenc/src/fontenc.c
index 923e35ea2..a121eca8f 100644
--- a/libfontenc/src/fontenc.c
+++ b/libfontenc/src/fontenc.c
@@ -1,953 +1,938 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XdotOrg: xc/lib/font/fontfile/fontenc.c,v 1.3 2005/07/03 07:01:00 daniels Exp $ */
-/* $XFree86: xc/lib/font/fontfile/fontenc.c,v 1.15 2003/02/20 03:25:19 dawes Exp $ */
-
-/* Backend-independent encoding code */
-
-#include <string.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <strings.h>
-#endif
-
-#ifndef FONTENC_NO_LIBFONT
-
-#include <X11/fonts/fontmisc.h> /* defines xalloc and friends */
-#include <X11/fonts/fntfilst.h>
-
-#else
-
-#include <stdlib.h>
-#define xalloc(n) malloc(n)
-#define xrealloc(p, n) realloc(p, n)
-#define xfree(p) free(p)
-#define FALSE 0
-#define TRUE 1
-#define MAXFONTNAMELEN 1024
-#define MAXFONTFILENAMELEN 1024
-
-#endif /* FONTENC_NO_FONTFILE */
-
-#include <X11/fonts/fontenc.h>
-#include "fontencI.h"
-
-/* Functions local to this file */
-
-static FontEncPtr FontEncLoad(const char*, const char*);
-
-/* Early versions of this code only knew about hardwired encodings,
- hence the following data. Now that the code knows how to load an
- encoding from a file, most of these tables could go away. */
-
-/* At any rate, no new hardcoded encodings will be added. */
-
-static FontMapRec iso10646[]=
-{
- {FONT_ENCODING_UNICODE,0,0,NULL,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* Notice that the Apple encodings do not have all the characters in
- the corresponding ISO 8859, and therefore the table has some holes.
- There's not much more we can do with fonts without a Unicode cmap
- unless we are willing to combine cmaps (which we are not). */
-
-static const unsigned short
-iso8859_1_apple_roman[]=
-{ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0x00, 0xA4,
- 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
- 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
- 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
- 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
- 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
- 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
- 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
- 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
- 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
- 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
- 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8 };
-
-/* Cannot use simple_recode because need to eliminate 0x80<=code<0xA0 */
-static unsigned
-iso8859_1_to_apple_roman(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_1_apple_roman[isocode-0xA0];
- else
- return 0;
-}
-
-static FontMapRec iso8859_1[]=
-{
- {FONT_ENCODING_TRUETYPE,2,2,NULL,NULL,NULL,NULL,NULL}, /* ISO 8859-1 */
- {FONT_ENCODING_UNICODE,0,0,NULL,NULL,NULL,NULL,NULL}, /* ISO 8859-1 coincides with Unicode*/
- {FONT_ENCODING_TRUETYPE,1,0,iso8859_1_to_apple_roman,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static const unsigned short iso8859_2_tophalf[]=
-{ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
- 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
- 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
- 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
- 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
- 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
- 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
- 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
- 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
- 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 };
-
-static FontEncSimpleMapRec iso8859_2_to_unicode_map=
-{0x60, 0, 0xA0, iso8859_2_tophalf };
-
-static const unsigned short iso8859_2_apple_centeuro[]=
-{ 0xCA, 0x84, 0x00, 0xFC, 0x00, 0xBB, 0xE5, 0xA4,
- 0xAC, 0xE1, 0x00, 0xE8, 0x8F, 0x00, 0xEB, 0xFB,
- 0xA1, 0x88, 0x00, 0xB8, 0x00, 0xBC, 0xE6, 0xFF,
- 0x00, 0xE4, 0x00, 0xE9, 0x90, 0x00, 0xEC, 0xFD,
- 0xD9, 0xE7, 0x00, 0x00, 0x80, 0xBD, 0x8C, 0x00,
- 0x89, 0x83, 0xA2, 0x00, 0x9D, 0xEA, 0x00, 0x91,
- 0x00, 0xC1, 0xC5, 0xEE, 0xEF, 0xCC, 0x85, 0x00,
- 0xDB, 0xF1, 0xF2, 0xF4, 0x86, 0xF8, 0x00, 0xA7,
- 0xDA, 0x87, 0x00, 0x00, 0x8A, 0xBE, 0x8D, 0x00,
- 0x8B, 0x8E, 0xAB, 0x00, 0x9E, 0x92, 0x00, 0x93,
- 0x00, 0xC4, 0xCB, 0x97, 0x99, 0xCE, 0x9A, 0xD6,
- 0xDE, 0xF3, 0x9C, 0xF5, 0x9F, 0xF9, 0x00, 0x00 };
-
-static unsigned
-iso8859_2_to_apple_centeuro(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_2_apple_centeuro[isocode-0xA0];
- else
- return 0;
-}
-
-
-static FontMapRec iso8859_2[]=
-{
- {FONT_ENCODING_UNICODE,0,0,
- FontEncSimpleRecode,NULL,&iso8859_2_to_unicode_map,NULL,NULL},
- {FONT_ENCODING_TRUETYPE,1,29,iso8859_2_to_apple_centeuro,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static const unsigned short iso8859_3_tophalf[]=
-{ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0x0000, 0x0124, 0x00A7,
- 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0x0000, 0x017B,
- 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
- 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0x0000, 0x017C,
- 0x00C0, 0x00C1, 0x00C2, 0x0000, 0x00C4, 0x010A, 0x0108, 0x00C7,
- 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
- 0x0000, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
- 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
- 0x00E0, 0x00E1, 0x00E2, 0x0000, 0x00E4, 0x010B, 0x0109, 0x00E7,
- 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
- 0x0000, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
- 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9};
-
-static FontEncSimpleMapRec iso8859_3_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_3_tophalf };
-
-static FontMapRec iso8859_3[]=
-{
- {FONT_ENCODING_UNICODE,0,0,
- FontEncSimpleRecode,NULL,&iso8859_3_to_unicode_map,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-
-static const unsigned short iso8859_4_tophalf[]=
-{ 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7,
- 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
- 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7,
- 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
- 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
- 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
- 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
- 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
- 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
- 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,
-};
-
-static FontEncSimpleMapRec iso8859_4_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_4_tophalf };
-
-static FontMapRec iso8859_4[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
- &iso8859_4_to_unicode_map,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static const unsigned short iso8859_5_tophalf[]=
-{ 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
- 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
- 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
- 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
- 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
- 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
- 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
- 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
- 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F};
-
-static FontEncSimpleMapRec iso8859_5_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_5_tophalf };
-
-static const unsigned short
-iso8859_5_apple_cyrillic[]=
-{ 0xCA, 0xDD, 0xAB, 0xAE, 0xB8, 0xC1, 0xA7, 0xBA,
- 0xB7, 0xBC, 0xBE, 0xCB, 0xCD, 0x00, 0xD8, 0xDA,
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
- 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
- 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
- 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
- 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
- 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
- 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF,
- 0xDC, 0xDE, 0xAC, 0xAF, 0xB9, 0xCF, 0xB4, 0xBB,
- 0xC0, 0xBD, 0xBF, 0xCC, 0xCE, 0xA4, 0xD9, 0xDB };
-
-static unsigned
-iso8859_5_to_apple_cyrillic(unsigned isocode, void *client_data)
-{
- if(isocode<=0x80)
- return isocode;
- else if(isocode>=0xA0)
- return iso8859_5_apple_cyrillic[isocode-0x80];
- else return 0;
-}
-
-static FontMapRec iso8859_5[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
- &iso8859_5_to_unicode_map,NULL,NULL},
- {FONT_ENCODING_TRUETYPE,1,7,iso8859_5_to_apple_cyrillic,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* ISO 8859-6 seems useless for serving fonts (not enough presentation
- * forms). What do Arabic-speakers use? */
-
-static unsigned
-iso8859_6_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode<=0xA0 || isocode==0xA4 || isocode==0xAD)
- return isocode;
- else if(isocode==0xAC || isocode==0xBB ||
- (isocode>=0xBF && isocode<=0xDA) ||
- (isocode>=0xE0 && isocode<=0xEF) ||
- (isocode>=0xF0 && isocode<=0xF2))
- return isocode-0xA0+0x0600;
- else
- return 0;
-}
-
-static FontMapRec iso8859_6[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_6_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static unsigned
-iso8859_7_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode<=0xA0 ||
- (isocode>=0xA3 && isocode<=0xAD) ||
- (isocode>=0xB0 && isocode<=0xB3) ||
- isocode==0xB7 || isocode==0xBB || isocode==0xBD)
- return isocode;
- else if(isocode==0xA1)
- return 0x02BD;
- else if(isocode==0xA2)
- return 0x02BC;
- else if(isocode==0xAF)
- return 0x2015;
- else if(isocode>=0xB4)
- return isocode-0xA0+0x0370;
- else
- return 0;
-}
-
-static FontMapRec iso8859_7[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_7_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static unsigned
-iso8859_8_to_unicode(unsigned isocode, void *client_data)
-{
- if(isocode==0xA1)
- return 0;
- else if(isocode<0xBF)
- return isocode;
- else if(isocode==0xDF)
- return 0x2017;
- else if(isocode>=0xE0 && isocode<=0xFA)
- return isocode+0x04F0;
- else
- return 0;
-}
-
-static FontMapRec iso8859_8[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_8_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static unsigned
-iso8859_9_to_unicode(unsigned isocode, void *client_data)
-{
- switch(isocode) {
- case 0xD0: return 0x011E;
- case 0xDD: return 0x0130;
- case 0xDE: return 0x015E;
- case 0xF0: return 0x011F;
- case 0xFD: return 0x0131;
- case 0xFE: return 0x015F;
- default: return isocode;
- }
-}
-
-static FontMapRec iso8859_9[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_9_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static const unsigned short iso8859_10_tophalf[]=
-{ 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7,
- 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A,
- 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7,
- 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2014, 0x016B, 0x014B,
- 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
- 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF,
- 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168,
- 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
- 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
- 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF,
- 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169,
- 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138};
-
-static FontEncSimpleMapRec iso8859_10_to_unicode_map=
-{ 0x60, 0, 0xA0, iso8859_10_tophalf };
-
-static FontMapRec iso8859_10[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
- &iso8859_10_to_unicode_map,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static unsigned
-iso8859_15_to_unicode(unsigned isocode, void *client_data)
-{
- switch(isocode) {
- case 0xA4: return 0x20AC;
- case 0xA6: return 0x0160;
- case 0xA8: return 0x0161;
- case 0xB4: return 0x017D;
- case 0xB8: return 0x017E;
- case 0xBC: return 0x0152;
- case 0xBD: return 0x0153;
- case 0xBE: return 0x0178;
- default: return isocode;
- }
-}
-
-static FontMapRec iso8859_15[]=
-{
- {FONT_ENCODING_UNICODE,0,0,iso8859_15_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static const unsigned short koi8_r_tophalf[]=
-{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
- 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
- 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2022, 0x221A, 0x2248,
- 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
- 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
- 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
- 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
- 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
- 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
- 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
- 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
- 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
- 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
- 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
- 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
- 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A};
-
-static FontEncSimpleMapRec koi8_r_to_unicode_map=
-{ 0x80, 0, 0x80, koi8_r_tophalf };
-
-
-static FontMapRec koi8_r[]=
-{
- {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
- &koi8_r_to_unicode_map,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-static unsigned
-koi8_ru_to_unicode(unsigned koicode, void *client_data)
-{
- switch(koicode) {
- case 0x93: return 0x201C;
- case 0x96: return 0x201D;
- case 0x97: return 0x2014;
- case 0x98: return 0x2116;
- case 0x99: return 0x2122;
- case 0x9B: return 0x00BB;
- case 0x9C: return 0x00AE;
- case 0x9D: return 0x00AB;
- case 0x9F: return 0x00A4;
- case 0xA4: return 0x0454;
- case 0xA6: return 0x0456;
- case 0xA7: return 0x0457;
- case 0xAD: return 0x0491;
- case 0xAE: return 0x045E;
- case 0xB4: return 0x0404;
- case 0xB6: return 0x0406;
- case 0xB7: return 0x0407;
- case 0xBD: return 0x0490;
- case 0xBE: return 0x040E;
- default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
- }
-}
-
-static FontMapRec koi8_ru[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_ru_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* koi8-e, ISO-IR-111 or ECMA-Cyrillic */
-
-static const unsigned short koi8_e_A0_BF[]=
-{ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00AD, 0x045E, 0x045F,
- 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00A4, 0x040E, 0x040F };
-
-static unsigned
-koi8_e_to_unicode(unsigned koicode, void *client_data)
-{
- if(koicode<0xA0)
- return koicode;
- else if(koicode<0xC0)
- return koi8_e_A0_BF[koicode-0xA0];
- else
- return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
-}
-
-static FontMapRec koi8_e[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_e_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* Koi8 unified */
-
-static const unsigned short koi8_uni_80_BF[]=
-{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
- 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
- 0x2591, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
- 0x00A9, 0x2122, 0x00A0, 0x00BB, 0x00AE, 0x00AB, 0x00B7, 0x00A4,
- 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x0491, 0x045E, 0x045F,
- 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x0490, 0x040E, 0x040F };
-
-static unsigned
-koi8_uni_to_unicode(unsigned koicode, void *client_data)
-{
- if(koicode<0x80)
- return koicode;
- else if(koicode<0xC0)
- return koi8_uni_80_BF[koicode-0x80];
- else
- return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
-}
-
-static FontMapRec koi8_uni[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_uni_to_unicode,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* Ukrainian variant of Koi8-R; see RFC 2319 */
-
-static unsigned
-koi8_u_to_unicode(unsigned koicode, void *client_data)
-{
- switch(koicode) {
- case 0xA4: return 0x0454;
- case 0xA6: return 0x0456;
- case 0xA7: return 0x0457;
- case 0xAD: return 0x0491;
- case 0xB4: return 0x0404;
- case 0xB6: return 0x0406;
- case 0xB7: return 0x0407;
- case 0xBD: return 0x0490;
- default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
- }
-}
-
-static FontMapRec koi8_u[]=
-{
- {FONT_ENCODING_UNICODE,0,0,koi8_u_to_unicode,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}
-};
-
-/* Microsoft Symbol, which is only meaningful for TrueType fonts, is
- treated specially in ftenc.c, where we add usFirstCharIndex-0x20 to
- the glyph index before applying the cmap. Lovely design. */
-
-static FontMapRec microsoft_symbol[]=
-{{FONT_ENCODING_TRUETYPE,3,0,NULL,NULL,NULL,NULL,NULL},
- /* You never know */
- {FONT_ENCODING_TRUETYPE,3,1,NULL,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}};
-
-static FontMapRec apple_roman[]=
-{{FONT_ENCODING_TRUETYPE,1,0,NULL,NULL,NULL,NULL,NULL},
- {0,0,0,NULL,NULL,NULL,NULL,NULL}};
-
-/* The data for recodings */
-
-/* For compatibility with X11R6.4. Losers. */
-static char *iso8859_15_aliases[2]={"fcd8859-15",NULL};
-
-static FontEncRec initial_encodings[]=
-{
- {"iso10646-1",NULL,256*256,0,iso10646,NULL,0,0}, /* Unicode */
- {"iso8859-1",NULL,256,0,iso8859_1,NULL,0,0}, /* Latin 1 (West European) */
- {"iso8859-2",NULL,256,0,iso8859_2,NULL,0,0}, /* Latin 2 (East European) */
- {"iso8859-3",NULL,256,0,iso8859_3,NULL,0,0}, /* Latin 3 (South European) */
- {"iso8859-4",NULL,256,0,iso8859_4,NULL,0,0}, /* Latin 4 (North European) */
- {"iso8859-5",NULL,256,0,iso8859_5,NULL,0,0}, /* Cyrillic */
- {"iso8859-6",NULL,256,0,iso8859_6,NULL,0,0}, /* Arabic */
- {"iso8859-7",NULL,256,0,iso8859_7,NULL,0,0}, /* Greek */
- {"iso8859-8",NULL,256,0,iso8859_8,NULL,0,0}, /* Hebrew */
- {"iso8859-9",NULL,256,0,iso8859_9,NULL,0,0}, /* Latin 5 (Turkish) */
- {"iso8859-10",NULL,256,0,iso8859_10,NULL,0,0}, /* Latin 6 (Nordic) */
- {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,NULL,0,0}, /* Latin 9 */
- {"koi8-r",NULL,256,0,koi8_r,NULL,0,0}, /* Russian */
- {"koi8-ru",NULL,256,0,koi8_ru,NULL,0,0}, /* Ukrainian */
- {"koi8-uni",NULL,256,0,koi8_uni,NULL,0,0}, /* Russian/Ukrainian/Bielorussian */
- {"koi8-e",NULL,256,0,koi8_e,NULL,0,0}, /* ``European'' */
- {"koi8-u",NULL,256,0,koi8_u,NULL,0,0}, /* Ukrainian too */
- {"microsoft-symbol",NULL,256,0,microsoft_symbol,NULL,0,0},
- {"apple-roman",NULL,256,0,apple_roman,NULL,0,0},
- {NULL,NULL,0,0,NULL,NULL,0,0}
-};
-
-static FontEncPtr font_encodings=NULL;
-
-static void
-define_initial_encoding_info(void)
-{
- FontEncPtr encoding;
- FontMapPtr mapping;
-
- font_encodings = initial_encodings;
- for(encoding = font_encodings; ; encoding++) {
- encoding->next = encoding + 1;
- for(mapping = encoding->mappings; ; mapping++) {
- mapping->next = mapping+1;
- mapping->encoding = encoding;
- if(mapping->next->type == 0) {
- mapping->next = NULL;
- break;
- }
- }
- if(!encoding->next->name) {
- encoding->next = NULL;
- break;
- }
- }
-}
-
-
-char*
-FontEncFromXLFD(const char *name, int length)
-{
- const char *p;
- char *q;
- static char charset[MAXFONTNAMELEN];
- int len;
-
- if(length > MAXFONTNAMELEN - 1)
- return NULL;
-
- if(name == NULL)
- p = NULL;
- else {
- p = name + length - 1;
- while(p > name && *p != '-')
- p--;
- p--;
- while(p >= name && *p != '-')
- p--;
- if(p <= name)
- p = NULL;
- }
-
- /* now p either is null or points at the '-' before the charset registry */
-
- if(p == NULL)
- return NULL;
-
- len = length - (p - name) - 1;
- memcpy(charset, p+1, len);
- charset[len] = 0;
-
- /* check for a subset specification */
- if((q = strchr(charset, (int)'[')))
- *q = 0;
-
- return charset;
-}
-
-unsigned
-FontEncRecode(unsigned code, FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- if(encoding && mapping->recode) {
- if(encoding->row_size == 0) {
- /* linear encoding */
- if(code < encoding->first || code>=encoding->size)
- return 0;
- } else {
- /* matrix encoding */
- int row = code/0x100, col = code&0xFF;
- if(row < encoding->first || row >= encoding->size ||
- col < encoding->first_col || col >= encoding->row_size)
- return 0;
- }
- return (*mapping->recode)(code, mapping->client_data);
- } else
- return code;
-}
-
-char*
-FontEncName(unsigned code, FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- if(encoding && mapping->name) {
- if((encoding->row_size == 0 && code >= encoding->size) ||
- (encoding->row_size != 0 &&
- (code/0x100 >= encoding->size ||
- (code&0xFF) >= encoding->row_size)))
- return NULL;
- return (*mapping->name)(code, mapping->client_data);
- } else
- return NULL;
-}
-
-FontEncPtr
-FontEncFind(const char *encoding_name, const char *filename)
-{
- FontEncPtr encoding;
- char **alias;
-
- if(font_encodings == NULL) define_initial_encoding_info();
-
- for(encoding = font_encodings; encoding; encoding = encoding->next) {
- if(!strcasecmp(encoding->name, encoding_name))
- return encoding;
- if(encoding->aliases)
- for(alias=encoding->aliases; *alias; alias++)
- if(!strcasecmp(*alias, encoding_name))
- return encoding;
- }
-
- /* Unknown charset, try to load a definition file */
- return FontEncLoad(encoding_name, filename);
-}
-
-FontMapPtr
-FontMapFind(FontEncPtr encoding, int type, int pid, int eid)
-{
- FontMapPtr mapping;
- if(encoding == NULL)
- return NULL;
-
- for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
- if(mapping->type != type)
- continue;
- if(pid > 0 && mapping->pid != pid)
- continue;
- if(eid > 0 && mapping->eid != eid)
- continue;
- return mapping;
- }
- return NULL;
-}
-
-FontMapPtr
-FontEncMapFind(const char *encoding_name, int type, int pid, int eid,
- const char *filename)
-{
- FontEncPtr encoding;
- FontMapPtr mapping;
-
- encoding = FontEncFind(encoding_name, filename);
- if(encoding == NULL)
- return NULL;
- mapping = FontMapFind(encoding, type, pid, eid);
- return mapping;
-}
-
-static FontEncPtr
-FontEncLoad(const char *encoding_name, const char *filename)
-{
- FontEncPtr encoding;
-
- encoding = FontEncReallyLoad(encoding_name, filename);
- if (encoding == NULL) {
- return NULL;
- } else {
- char **alias;
- int found = 0;
-
- /* Check whether the name is already known for this encoding */
- if(strcasecmp(encoding->name, encoding_name) == 0) {
- found = 1;
- } else {
- if(encoding->aliases) {
- for(alias=encoding->aliases; *alias; alias++)
- if(!strcasecmp(*alias, encoding_name)) {
- found = 1;
- break;
- }
- }
- }
-
- if(!found) {
- /* Add a new alias. This works because we know that this
- particular encoding has been allocated dynamically */
- char **new_aliases;
- char *new_name;
- int numaliases = 0;
-
- new_name = xalloc(strlen(encoding_name) + 1);
- if(new_name == NULL)
- return NULL;
- strcpy(new_name, encoding_name);
- if(encoding->aliases) {
- for(alias = encoding->aliases; *alias; alias++)
- numaliases++;
- }
- new_aliases = (char**)xalloc((numaliases+2)*sizeof(char*));
- if(new_aliases == NULL) {
- xfree(new_name);
- return NULL;
- }
- if(encoding->aliases) {
- memcpy(new_aliases, encoding->aliases, numaliases*sizeof(char*));
- xfree(encoding->aliases);
- }
- new_aliases[numaliases] = new_name;
- new_aliases[numaliases+1] = NULL;
- encoding->aliases = new_aliases;
- }
-
- /* register the new encoding */
- encoding->next=font_encodings;
- font_encodings=encoding;
-
- return encoding;
- }
-}
-
-unsigned
-FontEncSimpleRecode(unsigned code, void *client_data)
-{
- FontEncSimpleMapPtr map;
- unsigned index;
-
- map = client_data;
-
- if(code > 0xFFFF || (map->row_size && (code&0xFF) >= map->row_size))
- return 0;
-
- if(map->row_size)
- index = (code&0xFF)+(code>>8)*map->row_size;
- else
- index = code;
-
- if(map->map && index>=map->first && index<map->first+map->len)
- return map->map[index-map->first];
- else
- return code;
-}
-
-char *
-FontEncSimpleName(unsigned code, void *client_data)
-{
- FontEncSimpleNamePtr map;
-
- map = client_data;
- if(map && code >= map->first && code<map->first+map->len)
- return map->map[code-map->first];
- else
- return NULL;
-}
-
-unsigned
-FontEncUndefinedRecode(unsigned code, void *client_data)
-{
- return code;
-}
-
-char *
-FontEncUndefinedName(unsigned code, void *client_data)
-{
- return NULL;
-}
-
-#define FONTENC_SEGMENT_SIZE 256
-#define FONTENC_SEGMENTS 256
-#define FONTENC_INVERSE_CODES (FONTENC_SEGMENT_SIZE * FONTENC_SEGMENTS)
-
-static unsigned int
-reverse_reverse(unsigned i, void* data)
-{
- int s, j;
- unsigned **map = (unsigned**)data;
-
- if(i >= FONTENC_INVERSE_CODES)
- return 0;
-
- if(map == NULL)
- return 0;
-
- s = i / FONTENC_SEGMENT_SIZE;
- j = i % FONTENC_SEGMENT_SIZE;
-
- if(map[s] == NULL)
- return 0;
- else
- return map[s][j];
-}
-
-static int
-tree_set(unsigned int **map, unsigned int i, unsigned int j)
-{
- int s, c;
-
- if(i >= FONTENC_INVERSE_CODES)
- return FALSE;
-
- s = i / FONTENC_SEGMENT_SIZE;
- c = i % FONTENC_SEGMENT_SIZE;
-
- if(map[s] == NULL) {
- map[s] = calloc(FONTENC_SEGMENT_SIZE, sizeof(int));
- if(map[s] == NULL)
- return FALSE;
- }
-
- map[s][c] = j;
- return TRUE;
-}
-
-FontMapReversePtr
-FontMapReverse(FontMapPtr mapping)
-{
- FontEncPtr encoding = mapping->encoding;
- FontMapReversePtr reverse = NULL;
- unsigned int **map = NULL;
- int i, j, k;
-
- if(encoding == NULL) goto bail;
-
- map = calloc(FONTENC_SEGMENTS, sizeof(int*));
- if(map == NULL) goto bail;
-
- if(encoding->row_size == 0) {
- for(i = encoding->first; i < encoding->size; i++) {
- k = FontEncRecode(i, mapping);
- if(k != 0)
- if(!tree_set(map, k, i))
- goto bail;
- }
- } else {
- for(i = encoding->first; i < encoding->size; i++) {
- for(j = encoding->first_col; j < encoding->row_size; j++) {
- k = FontEncRecode(i*256 + j, mapping);
- if(k != 0)
- if(!tree_set(map, k, i*256+j))
- goto bail;
- }
- }
- }
-
- reverse = malloc(sizeof(FontMapReverseRec));
- if(!reverse) goto bail;
-
- reverse->reverse = reverse_reverse;
- reverse->data = map;
- return reverse;
-
- bail:
- if(map)
- xfree(map);
- if(reverse)
- xfree(reverse);
- return NULL;
-}
-
-void
-FontMapReverseFree(FontMapReversePtr delendum)
-{
- unsigned int **map = (unsigned int**)delendum;
- int i;
-
- if(map == NULL)
- return;
-
- for(i = 0; i < FONTENC_SEGMENTS; i++)
- if(map[i] != NULL)
- xfree(map[i]);
-
- xfree(map);
- return;
-}
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* Backend-independent encoding code */
+
+#include <string.h>
+
+#if defined(__SCO__) || defined(__UNIXWARE__)
+#include <strings.h>
+#endif
+
+#include <stdlib.h>
+
+#define FALSE 0
+#define TRUE 1
+#define MAXFONTNAMELEN 1024
+#define MAXFONTFILENAMELEN 1024
+
+#include <X11/fonts/fontenc.h>
+#include "fontencI.h"
+#ifdef _MSC_VER
+#define strdup _strdup
+#endif
+
+/* Functions local to this file */
+
+static FontEncPtr FontEncLoad(const char*, const char*);
+
+/* Early versions of this code only knew about hardwired encodings,
+ hence the following data. Now that the code knows how to load an
+ encoding from a file, most of these tables could go away. */
+
+/* At any rate, no new hardcoded encodings will be added. */
+
+static FontMapRec iso10646[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,NULL,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* Notice that the Apple encodings do not have all the characters in
+ the corresponding ISO 8859, and therefore the table has some holes.
+ There's not much more we can do with fonts without a Unicode cmap
+ unless we are willing to combine cmaps (which we are not). */
+
+static const unsigned short
+iso8859_1_apple_roman[]=
+{ 0xCA, 0xC1, 0xA2, 0xA3, 0xDB, 0xB4, 0x00, 0xA4,
+ 0xAC, 0xA9, 0xBB, 0xC7, 0xC2, 0x00, 0xA8, 0xF8,
+ 0xA1, 0xB1, 0x00, 0x00, 0xAB, 0xB5, 0xA6, 0xE1,
+ 0xFC, 0x00, 0xBC, 0xC8, 0x00, 0x00, 0x00, 0xC0,
+ 0xCB, 0xE7, 0xE5, 0xCC, 0x80, 0x81, 0xAE, 0x82,
+ 0xE9, 0x83, 0xE6, 0xE8, 0xED, 0xEA, 0xEB, 0xEC,
+ 0x00, 0x84, 0xF1, 0xEE, 0xEF, 0xCD, 0x85, 0x00,
+ 0xAF, 0xF4, 0xF2, 0xF3, 0x86, 0x00, 0x00, 0xA7,
+ 0x88, 0x87, 0x89, 0x8B, 0x8A, 0x8C, 0xBE, 0x8D,
+ 0x8F, 0x8E, 0x90, 0x91, 0x93, 0x92, 0x94, 0x95,
+ 0x00, 0x96, 0x98, 0x97, 0x99, 0x9B, 0x9A, 0xD6,
+ 0xBF, 0x9D, 0x9C, 0x9E, 0x9F, 0x00, 0x00, 0xD8 };
+
+/* Cannot use simple_recode because need to eliminate 0x80<=code<0xA0 */
+static unsigned
+iso8859_1_to_apple_roman(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_1_apple_roman[isocode-0xA0];
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_1[]=
+{
+ {FONT_ENCODING_TRUETYPE,2,2,NULL,NULL,NULL,NULL,NULL}, /* ISO 8859-1 */
+ {FONT_ENCODING_UNICODE,0,0,NULL,NULL,NULL,NULL,NULL}, /* ISO 8859-1 coincides with Unicode*/
+ {FONT_ENCODING_TRUETYPE,1,0,iso8859_1_to_apple_roman,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static const unsigned short iso8859_2_tophalf[]=
+{ 0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
+ 0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
+ 0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
+ 0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
+ 0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
+ 0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
+ 0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
+ 0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
+ 0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
+ 0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9 };
+
+static FontEncSimpleMapRec iso8859_2_to_unicode_map=
+{0x60, 0, 0xA0, iso8859_2_tophalf };
+
+static const unsigned short iso8859_2_apple_centeuro[]=
+{ 0xCA, 0x84, 0x00, 0xFC, 0x00, 0xBB, 0xE5, 0xA4,
+ 0xAC, 0xE1, 0x00, 0xE8, 0x8F, 0x00, 0xEB, 0xFB,
+ 0xA1, 0x88, 0x00, 0xB8, 0x00, 0xBC, 0xE6, 0xFF,
+ 0x00, 0xE4, 0x00, 0xE9, 0x90, 0x00, 0xEC, 0xFD,
+ 0xD9, 0xE7, 0x00, 0x00, 0x80, 0xBD, 0x8C, 0x00,
+ 0x89, 0x83, 0xA2, 0x00, 0x9D, 0xEA, 0x00, 0x91,
+ 0x00, 0xC1, 0xC5, 0xEE, 0xEF, 0xCC, 0x85, 0x00,
+ 0xDB, 0xF1, 0xF2, 0xF4, 0x86, 0xF8, 0x00, 0xA7,
+ 0xDA, 0x87, 0x00, 0x00, 0x8A, 0xBE, 0x8D, 0x00,
+ 0x8B, 0x8E, 0xAB, 0x00, 0x9E, 0x92, 0x00, 0x93,
+ 0x00, 0xC4, 0xCB, 0x97, 0x99, 0xCE, 0x9A, 0xD6,
+ 0xDE, 0xF3, 0x9C, 0xF5, 0x9F, 0xF9, 0x00, 0x00 };
+
+static unsigned
+iso8859_2_to_apple_centeuro(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_2_apple_centeuro[isocode-0xA0];
+ else
+ return 0;
+}
+
+
+static FontMapRec iso8859_2[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,
+ FontEncSimpleRecode,NULL,&iso8859_2_to_unicode_map,NULL,NULL},
+ {FONT_ENCODING_TRUETYPE,1,29,iso8859_2_to_apple_centeuro,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static const unsigned short iso8859_3_tophalf[]=
+{ 0x00A0, 0x0126, 0x02D8, 0x00A3, 0x00A4, 0x0000, 0x0124, 0x00A7,
+ 0x00A8, 0x0130, 0x015E, 0x011E, 0x0134, 0x00AD, 0x0000, 0x017B,
+ 0x00B0, 0x0127, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x0125, 0x00B7,
+ 0x00B8, 0x0131, 0x015F, 0x011F, 0x0135, 0x00BD, 0x0000, 0x017C,
+ 0x00C0, 0x00C1, 0x00C2, 0x0000, 0x00C4, 0x010A, 0x0108, 0x00C7,
+ 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
+ 0x0000, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x0120, 0x00D6, 0x00D7,
+ 0x011C, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x016C, 0x015C, 0x00DF,
+ 0x00E0, 0x00E1, 0x00E2, 0x0000, 0x00E4, 0x010B, 0x0109, 0x00E7,
+ 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
+ 0x0000, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x0121, 0x00F6, 0x00F7,
+ 0x011D, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x016D, 0x015D, 0x02D9};
+
+static FontEncSimpleMapRec iso8859_3_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_3_tophalf };
+
+static FontMapRec iso8859_3[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,
+ FontEncSimpleRecode,NULL,&iso8859_3_to_unicode_map,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+
+static const unsigned short iso8859_4_tophalf[]=
+{ 0x00A0, 0x0104, 0x0138, 0x0156, 0x00A4, 0x0128, 0x013B, 0x00A7,
+ 0x00A8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00AD, 0x017D, 0x00AF,
+ 0x00B0, 0x0105, 0x02DB, 0x0157, 0x00B4, 0x0129, 0x013C, 0x02C7,
+ 0x00B8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014A, 0x017E, 0x014B,
+ 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x012A,
+ 0x0110, 0x0145, 0x014C, 0x0136, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
+ 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x0168, 0x016A, 0x00DF,
+ 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x012B,
+ 0x0111, 0x0146, 0x014D, 0x0137, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
+ 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x0169, 0x016B, 0x02D9,
+};
+
+static FontEncSimpleMapRec iso8859_4_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_4_tophalf };
+
+static FontMapRec iso8859_4[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
+ &iso8859_4_to_unicode_map,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static const unsigned short iso8859_5_tophalf[]=
+{ 0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F};
+
+static FontEncSimpleMapRec iso8859_5_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_5_tophalf };
+
+static const unsigned short
+iso8859_5_apple_cyrillic[]=
+{ 0xCA, 0xDD, 0xAB, 0xAE, 0xB8, 0xC1, 0xA7, 0xBA,
+ 0xB7, 0xBC, 0xBE, 0xCB, 0xCD, 0x00, 0xD8, 0xDA,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+ 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+ 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
+ 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7,
+ 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF,
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+ 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xDF,
+ 0xDC, 0xDE, 0xAC, 0xAF, 0xB9, 0xCF, 0xB4, 0xBB,
+ 0xC0, 0xBD, 0xBF, 0xCC, 0xCE, 0xA4, 0xD9, 0xDB };
+
+static unsigned
+iso8859_5_to_apple_cyrillic(unsigned isocode, void *client_data)
+{
+ if(isocode<=0x80)
+ return isocode;
+ else if(isocode>=0xA0)
+ return iso8859_5_apple_cyrillic[isocode-0x80];
+ else return 0;
+}
+
+static FontMapRec iso8859_5[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
+ &iso8859_5_to_unicode_map,NULL,NULL},
+ {FONT_ENCODING_TRUETYPE,1,7,iso8859_5_to_apple_cyrillic,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* ISO 8859-6 seems useless for serving fonts (not enough presentation
+ * forms). What do Arabic-speakers use? */
+
+static unsigned
+iso8859_6_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode<=0xA0 || isocode==0xA4 || isocode==0xAD)
+ return isocode;
+ else if(isocode==0xAC || isocode==0xBB ||
+ (isocode>=0xBF && isocode<=0xDA) ||
+ (isocode>=0xE0 && isocode<=0xEF) ||
+ (isocode>=0xF0 && isocode<=0xF2))
+ return isocode-0xA0+0x0600;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_6[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_6_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static unsigned
+iso8859_7_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode<=0xA0 ||
+ (isocode>=0xA3 && isocode<=0xAD) ||
+ (isocode>=0xB0 && isocode<=0xB3) ||
+ isocode==0xB7 || isocode==0xBB || isocode==0xBD)
+ return isocode;
+ else if(isocode==0xA1)
+ return 0x02BD;
+ else if(isocode==0xA2)
+ return 0x02BC;
+ else if(isocode==0xAF)
+ return 0x2015;
+ else if(isocode>=0xB4)
+ return isocode-0xA0+0x0370;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_7[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_7_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static unsigned
+iso8859_8_to_unicode(unsigned isocode, void *client_data)
+{
+ if(isocode==0xA1)
+ return 0;
+ else if(isocode<0xBF)
+ return isocode;
+ else if(isocode==0xDF)
+ return 0x2017;
+ else if(isocode>=0xE0 && isocode<=0xFA)
+ return isocode+0x04F0;
+ else
+ return 0;
+}
+
+static FontMapRec iso8859_8[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_8_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static unsigned
+iso8859_9_to_unicode(unsigned isocode, void *client_data)
+{
+ switch(isocode) {
+ case 0xD0: return 0x011E;
+ case 0xDD: return 0x0130;
+ case 0xDE: return 0x015E;
+ case 0xF0: return 0x011F;
+ case 0xFD: return 0x0131;
+ case 0xFE: return 0x015F;
+ default: return isocode;
+ }
+}
+
+static FontMapRec iso8859_9[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_9_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static const unsigned short iso8859_10_tophalf[]=
+{ 0x00A0, 0x0104, 0x0112, 0x0122, 0x012A, 0x0128, 0x0136, 0x00A7,
+ 0x013B, 0x0110, 0x0160, 0x0166, 0x017D, 0x00AD, 0x016A, 0x014A,
+ 0x00B0, 0x0105, 0x0113, 0x0123, 0x012B, 0x0129, 0x0137, 0x00B7,
+ 0x013C, 0x0111, 0x0161, 0x0167, 0x017E, 0x2014, 0x016B, 0x014B,
+ 0x0100, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x012E,
+ 0x010C, 0x00C9, 0x0118, 0x00CB, 0x0116, 0x00CD, 0x00CE, 0x00CF,
+ 0x00D0, 0x0145, 0x014C, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x0168,
+ 0x00D8, 0x0172, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
+ 0x0101, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x012F,
+ 0x010D, 0x00E9, 0x0119, 0x00EB, 0x0117, 0x00ED, 0x00EE, 0x00EF,
+ 0x00F0, 0x0146, 0x014D, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x0169,
+ 0x00F8, 0x0173, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x0138};
+
+static FontEncSimpleMapRec iso8859_10_to_unicode_map=
+{ 0x60, 0, 0xA0, iso8859_10_tophalf };
+
+static FontMapRec iso8859_10[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
+ &iso8859_10_to_unicode_map,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static unsigned
+iso8859_15_to_unicode(unsigned isocode, void *client_data)
+{
+ switch(isocode) {
+ case 0xA4: return 0x20AC;
+ case 0xA6: return 0x0160;
+ case 0xA8: return 0x0161;
+ case 0xB4: return 0x017D;
+ case 0xB8: return 0x017E;
+ case 0xBC: return 0x0152;
+ case 0xBD: return 0x0153;
+ case 0xBE: return 0x0178;
+ default: return isocode;
+ }
+}
+
+static FontMapRec iso8859_15[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,iso8859_15_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static const unsigned short koi8_r_tophalf[]=
+{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
+ 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25A0, 0x2022, 0x221A, 0x2248,
+ 0x2264, 0x2265, 0x00A0, 0x2321, 0x00B0, 0x00B2, 0x00B7, 0x00F7,
+ 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255A, 0x255B, 0x255C, 0x255D, 0x255E,
+ 0x255F, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256A, 0x256B, 0x256C, 0x00A9,
+ 0x044E, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433,
+ 0x0445, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E,
+ 0x043F, 0x044F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432,
+ 0x044C, 0x044B, 0x0437, 0x0448, 0x044D, 0x0449, 0x0447, 0x044A,
+ 0x042E, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413,
+ 0x0425, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E,
+ 0x041F, 0x042F, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412,
+ 0x042C, 0x042B, 0x0417, 0x0428, 0x042D, 0x0429, 0x0427, 0x042A};
+
+static FontEncSimpleMapRec koi8_r_to_unicode_map=
+{ 0x80, 0, 0x80, koi8_r_tophalf };
+
+
+static FontMapRec koi8_r[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,FontEncSimpleRecode,NULL,
+ &koi8_r_to_unicode_map,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+static unsigned
+koi8_ru_to_unicode(unsigned koicode, void *client_data)
+{
+ switch(koicode) {
+ case 0x93: return 0x201C;
+ case 0x96: return 0x201D;
+ case 0x97: return 0x2014;
+ case 0x98: return 0x2116;
+ case 0x99: return 0x2122;
+ case 0x9B: return 0x00BB;
+ case 0x9C: return 0x00AE;
+ case 0x9D: return 0x00AB;
+ case 0x9F: return 0x00A4;
+ case 0xA4: return 0x0454;
+ case 0xA6: return 0x0456;
+ case 0xA7: return 0x0457;
+ case 0xAD: return 0x0491;
+ case 0xAE: return 0x045E;
+ case 0xB4: return 0x0404;
+ case 0xB6: return 0x0406;
+ case 0xB7: return 0x0407;
+ case 0xBD: return 0x0490;
+ case 0xBE: return 0x040E;
+ default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+ }
+}
+
+static FontMapRec koi8_ru[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_ru_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* koi8-e, ISO-IR-111 or ECMA-Cyrillic */
+
+static const unsigned short koi8_e_A0_BF[]=
+{ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00AD, 0x045E, 0x045F,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00A4, 0x040E, 0x040F };
+
+static unsigned
+koi8_e_to_unicode(unsigned koicode, void *client_data)
+{
+ if(koicode<0xA0)
+ return koicode;
+ else if(koicode<0xC0)
+ return koi8_e_A0_BF[koicode-0xA0];
+ else
+ return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+}
+
+static FontMapRec koi8_e[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_e_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* Koi8 unified */
+
+static const unsigned short koi8_uni_80_BF[]=
+{ 0x2500, 0x2502, 0x250C, 0x2510, 0x2514, 0x2518, 0x251C, 0x2524,
+ 0x252C, 0x2534, 0x253C, 0x2580, 0x2584, 0x2588, 0x258C, 0x2590,
+ 0x2591, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
+ 0x00A9, 0x2122, 0x00A0, 0x00BB, 0x00AE, 0x00AB, 0x00B7, 0x00A4,
+ 0x00A0, 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x0491, 0x045E, 0x045F,
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x0490, 0x040E, 0x040F };
+
+static unsigned
+koi8_uni_to_unicode(unsigned koicode, void *client_data)
+{
+ if(koicode<0x80)
+ return koicode;
+ else if(koicode<0xC0)
+ return koi8_uni_80_BF[koicode-0x80];
+ else
+ return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+}
+
+static FontMapRec koi8_uni[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_uni_to_unicode,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* Ukrainian variant of Koi8-R; see RFC 2319 */
+
+static unsigned
+koi8_u_to_unicode(unsigned koicode, void *client_data)
+{
+ switch(koicode) {
+ case 0xA4: return 0x0454;
+ case 0xA6: return 0x0456;
+ case 0xA7: return 0x0457;
+ case 0xAD: return 0x0491;
+ case 0xB4: return 0x0404;
+ case 0xB6: return 0x0406;
+ case 0xB7: return 0x0407;
+ case 0xBD: return 0x0490;
+ default: return FontEncSimpleRecode(koicode, &koi8_r_to_unicode_map);
+ }
+}
+
+static FontMapRec koi8_u[]=
+{
+ {FONT_ENCODING_UNICODE,0,0,koi8_u_to_unicode,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}
+};
+
+/* Microsoft Symbol, which is only meaningful for TrueType fonts, is
+ treated specially in ftenc.c, where we add usFirstCharIndex-0x20 to
+ the glyph index before applying the cmap. Lovely design. */
+
+static FontMapRec microsoft_symbol[]=
+{{FONT_ENCODING_TRUETYPE,3,0,NULL,NULL,NULL,NULL,NULL},
+ /* You never know */
+ {FONT_ENCODING_TRUETYPE,3,1,NULL,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}};
+
+static FontMapRec apple_roman[]=
+{{FONT_ENCODING_TRUETYPE,1,0,NULL,NULL,NULL,NULL,NULL},
+ {0,0,0,NULL,NULL,NULL,NULL,NULL}};
+
+/* The data for recodings */
+
+/* For compatibility with X11R6.4. Losers. */
+static char *iso8859_15_aliases[2]={"fcd8859-15",NULL};
+
+static FontEncRec initial_encodings[]=
+{
+ {"iso10646-1",NULL,256*256,0,iso10646,NULL,0,0}, /* Unicode */
+ {"iso8859-1",NULL,256,0,iso8859_1,NULL,0,0}, /* Latin 1 (West European) */
+ {"iso8859-2",NULL,256,0,iso8859_2,NULL,0,0}, /* Latin 2 (East European) */
+ {"iso8859-3",NULL,256,0,iso8859_3,NULL,0,0}, /* Latin 3 (South European) */
+ {"iso8859-4",NULL,256,0,iso8859_4,NULL,0,0}, /* Latin 4 (North European) */
+ {"iso8859-5",NULL,256,0,iso8859_5,NULL,0,0}, /* Cyrillic */
+ {"iso8859-6",NULL,256,0,iso8859_6,NULL,0,0}, /* Arabic */
+ {"iso8859-7",NULL,256,0,iso8859_7,NULL,0,0}, /* Greek */
+ {"iso8859-8",NULL,256,0,iso8859_8,NULL,0,0}, /* Hebrew */
+ {"iso8859-9",NULL,256,0,iso8859_9,NULL,0,0}, /* Latin 5 (Turkish) */
+ {"iso8859-10",NULL,256,0,iso8859_10,NULL,0,0}, /* Latin 6 (Nordic) */
+ {"iso8859-15",iso8859_15_aliases,256,0,iso8859_15,NULL,0,0}, /* Latin 9 */
+ {"koi8-r",NULL,256,0,koi8_r,NULL,0,0}, /* Russian */
+ {"koi8-ru",NULL,256,0,koi8_ru,NULL,0,0}, /* Ukrainian */
+ {"koi8-uni",NULL,256,0,koi8_uni,NULL,0,0}, /* Russian/Ukrainian/Bielorussian */
+ {"koi8-e",NULL,256,0,koi8_e,NULL,0,0}, /* ``European'' */
+ {"koi8-u",NULL,256,0,koi8_u,NULL,0,0}, /* Ukrainian too */
+ {"microsoft-symbol",NULL,256,0,microsoft_symbol,NULL,0,0},
+ {"apple-roman",NULL,256,0,apple_roman,NULL,0,0},
+ {NULL,NULL,0,0,NULL,NULL,0,0}
+};
+
+static FontEncPtr font_encodings=NULL;
+
+static void
+define_initial_encoding_info(void)
+{
+ FontEncPtr encoding;
+ FontMapPtr mapping;
+
+ font_encodings = initial_encodings;
+ for(encoding = font_encodings; ; encoding++) {
+ encoding->next = encoding + 1;
+ for(mapping = encoding->mappings; ; mapping++) {
+ mapping->next = mapping+1;
+ mapping->encoding = encoding;
+ if(mapping->next->type == 0) {
+ mapping->next = NULL;
+ break;
+ }
+ }
+ if(!encoding->next->name) {
+ encoding->next = NULL;
+ break;
+ }
+ }
+}
+
+
+char*
+FontEncFromXLFD(const char *name, int length)
+{
+ const char *p;
+ char *q;
+ static char charset[MAXFONTNAMELEN];
+ int len;
+
+ if(length > MAXFONTNAMELEN - 1)
+ return NULL;
+
+ if(name == NULL)
+ p = NULL;
+ else {
+ p = name + length - 1;
+ while(p > name && *p != '-')
+ p--;
+ p--;
+ while(p >= name && *p != '-')
+ p--;
+ if(p <= name)
+ p = NULL;
+ }
+
+ /* now p either is null or points at the '-' before the charset registry */
+
+ if(p == NULL)
+ return NULL;
+
+ len = length - (p - name) - 1;
+ memcpy(charset, p+1, len);
+ charset[len] = 0;
+
+ /* check for a subset specification */
+ if((q = strchr(charset, (int)'[')))
+ *q = 0;
+
+ return charset;
+}
+
+unsigned
+FontEncRecode(unsigned code, FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ if(encoding && mapping->recode) {
+ if(encoding->row_size == 0) {
+ /* linear encoding */
+ if(code < encoding->first || code>=encoding->size)
+ return 0;
+ } else {
+ /* matrix encoding */
+ int row = code/0x100, col = code&0xFF;
+ if(row < encoding->first || row >= encoding->size ||
+ col < encoding->first_col || col >= encoding->row_size)
+ return 0;
+ }
+ return (*mapping->recode)(code, mapping->client_data);
+ } else
+ return code;
+}
+
+char*
+FontEncName(unsigned code, FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ if(encoding && mapping->name) {
+ if((encoding->row_size == 0 && code >= encoding->size) ||
+ (encoding->row_size != 0 &&
+ (code/0x100 >= encoding->size ||
+ (code&0xFF) >= encoding->row_size)))
+ return NULL;
+ return (*mapping->name)(code, mapping->client_data);
+ } else
+ return NULL;
+}
+
+FontEncPtr
+FontEncFind(const char *encoding_name, const char *filename)
+{
+ FontEncPtr encoding;
+ char **alias;
+
+ if(font_encodings == NULL) define_initial_encoding_info();
+
+ for(encoding = font_encodings; encoding; encoding = encoding->next) {
+ if(!strcasecmp(encoding->name, encoding_name))
+ return encoding;
+ if(encoding->aliases)
+ for(alias=encoding->aliases; *alias; alias++)
+ if(!strcasecmp(*alias, encoding_name))
+ return encoding;
+ }
+
+ /* Unknown charset, try to load a definition file */
+ return FontEncLoad(encoding_name, filename);
+}
+
+FontMapPtr
+FontMapFind(FontEncPtr encoding, int type, int pid, int eid)
+{
+ FontMapPtr mapping;
+ if(encoding == NULL)
+ return NULL;
+
+ for(mapping = encoding->mappings; mapping; mapping = mapping->next) {
+ if(mapping->type != type)
+ continue;
+ if(pid > 0 && mapping->pid != pid)
+ continue;
+ if(eid > 0 && mapping->eid != eid)
+ continue;
+ return mapping;
+ }
+ return NULL;
+}
+
+FontMapPtr
+FontEncMapFind(const char *encoding_name, int type, int pid, int eid,
+ const char *filename)
+{
+ FontEncPtr encoding;
+ FontMapPtr mapping;
+
+ encoding = FontEncFind(encoding_name, filename);
+ if(encoding == NULL)
+ return NULL;
+ mapping = FontMapFind(encoding, type, pid, eid);
+ return mapping;
+}
+
+static FontEncPtr
+FontEncLoad(const char *encoding_name, const char *filename)
+{
+ FontEncPtr encoding;
+
+ encoding = FontEncReallyLoad(encoding_name, filename);
+ if (encoding == NULL) {
+ return NULL;
+ } else {
+ char **alias;
+ int found = 0;
+
+ /* Check whether the name is already known for this encoding */
+ if(strcasecmp(encoding->name, encoding_name) == 0) {
+ found = 1;
+ } else {
+ if(encoding->aliases) {
+ for(alias=encoding->aliases; *alias; alias++)
+ if(!strcasecmp(*alias, encoding_name)) {
+ found = 1;
+ break;
+ }
+ }
+ }
+
+ if(!found) {
+ /* Add a new alias. This works because we know that this
+ particular encoding has been allocated dynamically */
+ char **new_aliases;
+ char *new_name;
+ int numaliases = 0;
+
+ new_name = strdup(encoding_name);
+ if(new_name == NULL)
+ return NULL;
+ if(encoding->aliases) {
+ for(alias = encoding->aliases; *alias; alias++)
+ numaliases++;
+ }
+ new_aliases = malloc((numaliases+2)*sizeof(char*));
+ if(new_aliases == NULL) {
+ free(new_name);
+ return NULL;
+ }
+ if(encoding->aliases) {
+ memcpy(new_aliases, encoding->aliases, numaliases*sizeof(char*));
+ free(encoding->aliases);
+ }
+ new_aliases[numaliases] = new_name;
+ new_aliases[numaliases+1] = NULL;
+ encoding->aliases = new_aliases;
+ }
+
+ /* register the new encoding */
+ encoding->next=font_encodings;
+ font_encodings=encoding;
+
+ return encoding;
+ }
+}
+
+unsigned
+FontEncSimpleRecode(unsigned code, void *client_data)
+{
+ FontEncSimpleMapPtr map;
+ unsigned index;
+
+ map = client_data;
+
+ if(code > 0xFFFF || (map->row_size && (code&0xFF) >= map->row_size))
+ return 0;
+
+ if(map->row_size)
+ index = (code&0xFF)+(code>>8)*map->row_size;
+ else
+ index = code;
+
+ if(map->map && index>=map->first && index<map->first+map->len)
+ return map->map[index-map->first];
+ else
+ return code;
+}
+
+char *
+FontEncSimpleName(unsigned code, void *client_data)
+{
+ FontEncSimpleNamePtr map;
+
+ map = client_data;
+ if(map && code >= map->first && code<map->first+map->len)
+ return map->map[code-map->first];
+ else
+ return NULL;
+}
+
+unsigned
+FontEncUndefinedRecode(unsigned code, void *client_data)
+{
+ return code;
+}
+
+char *
+FontEncUndefinedName(unsigned code, void *client_data)
+{
+ return NULL;
+}
+
+#define FONTENC_SEGMENT_SIZE 256
+#define FONTENC_SEGMENTS 256
+#define FONTENC_INVERSE_CODES (FONTENC_SEGMENT_SIZE * FONTENC_SEGMENTS)
+
+static unsigned int
+reverse_reverse(unsigned i, void* data)
+{
+ int s, j;
+ unsigned **map = (unsigned**)data;
+
+ if(i >= FONTENC_INVERSE_CODES)
+ return 0;
+
+ if(map == NULL)
+ return 0;
+
+ s = i / FONTENC_SEGMENT_SIZE;
+ j = i % FONTENC_SEGMENT_SIZE;
+
+ if(map[s] == NULL)
+ return 0;
+ else
+ return map[s][j];
+}
+
+static int
+tree_set(unsigned int **map, unsigned int i, unsigned int j)
+{
+ int s, c;
+
+ if(i >= FONTENC_INVERSE_CODES)
+ return FALSE;
+
+ s = i / FONTENC_SEGMENT_SIZE;
+ c = i % FONTENC_SEGMENT_SIZE;
+
+ if(map[s] == NULL) {
+ map[s] = calloc(FONTENC_SEGMENT_SIZE, sizeof(int));
+ if(map[s] == NULL)
+ return FALSE;
+ }
+
+ map[s][c] = j;
+ return TRUE;
+}
+
+FontMapReversePtr
+FontMapReverse(FontMapPtr mapping)
+{
+ FontEncPtr encoding = mapping->encoding;
+ FontMapReversePtr reverse = NULL;
+ unsigned int **map = NULL;
+ int i, j, k;
+
+ if(encoding == NULL) goto bail;
+
+ map = calloc(FONTENC_SEGMENTS, sizeof(int*));
+ if(map == NULL) goto bail;
+
+ if(encoding->row_size == 0) {
+ for(i = encoding->first; i < encoding->size; i++) {
+ k = FontEncRecode(i, mapping);
+ if(k != 0)
+ if(!tree_set(map, k, i))
+ goto bail;
+ }
+ } else {
+ for(i = encoding->first; i < encoding->size; i++) {
+ for(j = encoding->first_col; j < encoding->row_size; j++) {
+ k = FontEncRecode(i*256 + j, mapping);
+ if(k != 0)
+ if(!tree_set(map, k, i*256+j))
+ goto bail;
+ }
+ }
+ }
+
+ reverse = malloc(sizeof(FontMapReverseRec));
+ if(!reverse) goto bail;
+
+ reverse->reverse = reverse_reverse;
+ reverse->data = map;
+ return reverse;
+
+ bail:
+ free(map);
+ free(reverse);
+ return NULL;
+}
+
+void
+FontMapReverseFree(FontMapReversePtr delendum)
+{
+ unsigned int **map = (unsigned int**)delendum;
+ int i;
+
+ if(map == NULL)
+ return;
+
+ for(i = 0; i < FONTENC_SEGMENTS; i++)
+ free(map[i]);
+
+ free(map);
+ return;
+}
diff --git a/libfontenc/src/fontencI.h b/libfontenc/src/fontencI.h
index 741193a3b..558607cb8 100644
--- a/libfontenc/src/fontencI.h
+++ b/libfontenc/src/fontencI.h
@@ -1,46 +1,44 @@
-/*
-Copyright (c) 1998-2001 by Juliusz Chroboczek
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-/* $XFree86: xc/lib/font/fontfile/fontencI.h,v 1.3 1999/04/25 10:01:43 dawes Exp $ */
-
-/* Private types and functions for the encoding code. */
-/* Used by the files `fontenc.h' and `encparse.h' */
-
-typedef struct _FontEncSimpleMap {
- unsigned len; /* might be 0x10000 */
- unsigned short row_size;
- unsigned short first;
- const unsigned short *map;
-} FontEncSimpleMapRec, *FontEncSimpleMapPtr;
-
-typedef struct _FontEncSimpleName {
- unsigned len;
- unsigned short first;
- char **map;
-} FontEncSimpleNameRec, *FontEncSimpleNamePtr;
-
-unsigned FontEncSimpleRecode(unsigned, void*);
-unsigned FontEncUndefinedRecode(unsigned, void*);
-char *FontEncSimpleName(unsigned, void*);
-char *FontEncUndefinedName(unsigned, void*);
-
-FontEncPtr FontEncReallyLoad(const char*, const char*);
+/*
+Copyright (c) 1998-2001 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/* Private types and functions for the encoding code. */
+/* Used by the files `fontenc.h' and `encparse.h' */
+
+typedef struct _FontEncSimpleMap {
+ unsigned len; /* might be 0x10000 */
+ unsigned short row_size;
+ unsigned short first;
+ const unsigned short *map;
+} FontEncSimpleMapRec, *FontEncSimpleMapPtr;
+
+typedef struct _FontEncSimpleName {
+ unsigned len;
+ unsigned short first;
+ char **map;
+} FontEncSimpleNameRec, *FontEncSimpleNamePtr;
+
+unsigned FontEncSimpleRecode(unsigned, void*);
+unsigned FontEncUndefinedRecode(unsigned, void*);
+char *FontEncSimpleName(unsigned, void*);
+char *FontEncUndefinedName(unsigned, void*);
+
+FontEncPtr FontEncReallyLoad(const char*, const char*);