aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/fonts.src/font-util
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/fonts.src/font-util')
-rw-r--r--xorg-server/fonts.src/font-util/COPYING240
-rw-r--r--xorg-server/fonts.src/font-util/Makefile.am140
-rw-r--r--xorg-server/fonts.src/font-util/configure.ac122
-rw-r--r--xorg-server/fonts.src/font-util/fontutil.m4.in724
-rw-r--r--xorg-server/fonts.src/font-util/fontutil.pc.in22
-rw-r--r--xorg-server/fonts.src/font-util/makefile5
-rw-r--r--xorg-server/fonts.src/font-util/ucs2any.c1902
7 files changed, 1580 insertions, 1575 deletions
diff --git a/xorg-server/fonts.src/font-util/COPYING b/xorg-server/fonts.src/font-util/COPYING
index 0ff904238..9c6ebb820 100644
--- a/xorg-server/fonts.src/font-util/COPYING
+++ b/xorg-server/fonts.src/font-util/COPYING
@@ -1,120 +1,120 @@
-Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
- ------------------------------------------------------------------------
-
-Copyright (c) 2003 The NetBSD Foundation, Inc.
-All rights reserved.
-
-This code is derived from software contributed to The NetBSD Foundation
-by Ben Collver <collver1@attbi.com>.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
- ------------------------------------------------------------------------
-
-Copyright (c) 2006 Martin Husemann.
-Copyright (c) 2007 Joerg Sonnenberger.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
- ------------------------------------------------------------------------
-
-Copyright 2005 Red Hat, Inc
-
-Permission to use, copy, modify, distribute, and sell this software and its
-documentation for any purpose is hereby granted without fee, provided that
-the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation.
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the copyright holders shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from the copyright holders.
-
- ------------------------------------------------------------------------
-
-Copyright (c) 1991-2003 Unicode, Inc. All Rights reserved.
-
-This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
-No claims are made as to fitness for any particular purpose. No
-warranties of any kind are expressed or implied. The recipient
-agrees to determine applicability of information provided. If this
-file has been provided on optical media by Unicode, Inc., the sole
-remedy for any claim will be exchange of defective media within 90
-days of receipt.
-
-Unicode, Inc. hereby grants the right to freely use the information
-supplied in this file in the creation of products supporting the
-Unicode Standard, and to make copies of this file in any form for
-internal or external distribution as long as this notice remains
-attached.
+Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+ ------------------------------------------------------------------------
+
+Copyright (c) 2003 The NetBSD Foundation, Inc.
+All rights reserved.
+
+This code is derived from software contributed to The NetBSD Foundation
+by Ben Collver <collver1@attbi.com>.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+ ------------------------------------------------------------------------
+
+Copyright (c) 2006 Martin Husemann.
+Copyright (c) 2007 Joerg Sonnenberger.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+ ------------------------------------------------------------------------
+
+Copyright 2005 Red Hat, Inc
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the copyright holders.
+
+ ------------------------------------------------------------------------
+
+Copyright (c) 1991-2003 Unicode, Inc. All Rights reserved.
+
+This file is provided as-is by Unicode, Inc. (The Unicode Consortium).
+No claims are made as to fitness for any particular purpose. No
+warranties of any kind are expressed or implied. The recipient
+agrees to determine applicability of information provided. If this
+file has been provided on optical media by Unicode, Inc., the sole
+remedy for any claim will be exchange of defective media within 90
+days of receipt.
+
+Unicode, Inc. hereby grants the right to freely use the information
+supplied in this file in the creation of products supporting the
+Unicode Standard, and to make copies of this file in any form for
+internal or external distribution as long as this notice remains
+attached.
diff --git a/xorg-server/fonts.src/font-util/Makefile.am b/xorg-server/fonts.src/font-util/Makefile.am
index 48561efef..87a4fe17c 100644
--- a/xorg-server/fonts.src/font-util/Makefile.am
+++ b/xorg-server/fonts.src/font-util/Makefile.am
@@ -1,70 +1,70 @@
-# Copyright 2005 Red Hat, Inc.
-#
-# Permission to use, copy, modify, distribute, and sell this software
-# and its documentation for any purpose is hereby granted without
-# fee, provided that the above copyright notice appear in all copies
-# and that both that copyright notice and this permission notice
-# appear in supporting documentation, and that the name of Red Hat
-# not be used in advertising or publicity pertaining to distribution
-# of the software without specific, written prior permission. Red
-# Hat makes no representations about the suitability of this software
-# for any purpose. It is provided "as is" without express or implied
-# warranty.
-#
-# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
-# NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
-# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-SUBDIRS = man
-bin_PROGRAMS = bdftruncate ucs2any
-
-AM_CFLAGS = $(CWARNFLAGS)
-
-ucs2any_SOURCES = ucs2any.c
-bdftruncate_SOURCES = bdftruncate.c
-
-aclocaldir = $(datadir)/aclocal
-aclocal_DATA = fontutil.m4
-
-mapfilesdir = @MAPDIR@
-mapfiles_DATA = \
- map-ISO8859-1 \
- map-ISO8859-2 \
- map-ISO8859-3 \
- map-ISO8859-4 \
- map-ISO8859-5 \
- map-ISO8859-6 \
- map-ISO8859-7 \
- map-ISO8859-8 \
- map-ISO8859-9 \
- map-ISO8859-10 \
- map-ISO8859-11 \
- map-ISO8859-13 \
- map-ISO8859-14 \
- map-ISO8859-15 \
- map-ISO8859-16 \
- map-JISX0201.1976-0 \
- map-KOI8-R
-
-pkgconfigdir = $(libdir)/pkgconfig
-pkgconfig_DATA = fontutil.pc
-
-CLEANFILES = bdftruncate
-
-EXTRA_DIST = $(mapfiles_DATA)
-
-MAINTAINERCLEANFILES = ChangeLog INSTALL
-
-.PHONY: ChangeLog INSTALL
-
-INSTALL:
- $(INSTALL_CMD)
-
-ChangeLog:
- $(CHANGELOG_CMD)
-
-dist-hook: ChangeLog INSTALL
+# Copyright 2005 Red Hat, Inc.
+#
+# Permission to use, copy, modify, distribute, and sell this software
+# and its documentation for any purpose is hereby granted without
+# fee, provided that the above copyright notice appear in all copies
+# and that both that copyright notice and this permission notice
+# appear in supporting documentation, and that the name of Red Hat
+# not be used in advertising or publicity pertaining to distribution
+# of the software without specific, written prior permission. Red
+# Hat makes no representations about the suitability of this software
+# for any purpose. It is provided "as is" without express or implied
+# warranty.
+#
+# RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+# NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+SUBDIRS = man
+bin_PROGRAMS = bdftruncate ucs2any
+
+AM_CFLAGS = $(CWARNFLAGS)
+
+ucs2any_SOURCES = ucs2any.c
+bdftruncate_SOURCES = bdftruncate.c
+
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = fontutil.m4
+
+mapfilesdir = @MAPDIR@
+mapfiles_DATA = \
+ map-ISO8859-1 \
+ map-ISO8859-2 \
+ map-ISO8859-3 \
+ map-ISO8859-4 \
+ map-ISO8859-5 \
+ map-ISO8859-6 \
+ map-ISO8859-7 \
+ map-ISO8859-8 \
+ map-ISO8859-9 \
+ map-ISO8859-10 \
+ map-ISO8859-11 \
+ map-ISO8859-13 \
+ map-ISO8859-14 \
+ map-ISO8859-15 \
+ map-ISO8859-16 \
+ map-JISX0201.1976-0 \
+ map-KOI8-R
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = fontutil.pc
+
+CLEANFILES = bdftruncate
+
+EXTRA_DIST = $(mapfiles_DATA)
+
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+ $(INSTALL_CMD)
+
+ChangeLog:
+ $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
diff --git a/xorg-server/fonts.src/font-util/configure.ac b/xorg-server/fonts.src/font-util/configure.ac
index 471a527f9..0c8e502ee 100644
--- a/xorg-server/fonts.src/font-util/configure.ac
+++ b/xorg-server/fonts.src/font-util/configure.ac
@@ -1,61 +1,61 @@
-dnl Copyright 2005 Red Hat, Inc.
-dnl
-dnl Permission to use, copy, modify, distribute, and sell this software
-dnl and its documentation for any purpose is hereby granted without
-dnl fee, provided that the above copyright notice appear in all copies
-dnl and that both that copyright notice and this permission notice
-dnl appear in supporting documentation, and that the name of Red Hat
-dnl not be used in advertising or publicity pertaining to distribution
-dnl of the software without specific, written prior permission. Red
-dnl Hat makes no representations about the suitability of this software
-dnl for any purpose. It is provided "as is" without express or implied
-dnl warranty.
-dnl
-dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
-dnl NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
-dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
-dnl OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
-dnl NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-dnl CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-dnl
-dnl Process this file with autoconf to create configure.
-
-AC_PREREQ([2.60])
-AC_INIT([font-util], [1.2.0],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [font-util])
-AM_INIT_AUTOMAKE([foreign dist-bzip2])
-AM_MAINTAINER_MODE
-
-# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
-m4_ifndef([XORG_MACROS_VERSION],
- [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.8)
-AM_CONFIG_HEADER(config.h)
-
-XORG_DEFAULT_OPTIONS
-
-AC_PROG_CC
-AC_PROG_INSTALL
-
-AC_MSG_CHECKING([for root directory for font files])
-fontrootdir='${datadir}/fonts/X11'
-AC_ARG_WITH(fontrootdir, [AC_HELP_STRING([--with-fontrootdir=DIR],
- [Path to parent of font subdirectories [DATADIR/fonts/X11]])],
- [fontrootdir="${withval}"])
-AC_SUBST(fontrootdir)
-AC_MSG_RESULT([${fontrootdir}])
-
-mapdir='${fontrootdir}/util'
-AC_ARG_WITH(mapdir, [AC_HELP_STRING([--with-mapdir=DIR],
- [Path to install font maps [FONTROOTDIR/util]])],
- [mapdir="${withval}"])
-MAPDIR="$mapdir"
-AC_SUBST(MAPDIR)
-
-AC_CONFIG_FILES([Makefile
- man/Makefile
- fontutil.m4
- fontutil.pc])
-
-AC_OUTPUT
+dnl Copyright 2005 Red Hat, Inc.
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software
+dnl and its documentation for any purpose is hereby granted without
+dnl fee, provided that the above copyright notice appear in all copies
+dnl and that both that copyright notice and this permission notice
+dnl appear in supporting documentation, and that the name of Red Hat
+dnl not be used in advertising or publicity pertaining to distribution
+dnl of the software without specific, written prior permission. Red
+dnl Hat makes no representations about the suitability of this software
+dnl for any purpose. It is provided "as is" without express or implied
+dnl warranty.
+dnl
+dnl RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+dnl NO EVENT SHALL RED HAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+dnl CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+dnl OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+dnl NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+dnl CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+dnl
+dnl Process this file with autoconf to create configure.
+
+AC_PREREQ([2.60])
+AC_INIT([font-util], [1.2.0],
+ [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [font-util])
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+m4_ifndef([XORG_MACROS_VERSION],
+ [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.8)
+AM_CONFIG_HEADER(config.h)
+
+XORG_DEFAULT_OPTIONS
+
+AC_PROG_CC
+AC_PROG_INSTALL
+
+AC_MSG_CHECKING([for root directory for font files])
+fontrootdir='${datadir}/fonts/X11'
+AC_ARG_WITH(fontrootdir, [AC_HELP_STRING([--with-fontrootdir=DIR],
+ [Path to parent of font subdirectories [DATADIR/fonts/X11]])],
+ [fontrootdir="${withval}"])
+AC_SUBST(fontrootdir)
+AC_MSG_RESULT([${fontrootdir}])
+
+mapdir='${fontrootdir}/util'
+AC_ARG_WITH(mapdir, [AC_HELP_STRING([--with-mapdir=DIR],
+ [Path to install font maps [FONTROOTDIR/util]])],
+ [mapdir="${withval}"])
+MAPDIR="$mapdir"
+AC_SUBST(MAPDIR)
+
+AC_CONFIG_FILES([Makefile
+ man/Makefile
+ fontutil.m4
+ fontutil.pc])
+
+AC_OUTPUT
diff --git a/xorg-server/fonts.src/font-util/fontutil.m4.in b/xorg-server/fonts.src/font-util/fontutil.m4.in
index b2b9bd8b5..56d5e7b61 100644
--- a/xorg-server/fonts.src/font-util/fontutil.m4.in
+++ b/xorg-server/fonts.src/font-util/fontutil.m4.in
@@ -1,362 +1,362 @@
-dnl @configure_input@
-dnl
-dnl This file comes from X.Org's @PACKAGE_STRING@
-dnl
-dnl Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
-dnl
-dnl Permission is hereby granted, free of charge, to any person obtaining a
-dnl copy of this software and associated documentation files (the "Software"),
-dnl to deal in the Software without restriction, including without limitation
-dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
-dnl and/or sell copies of the Software, and to permit persons to whom the
-dnl Software is furnished to do so, subject to the following conditions:
-dnl
-dnl The above copyright notice and this permission notice (including the next
-dnl paragraph) shall be included in all copies or substantial portions of the
-dnl Software.
-dnl
-dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-dnl DEALINGS IN THE SOFTWARE.
-dnl
-dnl --------------------------------------------------------------------
-dnl
-dnl Copyright 2005 Red Hat, Inc
-dnl
-dnl Permission to use, copy, modify, distribute, and sell this software and its
-dnl documentation for any purpose is hereby granted without fee, provided that
-dnl the above copyright notice appear in all copies and that both that
-dnl copyright notice and this permission notice appear in supporting
-dnl documentation.
-dnl
-dnl The above copyright notice and this permission notice shall be included
-dnl in all copies or substantial portions of the Software.
-dnl
-dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-dnl OTHER DEALINGS IN THE SOFTWARE.
-dnl
-dnl Except as contained in this notice, the name of the copyright holders shall
-dnl not be used in advertising or otherwise to promote the sale, use or
-dnl other dealings in this Software without prior written authorization
-dnl from the copyright holders.
-
-# XORG_FONT_MACROS_VERSION(required-version)
-# ------------------------------------------
-# Minimum version: 1.1.0
-#
-# If you're using a macro added in Version 1.1 or newer, include this in
-# your configure.ac with the minimum required version, such as:
-# XORG_FONT_MACROS_VERSION(1.1)
-#
-# To ensure that this macro is defined, also add:
-# m4_ifndef([XORG_FONT_MACROS_VERSION],
-# [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])])
-#
-#
-# See the "minimum version" comment for each macro you use to see what
-# version you require.
-m4_defun([XORG_FONT_MACROS_VERSION],[
-m4_define([vers_have], [@VERSION@])
-m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
-m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
-m4_if(m4_cmp(maj_have, maj_needed), 0,,
- [m4_fatal([font-util major version ]maj_needed[ is required but ]vers_have[ found])])
-m4_if(m4_version_compare(vers_have, [$1]), -1,
- [m4_fatal([font-util version $1 or higher is required but ]vers_have[ found])])
-m4_undefine([vers_have])
-m4_undefine([maj_have])
-m4_undefine([maj_needed])
-]) # XORG_FONT_MACROS_VERSION
-
-# XORG_FONT_CHECK_{maps}()
-# ------------------------
-# Minimum version: 1.0.0
-# These macros add --enable/disable-{maps} where {maps} are ISO8859-*,
-# JISX0201 or KOI8_R. By default, they are all enabled.
-
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_1], [XORG_FONT_CHECK_ENCODING(ISO8859-1)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_2], [XORG_FONT_CHECK_ENCODING(ISO8859-2)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_3], [XORG_FONT_CHECK_ENCODING(ISO8859-3)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_4], [XORG_FONT_CHECK_ENCODING(ISO8859-4)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_5], [XORG_FONT_CHECK_ENCODING(ISO8859-5)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_6], [XORG_FONT_CHECK_ENCODING(ISO8859-6)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_7], [XORG_FONT_CHECK_ENCODING(ISO8859-7)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_8], [XORG_FONT_CHECK_ENCODING(ISO8859-8)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_9], [XORG_FONT_CHECK_ENCODING(ISO8859-9)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_10],[XORG_FONT_CHECK_ENCODING(ISO8859-10)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_11],[XORG_FONT_CHECK_ENCODING(ISO8859-11)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_12],[XORG_FONT_CHECK_ENCODING(ISO8859-12)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_13],[XORG_FONT_CHECK_ENCODING(ISO8859-13)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_14],[XORG_FONT_CHECK_ENCODING(ISO8859-14)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_15],[XORG_FONT_CHECK_ENCODING(ISO8859-15)])
-AC_DEFUN([XORG_FONT_CHECK_ISO8859_16],[XORG_FONT_CHECK_ENCODING(ISO8859-16)])
-AC_DEFUN([XORG_FONT_CHECK_JISX0201], [XORG_FONT_CHECK_ENCODING(JISX0201)])
-AC_DEFUN([XORG_FONT_CHECK_KOI8_R], [XORG_FONT_CHECK_ENCODING(KOI8-R)])
-
-# XORG_FONT_CHECK_ENCODING(encoding)
-# ----------------------------------
-# Minimum version: 1.1.0
-# This macro adds --enable/disable-<encoding>, enabled by default.
-# It replaced individual copies of this code in the above macros in 1.1.
-# Currently assumes encoding names will be all upper-case - add m4_toupper
-# calls if this is not true in the future.
-
-AC_DEFUN([XORG_FONT_CHECK_ENCODING],[
- AC_ARG_ENABLE(m4_tolower($1),
- AS_HELP_STRING(m4_join([-], [--disable], m4_tolower($1)),
- [Build $1 fonts (default: yes)]),
- [AS_TR_SH($1)=$enableval])
- AC_MSG_CHECKING([whether to build $1 fonts])
- AC_MSG_RESULT($[AS_TR_SH($1)])
- AM_CONDITIONAL(AS_TR_SH($1), [test "x$AS_TR_SH($1)" = xyes])
-]) # XORG_FONT_CHECK_ENCODING
-
-# XORG_FONT_CHECK_ENCODING_LIST(encoding1 encoding2....)
-# -----------------------------------------------------
-# Minimum version: 1.1.0
-# Call XORG_FONT_CHECK_ENCODING for multiple encodings at once.
-# Add a shorthand --enable/disable-all-encodings option.
-
-AC_DEFUN([XORG_FONT_CHECK_ENCODING_LIST],[
- AC_ARG_ENABLE([all-encodings],
- AS_HELP_STRING([--disable-all-encodings],
- [Disable building of all font encodings]),
- [m4_foreach_w([enc], [$1], [
- AS_TR_SH(enc)=$enableval
- ])],
- [m4_foreach_w([enc], [$1], [
- AS_TR_SH(enc)=yes
- ])])
- m4_foreach_w([enc], [$1], [XORG_FONT_CHECK_ENCODING(enc)])
-]) # XORG_FONT_CHECK_ENCODING_LIST
-
-# XORG_FONT_REQUIRED_PROG(VARNAME, progname)
-# ------------------------------------------
-# Minimum version: 1.1.0
-#
-# Simple wrapper around AC_PATH_PROG that errors if not found
-#
-
-AC_DEFUN([XORG_FONT_REQUIRED_PROG],[
- AC_PATH_PROG($1, $2)
- if test x"$$1" = x; then
- AC_MSG_ERROR([$2 is required to build $PACKAGE_NAME.])
- fi
-])
-
-
-# XORG_FONT_FCCACHE()
-# -------------------
-# Minimum version: 1.1.0
-#
-# Set FCCACHE to path to fc-cache (fontconfig cache builder) if found
-# Set RUN_FCCACHE to a rule suitable for substituting into a makefile
-# to run fc-cache if found and not installing to $DESTDIR
-#
-# fc-cache is optional, not required, and should be skipped when making
-# packages (installing to $DESTDIR).
-#
-AC_DEFUN([XORG_FONT_FCCACHE],[
- AC_PATH_PROG(FCCACHE, fc-cache)
- FCCACHE_WARN='echo "** Warning: fonts.cache not built" ; echo "** Generate this file manually on host system using fc-cache"'
- if test x"$FCCACHE" = x ; then
- RUN_FCCACHE="${FCCACHE_WARN}"
- else
- RUN_FCCACHE='@(if test -z "$(DESTDIR)"; then echo $(FCCACHE) $(fontdir); $(FCCACHE) $(fontdir); else'
- RUN_FCCACHE="${RUN_FCCACHE} ${FCCACHE_WARN} ; fi)"
- fi
- AC_SUBST([RUN_FCCACHE])
-])
-
-
-# XORG_FONT_COMMON_UTILS()
-# ------------------------
-# Minimum version: 1.1.0
-#
-# Call XORG_FONT_REQUIRED_PROG for programs needed for all font types
-
-AC_DEFUN([XORG_FONT_COMMON_UTILS],[
- XORG_FONT_FCCACHE
- XORG_FONT_REQUIRED_PROG(MKFONTDIR, mkfontdir)
-])
-
-# XORG_FONT_SCALED_UTILS()
-# ------------------------
-# Minimum version: 1.1.0
-#
-# Call XORG_FONT_REQUIRED_PROG for programs needed for scalable fonts
-# (TrueType, OpenType, Type1)
-
-AC_DEFUN([XORG_FONT_SCALED_UTILS],[
- XORG_FONT_COMMON_UTILS
- XORG_FONT_REQUIRED_PROG(MKFONTSCALE, mkfontscale)
-])
-
-# XORG_FONT_BDF_UTILS()
-# ---------------------
-# Minimum version: 1.1.0
-#
-# Call XORG_FONT_REQUIRED_PROG for programs needed for BDF format bitmap fonts
-# Also call XORG_FONT_CHECK_COMPRESSION to determine how to compress the
-# PCF output files created by bdftopcf
-
-AC_DEFUN([XORG_FONT_BDF_UTILS],[
- XORG_FONT_COMMON_UTILS
- XORG_FONT_REQUIRED_PROG(BDFTOPCF, bdftopcf)
- XORG_FONT_CHECK_COMPRESSION
-])
-
-# XORG_FONT_CHECK_COMPRESSION()
-# -----------------------------
-# Minimum version: 1.1.0
-#
-# Offer a --with-compression flag to control what compression method is
-# used for pcf font files. Offers all the methods currently supported
-# by libXfont, including no compression.
-
-AC_DEFUN([XORG_FONT_CHECK_COMPRESSION],[
- AC_MSG_CHECKING([font compression method])
- AC_ARG_WITH(compression,
- [AS_HELP_STRING([--with-compression=<no|compress|gzip|bzip2>],
- [compression method to use on pcf fonts])],
- [compression="$withval"], [compression="yes"])
- if test x"$compression" = "xyes" ; then
- compression="gzip"
- fi
- AC_MSG_RESULT([${compression}])
- case ${compression} in
- *compress) COMPRESS_SUFFIX=".Z" ;;
- *gzip) COMPRESS_SUFFIX=".gz" ;;
- *bzip2) COMPRESS_SUFFIX=".bz2" ;;
- no|none) COMPRESS_SUFFIX="" ; COMPRESS="cat" ;;
- *) AC_MSG_ERROR([${compression} is not a supported compression method]) ;;
- esac
- if test x"$COMPRESS_SUFFIX" != "x" ; then
- XORG_FONT_REQUIRED_PROG(COMPRESS, ${compression})
- fi
- AC_SUBST([COMPRESS_SUFFIX])
-])
-
-# XORG_FONT_UCS2ANY()
-# -------------------
-# Minimum version: 1.1.0
-#
-# Call XORG_FONT_REQUIRED_PROG for ucs2any program needed for splitting
-# Unicode-encoded BDF format bitmap fonts into subsets for older encodings.
-# Also call pkg-config to find the directory with the encoding files needed
-# by ucs2any, and export it as MAPFILES_PATH to the Makefiles
-
-AC_DEFUN([XORG_FONT_UCS2ANY],[
- XORG_FONT_REQUIRED_PROG(UCS2ANY, ucs2any)
- PKG_CHECK_MODULES(MAPS, [fontutil])
- AC_MSG_CHECKING([for ucs2any encoding data files])
- MAPFILES_PATH=`pkg-config --variable=mapdir fontutil`
- AC_SUBST(MAPFILES_PATH)
- AC_MSG_RESULT([${MAPFILES_PATH}])
-])
-
-
-
-# XORG_FONT_FC_CONFDIR()
-# --------------------
-# Minimum version: 1.2.0
-#
-# Sets FC_CONFDIR to the fontconfig config directory
-# (which should be --with-confdir=... when building fontconfig)
-# found from:
-# --with-fc-confdir=...
-# pkg-config --variable=confdir fontconfig
-# ${sysconfdir}/fonts
-
-AC_DEFUN([XORG_FONT_FC_CONFDIR],[
- dnl Ensure $PKG_CONFIG is set first
- AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-
- AC_MSG_CHECKING([for fontconfig's configuration directory])
- AC_ARG_WITH(fc-confdir,
- AS_HELP_STRING([--with-fc-confdir=DIR],
- [Path to fontconfig's configuration directory]),
- [FC_CONFDIR="$withval"])
- # if --with-fc-confdir was not specified
- if test "x${FC_CONFDIR}" = "x"; then
- FC_CONFDIR=`$PKG_CONFIG --variable=confdir fontconfig`
- fi
- # ...and if pkg-config didn't find confdir in fontconfig.pc...
- if test "x${FC_CONFDIR}" = "x"; then
- FC_CONFDIR="${sysconfdir}/fonts"
- fi
- AC_SUBST(FC_CONFDIR)
- AC_MSG_RESULT([${FC_CONFDIR}])
-])
-
-
-
-# XORG_FONTROOTDIR()
-# --------------------
-# Minimum version: 1.1.0
-#
-# Sets FONTROOTDIR to the root directory for font files. Uses the first
-# found from:
-# --with-fontrootdir
-# pkg-config --variable=fontrootdir fontutil
-# ${datadir}/fonts/X11
-
-AC_DEFUN([XORG_FONTROOTDIR],[
- dnl Ensure $PKG_CONFIG is set first
- AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-
- AC_MSG_CHECKING([for root directory for font files])
- AC_ARG_WITH(fontrootdir,
- AS_HELP_STRING([--with-fontrootdir=DIR],
- [Path to root directory for font files]),
- [FONTROOTDIR="$withval"])
- # if --with-fontrootdir not specified...
- if test "x${FONTROOTDIR}" = "x"; then
- FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil`
- fi
- # ...and if pkg-config didn't find fontdir in fontutil.pc...
- if test "x${FONTROOTDIR}" = "x"; then
- FONTROOTDIR="${datadir}/fonts/X11"
- fi
- AC_SUBST(FONTROOTDIR)
- AC_MSG_RESULT([${FONTROOTDIR}])
-])
-
-# XORG_FONTSUBDIR(variable, flag, subdir)
-# ---------------------------------------
-# Minimum version: 1.1.0
-#
-# Offer a --with-<flag> flag to control directory for font installation
-# Default is the specified <subdir> of the font root directory.
-# Sets <variable> to the selected directory
-
-AC_DEFUN([XORG_FONTSUBDIR],[
- AC_REQUIRE([XORG_FONTROOTDIR])
-
- AC_MSG_CHECKING([for directory for $3 files])
- AC_ARG_WITH($2,
- [AS_HELP_STRING([--with-$2=DIR],
- [Path to $3 files [FONTROOTDIR/$3]])],
- [$1="${withval}"], [$1='${FONTROOTDIR}/$3'])
- AC_SUBST($1)
- AC_MSG_RESULT([${$1}])
-]) # XORG_FONTSUBDIR
-
-# XORG_FONTDIR(subdir)
-# --------------------
-# Minimum version: 1.1.0
-#
-# Offer a --with-fontdir flag to control directory for font installation
-# Default is the specified subdir of the font root directory.
-# Sets FONTDIR to the selected directory
-
-AC_DEFUN([XORG_FONTDIR],[XORG_FONTSUBDIR([FONTDIR], [fontdir], [$1])])
+dnl @configure_input@
+dnl
+dnl This file comes from X.Org's @PACKAGE_STRING@
+dnl
+dnl Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+dnl
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the "Software"),
+dnl to deal in the Software without restriction, including without limitation
+dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
+dnl and/or sell copies of the Software, and to permit persons to whom the
+dnl Software is furnished to do so, subject to the following conditions:
+dnl
+dnl The above copyright notice and this permission notice (including the next
+dnl paragraph) shall be included in all copies or substantial portions of the
+dnl Software.
+dnl
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+dnl DEALINGS IN THE SOFTWARE.
+dnl
+dnl --------------------------------------------------------------------
+dnl
+dnl Copyright 2005 Red Hat, Inc
+dnl
+dnl Permission to use, copy, modify, distribute, and sell this software and its
+dnl documentation for any purpose is hereby granted without fee, provided that
+dnl the above copyright notice appear in all copies and that both that
+dnl copyright notice and this permission notice appear in supporting
+dnl documentation.
+dnl
+dnl The above copyright notice and this permission notice shall be included
+dnl in all copies or substantial portions of the Software.
+dnl
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+dnl OTHER DEALINGS IN THE SOFTWARE.
+dnl
+dnl Except as contained in this notice, the name of the copyright holders shall
+dnl not be used in advertising or otherwise to promote the sale, use or
+dnl other dealings in this Software without prior written authorization
+dnl from the copyright holders.
+
+# XORG_FONT_MACROS_VERSION(required-version)
+# ------------------------------------------
+# Minimum version: 1.1.0
+#
+# If you're using a macro added in Version 1.1 or newer, include this in
+# your configure.ac with the minimum required version, such as:
+# XORG_FONT_MACROS_VERSION(1.1)
+#
+# To ensure that this macro is defined, also add:
+# m4_ifndef([XORG_FONT_MACROS_VERSION],
+# [m4_fatal([must install X.Org font-util 1.1 or later before running autoconf/autogen])])
+#
+#
+# See the "minimum version" comment for each macro you use to see what
+# version you require.
+m4_defun([XORG_FONT_MACROS_VERSION],[
+m4_define([vers_have], [@VERSION@])
+m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
+m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
+m4_if(m4_cmp(maj_have, maj_needed), 0,,
+ [m4_fatal([font-util major version ]maj_needed[ is required but ]vers_have[ found])])
+m4_if(m4_version_compare(vers_have, [$1]), -1,
+ [m4_fatal([font-util version $1 or higher is required but ]vers_have[ found])])
+m4_undefine([vers_have])
+m4_undefine([maj_have])
+m4_undefine([maj_needed])
+]) # XORG_FONT_MACROS_VERSION
+
+# XORG_FONT_CHECK_{maps}()
+# ------------------------
+# Minimum version: 1.0.0
+# These macros add --enable/disable-{maps} where {maps} are ISO8859-*,
+# JISX0201 or KOI8_R. By default, they are all enabled.
+
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_1], [XORG_FONT_CHECK_ENCODING(ISO8859-1)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_2], [XORG_FONT_CHECK_ENCODING(ISO8859-2)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_3], [XORG_FONT_CHECK_ENCODING(ISO8859-3)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_4], [XORG_FONT_CHECK_ENCODING(ISO8859-4)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_5], [XORG_FONT_CHECK_ENCODING(ISO8859-5)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_6], [XORG_FONT_CHECK_ENCODING(ISO8859-6)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_7], [XORG_FONT_CHECK_ENCODING(ISO8859-7)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_8], [XORG_FONT_CHECK_ENCODING(ISO8859-8)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_9], [XORG_FONT_CHECK_ENCODING(ISO8859-9)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_10],[XORG_FONT_CHECK_ENCODING(ISO8859-10)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_11],[XORG_FONT_CHECK_ENCODING(ISO8859-11)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_12],[XORG_FONT_CHECK_ENCODING(ISO8859-12)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_13],[XORG_FONT_CHECK_ENCODING(ISO8859-13)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_14],[XORG_FONT_CHECK_ENCODING(ISO8859-14)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_15],[XORG_FONT_CHECK_ENCODING(ISO8859-15)])
+AC_DEFUN([XORG_FONT_CHECK_ISO8859_16],[XORG_FONT_CHECK_ENCODING(ISO8859-16)])
+AC_DEFUN([XORG_FONT_CHECK_JISX0201], [XORG_FONT_CHECK_ENCODING(JISX0201)])
+AC_DEFUN([XORG_FONT_CHECK_KOI8_R], [XORG_FONT_CHECK_ENCODING(KOI8-R)])
+
+# XORG_FONT_CHECK_ENCODING(encoding)
+# ----------------------------------
+# Minimum version: 1.1.0
+# This macro adds --enable/disable-<encoding>, enabled by default.
+# It replaced individual copies of this code in the above macros in 1.1.
+# Currently assumes encoding names will be all upper-case - add m4_toupper
+# calls if this is not true in the future.
+
+AC_DEFUN([XORG_FONT_CHECK_ENCODING],[
+ AC_ARG_ENABLE(m4_tolower($1),
+ AS_HELP_STRING(m4_join([-], [--disable], m4_tolower($1)),
+ [Build $1 fonts (default: yes)]),
+ [AS_TR_SH($1)=$enableval])
+ AC_MSG_CHECKING([whether to build $1 fonts])
+ AC_MSG_RESULT($[AS_TR_SH($1)])
+ AM_CONDITIONAL(AS_TR_SH($1), [test "x$AS_TR_SH($1)" = xyes])
+]) # XORG_FONT_CHECK_ENCODING
+
+# XORG_FONT_CHECK_ENCODING_LIST(encoding1 encoding2....)
+# -----------------------------------------------------
+# Minimum version: 1.1.0
+# Call XORG_FONT_CHECK_ENCODING for multiple encodings at once.
+# Add a shorthand --enable/disable-all-encodings option.
+
+AC_DEFUN([XORG_FONT_CHECK_ENCODING_LIST],[
+ AC_ARG_ENABLE([all-encodings],
+ AS_HELP_STRING([--disable-all-encodings],
+ [Disable building of all font encodings]),
+ [m4_foreach_w([enc], [$1], [
+ AS_TR_SH(enc)=$enableval
+ ])],
+ [m4_foreach_w([enc], [$1], [
+ AS_TR_SH(enc)=yes
+ ])])
+ m4_foreach_w([enc], [$1], [XORG_FONT_CHECK_ENCODING(enc)])
+]) # XORG_FONT_CHECK_ENCODING_LIST
+
+# XORG_FONT_REQUIRED_PROG(VARNAME, progname)
+# ------------------------------------------
+# Minimum version: 1.1.0
+#
+# Simple wrapper around AC_PATH_PROG that errors if not found
+#
+
+AC_DEFUN([XORG_FONT_REQUIRED_PROG],[
+ AC_PATH_PROG($1, $2)
+ if test x"$$1" = x; then
+ AC_MSG_ERROR([$2 is required to build $PACKAGE_NAME.])
+ fi
+])
+
+
+# XORG_FONT_FCCACHE()
+# -------------------
+# Minimum version: 1.1.0
+#
+# Set FCCACHE to path to fc-cache (fontconfig cache builder) if found
+# Set RUN_FCCACHE to a rule suitable for substituting into a makefile
+# to run fc-cache if found and not installing to $DESTDIR
+#
+# fc-cache is optional, not required, and should be skipped when making
+# packages (installing to $DESTDIR).
+#
+AC_DEFUN([XORG_FONT_FCCACHE],[
+ AC_PATH_PROG(FCCACHE, fc-cache)
+ FCCACHE_WARN='echo "** Warning: fonts.cache not built" ; echo "** Generate this file manually on host system using fc-cache"'
+ if test x"$FCCACHE" = x ; then
+ RUN_FCCACHE="${FCCACHE_WARN}"
+ else
+ RUN_FCCACHE='@(if test -z "$(DESTDIR)"; then echo $(FCCACHE) $(fontdir); $(FCCACHE) $(fontdir); else'
+ RUN_FCCACHE="${RUN_FCCACHE} ${FCCACHE_WARN} ; fi)"
+ fi
+ AC_SUBST([RUN_FCCACHE])
+])
+
+
+# XORG_FONT_COMMON_UTILS()
+# ------------------------
+# Minimum version: 1.1.0
+#
+# Call XORG_FONT_REQUIRED_PROG for programs needed for all font types
+
+AC_DEFUN([XORG_FONT_COMMON_UTILS],[
+ XORG_FONT_FCCACHE
+ XORG_FONT_REQUIRED_PROG(MKFONTDIR, mkfontdir)
+])
+
+# XORG_FONT_SCALED_UTILS()
+# ------------------------
+# Minimum version: 1.1.0
+#
+# Call XORG_FONT_REQUIRED_PROG for programs needed for scalable fonts
+# (TrueType, OpenType, Type1)
+
+AC_DEFUN([XORG_FONT_SCALED_UTILS],[
+ XORG_FONT_COMMON_UTILS
+ XORG_FONT_REQUIRED_PROG(MKFONTSCALE, mkfontscale)
+])
+
+# XORG_FONT_BDF_UTILS()
+# ---------------------
+# Minimum version: 1.1.0
+#
+# Call XORG_FONT_REQUIRED_PROG for programs needed for BDF format bitmap fonts
+# Also call XORG_FONT_CHECK_COMPRESSION to determine how to compress the
+# PCF output files created by bdftopcf
+
+AC_DEFUN([XORG_FONT_BDF_UTILS],[
+ XORG_FONT_COMMON_UTILS
+ XORG_FONT_REQUIRED_PROG(BDFTOPCF, bdftopcf)
+ XORG_FONT_CHECK_COMPRESSION
+])
+
+# XORG_FONT_CHECK_COMPRESSION()
+# -----------------------------
+# Minimum version: 1.1.0
+#
+# Offer a --with-compression flag to control what compression method is
+# used for pcf font files. Offers all the methods currently supported
+# by libXfont, including no compression.
+
+AC_DEFUN([XORG_FONT_CHECK_COMPRESSION],[
+ AC_MSG_CHECKING([font compression method])
+ AC_ARG_WITH(compression,
+ [AS_HELP_STRING([--with-compression=<no|compress|gzip|bzip2>],
+ [compression method to use on pcf fonts])],
+ [compression="$withval"], [compression="yes"])
+ if test x"$compression" = "xyes" ; then
+ compression="gzip"
+ fi
+ AC_MSG_RESULT([${compression}])
+ case ${compression} in
+ *compress) COMPRESS_SUFFIX=".Z" ;;
+ *gzip) COMPRESS_SUFFIX=".gz" ;;
+ *bzip2) COMPRESS_SUFFIX=".bz2" ;;
+ no|none) COMPRESS_SUFFIX="" ; COMPRESS="cat" ;;
+ *) AC_MSG_ERROR([${compression} is not a supported compression method]) ;;
+ esac
+ if test x"$COMPRESS_SUFFIX" != "x" ; then
+ XORG_FONT_REQUIRED_PROG(COMPRESS, ${compression})
+ fi
+ AC_SUBST([COMPRESS_SUFFIX])
+])
+
+# XORG_FONT_UCS2ANY()
+# -------------------
+# Minimum version: 1.1.0
+#
+# Call XORG_FONT_REQUIRED_PROG for ucs2any program needed for splitting
+# Unicode-encoded BDF format bitmap fonts into subsets for older encodings.
+# Also call pkg-config to find the directory with the encoding files needed
+# by ucs2any, and export it as MAPFILES_PATH to the Makefiles
+
+AC_DEFUN([XORG_FONT_UCS2ANY],[
+ XORG_FONT_REQUIRED_PROG(UCS2ANY, ucs2any)
+ PKG_CHECK_MODULES(MAPS, [fontutil])
+ AC_MSG_CHECKING([for ucs2any encoding data files])
+ MAPFILES_PATH=`pkg-config --variable=mapdir fontutil`
+ AC_SUBST(MAPFILES_PATH)
+ AC_MSG_RESULT([${MAPFILES_PATH}])
+])
+
+
+
+# XORG_FONT_FC_CONFDIR()
+# --------------------
+# Minimum version: 1.2.0
+#
+# Sets FC_CONFDIR to the fontconfig config directory
+# (which should be --with-confdir=... when building fontconfig)
+# found from:
+# --with-fc-confdir=...
+# pkg-config --variable=confdir fontconfig
+# ${sysconfdir}/fonts
+
+AC_DEFUN([XORG_FONT_FC_CONFDIR],[
+ dnl Ensure $PKG_CONFIG is set first
+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+
+ AC_MSG_CHECKING([for fontconfig's configuration directory])
+ AC_ARG_WITH(fc-confdir,
+ AS_HELP_STRING([--with-fc-confdir=DIR],
+ [Path to fontconfig's configuration directory]),
+ [FC_CONFDIR="$withval"])
+ # if --with-fc-confdir was not specified
+ if test "x${FC_CONFDIR}" = "x"; then
+ FC_CONFDIR=`$PKG_CONFIG --variable=confdir fontconfig`
+ fi
+ # ...and if pkg-config didn't find confdir in fontconfig.pc...
+ if test "x${FC_CONFDIR}" = "x"; then
+ FC_CONFDIR="${sysconfdir}/fonts"
+ fi
+ AC_SUBST(FC_CONFDIR)
+ AC_MSG_RESULT([${FC_CONFDIR}])
+])
+
+
+
+# XORG_FONTROOTDIR()
+# --------------------
+# Minimum version: 1.1.0
+#
+# Sets FONTROOTDIR to the root directory for font files. Uses the first
+# found from:
+# --with-fontrootdir
+# pkg-config --variable=fontrootdir fontutil
+# ${datadir}/fonts/X11
+
+AC_DEFUN([XORG_FONTROOTDIR],[
+ dnl Ensure $PKG_CONFIG is set first
+ AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+
+ AC_MSG_CHECKING([for root directory for font files])
+ AC_ARG_WITH(fontrootdir,
+ AS_HELP_STRING([--with-fontrootdir=DIR],
+ [Path to root directory for font files]),
+ [FONTROOTDIR="$withval"])
+ # if --with-fontrootdir not specified...
+ if test "x${FONTROOTDIR}" = "x"; then
+ FONTROOTDIR=`$PKG_CONFIG --variable=fontrootdir fontutil`
+ fi
+ # ...and if pkg-config didn't find fontdir in fontutil.pc...
+ if test "x${FONTROOTDIR}" = "x"; then
+ FONTROOTDIR="${datadir}/fonts/X11"
+ fi
+ AC_SUBST(FONTROOTDIR)
+ AC_MSG_RESULT([${FONTROOTDIR}])
+])
+
+# XORG_FONTSUBDIR(variable, flag, subdir)
+# ---------------------------------------
+# Minimum version: 1.1.0
+#
+# Offer a --with-<flag> flag to control directory for font installation
+# Default is the specified <subdir> of the font root directory.
+# Sets <variable> to the selected directory
+
+AC_DEFUN([XORG_FONTSUBDIR],[
+ AC_REQUIRE([XORG_FONTROOTDIR])
+
+ AC_MSG_CHECKING([for directory for $3 files])
+ AC_ARG_WITH($2,
+ [AS_HELP_STRING([--with-$2=DIR],
+ [Path to $3 files [FONTROOTDIR/$3]])],
+ [$1="${withval}"], [$1='${FONTROOTDIR}/$3'])
+ AC_SUBST($1)
+ AC_MSG_RESULT([${$1}])
+]) # XORG_FONTSUBDIR
+
+# XORG_FONTDIR(subdir)
+# --------------------
+# Minimum version: 1.1.0
+#
+# Offer a --with-fontdir flag to control directory for font installation
+# Default is the specified subdir of the font root directory.
+# Sets FONTDIR to the selected directory
+
+AC_DEFUN([XORG_FONTDIR],[XORG_FONTSUBDIR([FONTDIR], [fontdir], [$1])])
diff --git a/xorg-server/fonts.src/font-util/fontutil.pc.in b/xorg-server/fonts.src/font-util/fontutil.pc.in
index 27055a1e8..c5a22ed1a 100644
--- a/xorg-server/fonts.src/font-util/fontutil.pc.in
+++ b/xorg-server/fonts.src/font-util/fontutil.pc.in
@@ -1,11 +1,11 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-datarootdir=@datarootdir@
-datadir=@datadir@
-fontrootdir=@fontrootdir@
-mapdir=@MAPDIR@
-
-Name: FontUtil
-Description: Font utilities dirs
-Version: @PACKAGE_VERSION@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+datarootdir=@datarootdir@
+datadir=@datadir@
+fontrootdir=@fontrootdir@
+mapdir=@MAPDIR@
+
+Name: FontUtil
+Description: Font utilities dirs
+Version: @PACKAGE_VERSION@
diff --git a/xorg-server/fonts.src/font-util/makefile b/xorg-server/fonts.src/font-util/makefile
new file mode 100644
index 000000000..13e196a03
--- /dev/null
+++ b/xorg-server/fonts.src/font-util/makefile
@@ -0,0 +1,5 @@
+TTYAPP = ucs2any
+
+CSRCS = ucs2any.c
+
+DEFINES += NEED_BASENAME
diff --git a/xorg-server/fonts.src/font-util/ucs2any.c b/xorg-server/fonts.src/font-util/ucs2any.c
index a6e8fb6bb..f51d0cbf7 100644
--- a/xorg-server/fonts.src/font-util/ucs2any.c
+++ b/xorg-server/fonts.src/font-util/ucs2any.c
@@ -1,951 +1,951 @@
-/*-
- * Copyright (c) 2003 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Ben Collver <collver1@attbi.com>.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * This utility allows you to generate from an ISO10646-1 encoded
- * BDF font other BDF fonts in any possible encoding. This way, you can
- * derive from a single ISO10646-1 master font a whole set of 8-bit
- * fonts in all ISO 8859 and various other encodings. (Hopefully
- * a future XFree86 release will have a similar facility built into
- * the server, which can reencode ISO10646-1 on the fly, because
- * storing the same fonts in many different encodings is clearly
- * a waste of storage capacity).
-*/
-
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#if !defined(NEED_BASENAME) && !defined(Lynx)
-#include <libgen.h>
-#endif
-#include <limits.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-/* global variable for argv[0] */
-static const char *my_name = NULL;
-
-#ifdef NEED_BASENAME
-static char *
-basename(char *pathname)
-{
- char *ptr;
-
- ptr = strrchr(pathname, '/');
- return ((ptr == NULL) ? pathname : &ptr[1]);
-}
-#endif
-
-/* "CLASS" "z" string and memory manipulation */
-
-static void *
-zmalloc(size_t size)
-{
- void *r;
- r = malloc(size);
- if (r == NULL) {
- perror(my_name);
- exit(errno);
- }
- memset(r, 0, size);
- return r;
-}
-
-static void *
-zrealloc(void *ptr, size_t size)
-{
- void *temp;
- temp = realloc(ptr, size);
- if (temp == NULL) {
- perror(my_name);
- exit(errno);
- }
- return temp;
-}
-
-static char *
-zstrdup(const char *str)
-{
- char *retval;
-
- if (str == NULL) {
- fprintf(stderr, "%s: zstrdup(NULL)\n", my_name);
- exit(1);
- }
- retval = strdup(str);
- if (retval == NULL) {
- perror(my_name);
- exit(errno);
- }
- return retval;
-}
-
-static void
-zstrcpy(char **dest, const char *source)
-{
- if (*dest != NULL)
- free(*dest);
- *dest = zstrdup(source);
-}
-
-static void
-zquotedcpy(char **dest, const char *source)
-{
- const char *start, *end;
-
- if (*dest != NULL)
- free(*dest);
- *dest = NULL;
- start = source;
- if (*start == '"') {
- start = source+1;
- end = strrchr(start, '"');
- if (!end) return;
- *dest = zmalloc(end-start+1);
- strncpy(*dest, start, end-start);
- (*dest)[end-start] = '\0';
- } else {
- *dest = zstrdup(source);
- }
-}
-
-static void
-zstrcat(char **dest, const char *source)
-{
- int dest_size = 1;
- int source_size;
-
- if (*dest != NULL)
- dest_size = strlen(*dest) + 1;
- source_size = strlen(source);
- *dest = zrealloc(*dest, dest_size + source_size);
- strcpy(*dest + dest_size - 1, source);
-}
-
-static void
-zstrtoupper(char *s)
-{
- char *t;
-
- for (t = s; *t != '\000'; t++)
- *t = toupper(*t);
-}
-
-#define zs_true(x) (x != NULL && strcmp(x, "0") != 0)
-#define zi_true(x) (x == 1)
-
-/* "CLASS" "dynamic array" */
-
-typedef struct {
- char *name;
- int size;
- int count;
- void **values;
- void *nv;
-} da_t;
-
-static da_t *
-da_new(char *name)
-{
- da_t *da;
-
- da = zmalloc(sizeof(da_t));
- da->size = 0;
- da->count = 0;
- da->values = NULL;
- da->nv = NULL;
- da->name = NULL;
- zstrcpy(&(da->name), name);
- return da;
-}
-
-static void *
-da_fetch(da_t *da, int key)
-{
- void *r = NULL;
-
- if (key >= 0 && key < da->size && da->values[key] != NULL)
- r = da->values[key];
- else
- if (key == -1 && da->nv != NULL)
- r = da->nv;
-
- return r;
-}
-
-static int
-da_fetch_int(da_t *da, int key)
-{
- int *t;
- int r = -1;
- t = da_fetch(da, key);
- if (t != NULL)
- r = *t;
- return r;
-}
-
-#define da_fetch_str(a,k) \
- (char *)da_fetch(a,k)
-
-static void
-da_add(da_t *da, int key, void *value)
-{
- int i = da->size;
- if (key >= 0) {
- if (key >= da->size) {
- da->size = key + 1;
- da->values = zrealloc(da->values,
- da->size * sizeof(void *));
- for (; i < da->size; i++)
- da->values[i] = NULL;
- }
- if (da->values[key] != NULL) {
- free(da->values[key]);
- } else {
- if (value == NULL) {
- if (da->count > 0)
- da->count--;
- } else {
- da->count++;
- }
- }
- da->values[key] = value;
- } else if (key == -1) {
- if (da->nv != NULL)
- free(da->nv);
- da->nv = value;
- }
-}
-
-static void
-da_add_str(da_t *da, int key, char *value)
-{
- da_add(da, key, value?zstrdup(value):NULL);
-}
-
-static void
-da_add_int(da_t *da, int key, int value)
-{
- int *v;
-
- v = zmalloc(sizeof(int));
- *v = value;
- da_add(da, key, v);
-}
-
-#define da_count(da) (da->count)
-#define da_size(da) (da->size)
-
-static void
-da_clear(da_t *da)
-{
- int i;
-
- for (i = da->size; i; i--)
- free(da->values[i]);
- if (da->values != NULL)
- free(da->values);
- da->size = 0;
- da->count = 0;
- da->values = NULL;
-}
-
-/* "CLASS" file input */
-
-#define TYPICAL_LINE_SIZE (80)
-
-/* read a line and strip trailing whitespace */
-static int
-read_line(FILE *fp, char **buffer)
-{
- int buffer_size = TYPICAL_LINE_SIZE;
- int eof = 0;
- int position = 0;
- int c;
-
- *buffer = zmalloc(TYPICAL_LINE_SIZE);
- (*buffer)[0] = '\0';
-
- if ((c = getc(fp)) == EOF)
- eof = 1;
-
- while (c != '\n' && !eof) {
- if (position + 1 >= buffer_size) {
- buffer_size = buffer_size * 2 + 1;
- *buffer = zrealloc(*buffer, buffer_size);
- }
- (*buffer)[position++] = c;
- (*buffer)[position] = '\0';
- c = getc(fp);
- if (c == EOF)
- eof = 1;
- }
-
- if (eof) {
- free(*buffer);
- *buffer = NULL;
- return 0;
- }
-
- while (position > 1) {
- position--;
- if (!isspace((*buffer)[position]))
- break;
- (*buffer)[position] = '\0';
- }
-
- return 1;
-}
-
-/* BEGIN */
-
-/*
-DEC VT100 graphics characters in the range 1-31 (as expected by
-some old xterm versions and a few other applications)
-*/
-#define decmap_size 31
-static int decmap[decmap_size] = {
- 0x25C6, /* BLACK DIAMOND */
- 0x2592, /* MEDIUM SHADE */
- 0x2409, /* SYMBOL FOR HORIZONTAL TABULATION */
- 0x240C, /* SYMBOL FOR FORM FEED */
- 0x240D, /* SYMBOL FOR CARRIAGE RETURN */
- 0x240A, /* SYMBOL FOR LINE FEED */
- 0x00B0, /* DEGREE SIGN */
- 0x00B1, /* PLUS-MINUS SIGN */
- 0x2424, /* SYMBOL FOR NEWLINE */
- 0x240B, /* SYMBOL FOR VERTICAL TABULATION */
- 0x2518, /* BOX DRAWINGS LIGHT UP AND LEFT */
- 0x2510, /* BOX DRAWINGS LIGHT DOWN AND LEFT */
- 0x250C, /* BOX DRAWINGS LIGHT DOWN AND RIGHT */
- 0x2514, /* BOX DRAWINGS LIGHT UP AND RIGHT */
- 0x253C, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
- 0x23BA, /* HORIZONTAL SCAN LINE-1 (Unicode 3.2 draft) */
- 0x23BB, /* HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */
- 0x2500, /* BOX DRAWINGS LIGHT HORIZONTAL */
- 0x23BC, /* HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */
- 0x23BD, /* HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */
- 0x251C, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
- 0x2524, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT */
- 0x2534, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL */
- 0x252C, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
- 0x2502, /* BOX DRAWINGS LIGHT VERTICAL */
- 0x2264, /* LESS-THAN OR EQUAL TO */
- 0x2265, /* GREATER-THAN OR EQUAL TO */
- 0x03C0, /* GREEK SMALL LETTER PI */
- 0x2260, /* NOT EQUAL TO */
- 0x00A3, /* POUND SIGN */
- 0x00B7 /* MIDDLE DOT */
-};
-
-static int
-is_control(int ucs)
-{
- return ((ucs >= 0x00 && ucs <= 0x1f) ||
- (ucs >= 0x7f && ucs <= 0x9f));
-}
-
-static int
-is_blockgraphics(int ucs)
-{
- return ucs >= 0x2500 && ucs <= 0x25FF;
-}
-
-/* calculate the bounding box that covers both provided bounding boxes */
-typedef struct {
- int cwidth;
- int cheight;
- int cxoff;
- int cyoff;
-} bbx_t;
-
-static bbx_t *
-combine_bbx(int awidth, int aheight, int axoff, int ayoff,
- int cwidth, int cheight, int cxoff, int cyoff, bbx_t *r)
-{
- r->cwidth = cwidth;
- r->cheight = cheight;
- r->cxoff = cxoff;
- r->cyoff = cyoff;
-
- if (axoff < r->cxoff) {
- r->cwidth += r->cxoff - axoff;
- r->cxoff = axoff;
- }
- if (ayoff < r->cyoff) {
- r->cheight += r->cyoff - ayoff;
- r->cyoff = ayoff;
- }
- if (awidth + axoff > r->cwidth + r->cxoff) {
- r->cwidth = awidth + axoff - r->cxoff;
- }
- if (aheight + ayoff > r->cheight + r->cyoff) {
- r->cheight = aheight + ayoff - r->cyoff;
- }
-
- return r;
-}
-
-static void
-usage(void) {
- printf("%s", "\n"
-"Usage: ucs2any [+d|-d] <source-name> { <mapping-file> <registry-encoding> }\n"
-"\n"
-"where\n"
-"\n"
-" +d put DEC VT100 graphics characters in the C0 range\n"
-" (default for upright charcell fonts)\n"
-"\n"
-" -d do not put DEC VT100 graphics characters in the\n"
-" C0 range (default for all other font types)\n"
-"\n"
-" <source-name> is the name of an ISO10646-1 encoded BDF file\n"
-"\n"
-" <mapping-file> is the name of a character set table like those on\n"
-" <ftp://ftp.unicode.org/Public/MAPPINGS/>\n"
-"\n"
-" <registry-encoding> are the CHARSET_REGISTRY and CHARSET_ENCODING\n"
-" field values for the font name (XLFD) of the\n"
-" target font, separated by a hyphen\n"
-"\n"
-"Example:\n"
-"\n"
-" ucs2any 6x13.bdf 8859-1.TXT iso8859-1 8859-2.TXT iso8859-2\n"
-"\n"
-"will generate the files 6x13-iso8859-1.bdf and 6x13-iso8859-2.bdf\n"
-"\n");
-}
-
-static int
-chars_compare(const void *aa, const void *bb)
-{
- int a = *(int *)aa;
- int b = *(int *)bb;
-
- return a - b;
-}
-
-/*
- * Return != 0 if "string" starts with "pattern" followed by whitespace.
- * If it does, return a pointer to the first non space char.
- */
-static const char *
-startswith(const char *string, const char *pattern)
-{
- int l = strlen(pattern);
-
- if (strlen(string) <= l) return NULL;
- if (strncmp(string, pattern, l) != 0) return NULL;
- string += l;
- if (!isspace(*string)) return NULL;
- while (isspace(*string))
- string++;
- return string;
-}
-
-int
-main(int argc, char *argv[])
-{
- int ai = 1;
- int dec_chars = -1;
- char *fsource = NULL;
- FILE *fsource_fp;
- int properties;
- int default_char;
- char *l = NULL;
- char *t = NULL;
- const char *nextc = NULL;
- char *startfont = NULL;
- char *slant = NULL;
- char *spacing = NULL;
- char *sc = NULL;
- int code = -1;
- da_t *startchar;
- da_t *my_char;
- char *fmap = NULL;
- char *registry = NULL;
- char *encoding = NULL;
- char *fontname = NULL;
- FILE *fmap_fp;
- da_t *map;
- da_t *headers;
- int nextheader = -1;
- int default_char_index = -1;
- int startproperties_index = -1;
- int fontname_index = -1;
- int charset_registry_index = -1;
- int slant_index = -1;
- int spacing_index = -1;
- int charset_encoding_index = -1;
- int fontboundingbox_index = -1;
- int target;
- int ucs;
- int i;
- int j;
- int *chars = NULL;
- bbx_t bbx;
- char *fout = NULL;
- FILE *fout_fp;
- int k;
- char *registry_encoding = NULL;
-
- my_name = argv[0];
- bbx.cheight = bbx.cxoff = bbx.cyoff = -1;
-
- startchar = da_new("startchar");
- my_char = da_new("my_char");
- map = da_new("map");
- headers = da_new("headers");
-
- if (argc < 2) {
- usage();
- exit(0);
- }
-
- /* check options */
- if (strcmp(argv[ai], "+d") == 0) {
- ai++;
- dec_chars = 1;
- } else if (strcmp(argv[ai], "-d") == 0) {
- ai++;
- dec_chars = 0;
- }
- if (ai >= argc) {
- usage();
- exit(0);
- }
-
- /* open and read source file */
- fsource = argv[ai];
- fsource_fp = fopen(fsource, "r");
- if (fsource_fp == NULL) {
- fprintf(stderr, "%s: Can't read file '%s': %s!\n", my_name,
- fsource, strerror(errno));
- exit(1);
- }
-
- /* read header */
- properties = 0;
- default_char = 0;
- while (read_line(fsource_fp, &l)) {
- if (startswith(l, "CHARS"))
- break;
- if (startswith(l, "STARTFONT")) {
- zstrcpy(&startfont, l);
- } else if (startswith(l, "_XMBDFED_INFO") ||
- startswith(l, "XFREE86_GLYPH_RANGES"))
- {
- properties--;
- } else if ((nextc = startswith(l, "DEFAULT_CHAR")) != NULL)
- {
- default_char = atoi(nextc);
- default_char_index = ++nextheader;
- da_add_str(headers, default_char_index, NULL);
- } else {
- if ((nextc = startswith(l, "STARTPROPERTIES")) != NULL)
- {
- properties = atoi(nextc);
- startproperties_index = ++nextheader;
- da_add_str(headers, startproperties_index, NULL);
- } else if ((nextc = startswith(l, "FONT")) != NULL)
- {
- char * term;
- /* slightly simplistic check ... */
- zquotedcpy(&fontname, nextc);
- if ((term = strstr(fontname, "-ISO10646-1")) == NULL) {
- fprintf(stderr,
- "%s: FONT name in '%s' is '%s' and not '*-ISO10646-1'!\n",
- my_name, fsource, fontname);
- exit(1);
- }
- *term = '\0';
- fontname_index = ++nextheader;
- da_add_str(headers, fontname_index, NULL);
- } else if ((nextc = startswith(l, "CHARSET_REGISTRY")) != NULL)
- {
- if (strcmp(nextc, "\"ISO10646\"") != 0) {
- fprintf(stderr,
- "%s: CHARSET_REGISTRY in '%s' is '%s' and not 'ISO10646'!\n",
- my_name, fsource, nextc);
- exit(1);
- }
- charset_registry_index = ++nextheader;
- da_add_str(headers, charset_registry_index, NULL);
- } else if ((nextc = startswith(l, "CHARSET_ENCODING")) != NULL)
- {
- if (strcmp(nextc, "\"1\"") != 0) {
- fprintf(stderr,
- "%s: CHARSET_ENCODING in '%s' is '%s' and not '1'!\n",
- my_name, fsource, nextc);
- exit(1);
- }
- charset_encoding_index = ++nextheader;
- da_add_str(headers, charset_encoding_index, NULL);
- } else if (startswith(l, "FONTBOUNDINGBOX")) {
- fontboundingbox_index = ++nextheader;
- da_add_str(headers, fontboundingbox_index, NULL);
- } else if ((nextc = startswith(l, "SLANT")) != NULL)
- {
- zquotedcpy(&slant, nextc);
- slant_index = ++nextheader;
- da_add_str(headers, slant_index, NULL);
- } else if ((nextc = startswith(l, "SPACING")) != NULL)
- {
- zquotedcpy(&spacing, nextc);
- zstrtoupper(spacing);
- spacing_index = ++nextheader;
- da_add_str(headers, spacing_index, NULL);
- } else if ((nextc = startswith(l, "COMMENT")) != NULL) {
- if (strncmp(nextc, "$Id: ", 5)==0) {
- char *header = NULL;
- char *id = NULL, *end = NULL;
- id = zstrdup(nextc + 5);
- end = strrchr(id, '$');
- if (end) *end = '\0';
- zstrcpy(&header, "COMMENT Derived from ");
- zstrcat(&header, id);
- zstrcat(&header, "\n");
- free(id);
- da_add_str(headers, ++nextheader, header);
- free(header);
- } else {
- da_add_str(headers, ++nextheader, l);
- }
- } else {
- da_add_str(headers, ++nextheader, l);
- }
- }
- free(l);
- }
-
- if (startfont == NULL) {
- fprintf(stderr, "%s: No STARTFONT line found in '%s'!\n",
- my_name, fsource);
- exit(1);
- }
-
- /* read characters */
- while (read_line(fsource_fp, &l)) {
- if (startswith(l, "STARTCHAR")) {
- zstrcpy(&sc, l);
- zstrcat(&sc, "\n");
- code = -1;
- } else if ((nextc = startswith(l, "ENCODING")) != NULL) {
- code = atoi(nextc);
- da_add_str(startchar, code, sc);
- da_add_str(my_char, code, "");
- } else if (strcmp(l, "ENDFONT")==0) {
- code = -1;
- zstrcpy(&sc, "STARTCHAR ???\n");
- } else {
- zstrcpy(&t, da_fetch_str(my_char, code));
- zstrcat(&t, l);
- zstrcat(&t, "\n");
- da_add_str(my_char, code, t);
- if (strcmp(l, "ENDCHAR")==0) {
- code = -1;
- zstrcpy(&sc, "STARTCHAR ???\n");
- }
- }
- free(l);
- }
-
- fclose(fsource_fp);
-
- ai++;
- while (ai < argc) {
- zstrcpy(&fmap, argv[ai]);
- i = ai + 1;
- if (i < argc) {
- char *temp = NULL;
- char * hyphen = strchr(argv[i], '-');
- if (!hyphen || strchr(hyphen+1, '-') != NULL) {
- fprintf(stderr,
- "%s: Argument registry-encoding '%s' not in expected format!\n",
- my_name, i < argc ? fmap : "");
- exit(1);
- }
- temp = zstrdup(argv[i]);
- hyphen = strchr(temp, '-');
- if (hyphen) *hyphen = 0;
- zstrcpy(&registry, temp);
- zstrcpy(&encoding, hyphen+1);
- free(temp);
- } else {
- fprintf(stderr, "map file argument \"%s\" needs a "
- "coresponding registry-encoding argument\n", fmap);
- exit(0);
- }
-
- ai++;
- ai++;
-
- /* open and read source file */
- fmap_fp = fopen(fmap, "r");
- if (fmap_fp == NULL) {
- fprintf(stderr,
- "%s: Can't read mapping file '%s': %s!\n",
- my_name, fmap, strerror(errno));
- exit(1);
- }
-
- da_clear(map);
-
- for (;read_line(fmap_fp, &l); free(l)) {
- char *p, *endp;
-
- for (p = l; isspace(p[0]); p++)
- ;
- if (p[0] == '\0' || p[0] == '#')
- continue;
- if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
- target = strtol(p+2, &endp, 16);
- if (*endp == '\0') goto bad;
- p = endp;
- } else
- goto bad;
- for (; isspace(p[0]); p++)
- ;
- if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
- ucs = strtol(p+2, &endp, 16);
- if (*endp == '\0') goto bad;
- p = endp;
- } else
- goto bad;
-
- if (!is_control(ucs)) {
- if (zs_true(da_fetch_str(startchar, ucs)))
- {
- da_add_int(map, target, ucs);
- } else {
- if (!((is_blockgraphics(ucs) &&
- strcmp(slant, "R") != 0) ||
- (ucs >= 0x200e &&
- ucs <= 0x200f))) {
- fprintf(stderr,
- "No glyph for character U+%04X (0x%02x) available.\n",
- ucs, target);
- }
- }
- }
- continue;
- bad:
- fprintf(stderr, "Unrecognized line in '%s':\n%s\n", fmap, l);
- }
- fclose(fmap_fp);
-
- /* add default character */
- if (!zi_true(da_fetch_int(map, 0))) {
- if (zs_true(da_fetch_str(startchar, default_char))) {
- da_add_int(map, 0, default_char);
- da_add_str(startchar, default_char,
- "STARTCHAR defaultchar\n");
- } else {
- fprintf(stderr, "%s",
- "No default character defined.\n");
- }
- }
-
- if (dec_chars == 1 ||
- (dec_chars == -1 && strcmp(slant, "R") == 0 &&
- strcmp(spacing, "C") == 0))
- {
- /* add DEC VT100 graphics characters in the range 1-31
- (as expected by some old xterm versions) */
- for (i = 0; i < decmap_size; i++) {
- if (zs_true(da_fetch_str(startchar, decmap[i])))
- {
- da_add_int(map, i + 1, decmap[i]);
- }
- }
- }
-
- /* list of characters that will be written out */
- j = da_count(map);
- if (j < 0) {
- fprintf(stderr,
- "No characters found for %s-%s.\n",
- registry, encoding);
- continue;
- }
- if (chars != NULL)
- free(chars);
- chars = zmalloc(j * sizeof(int));
- memset(chars, 0, j * sizeof(int));
- for (k = 0, i = 0; k < da_count(map) && i < da_size(map); i++) {
- if (da_fetch(map, i) != NULL)
- chars[k++] = i;
- }
- qsort(chars, j, sizeof(int), chars_compare);
-
- /* find overall font bounding box */
- bbx.cwidth = -1;
- for (i = 0; i < j; i++) {
- ucs = da_fetch_int(map, chars[i]);
- zstrcpy(&t, da_fetch_str(my_char, ucs));
- if ((nextc = startswith(t, "BBX")) != NULL
- || (nextc = strstr(t, "\nBBX")) != NULL)
- {
- char *endp;
- long w, h, x, y;
-
- if (*nextc == '\n') {
- nextc += 4;
- while (isspace(*nextc))
- nextc++;
- }
- for (;isspace(*nextc);)
- nextc++;
- w = strtol(nextc, &endp, 10);
- nextc = endp;
- if (*nextc == '\0') goto bbxbad;
- for (;isspace(*nextc);)
- nextc++;
- h = strtol(nextc, &endp, 10);
- nextc = endp;
- if (*nextc == '\0') goto bbxbad;
- for (;isspace(*nextc);)
- nextc++;
- x = strtol(nextc, &endp, 10);
- nextc = endp;
- if (*nextc == '\0') goto bbxbad;
- for (;isspace(*nextc);)
- nextc++;
- y = strtol(nextc, &endp, 10);
- if (bbx.cwidth == -1) {
- bbx.cwidth = w;
- bbx.cheight = h;
- bbx.cxoff = x;
- bbx.cyoff = y;
- } else {
- combine_bbx(bbx.cwidth, bbx.cheight,
- bbx.cxoff, bbx.cyoff,
- w, h, x, y, &bbx);
- }
- continue;
- bbxbad:
- fprintf(stderr, "Unparsable BBX found for U+%04x!\n", ucs);
- } else {
- fprintf(stderr,
- "Warning: No BBX found for U+%04X!\n",
- ucs);
- }
- }
-
- if (!registry) registry = zstrdup("");
- if (!encoding) encoding = zstrdup("");
-
- /* generate output file name */
- zstrcpy(&registry_encoding, "-");
- zstrcat(&registry_encoding, registry);
- zstrcat(&registry_encoding, "-");
- zstrcat(&registry_encoding, encoding);
-
- {
- char * p = strstr(fsource, ".bdf");
- if (p) {
- zstrcpy(&fout, fsource);
- p = strstr(fout, ".bdf");
- *p = 0;
- zstrcat(&fout, registry_encoding);
- zstrcat(&fout, ".bdf");
- } else {
- zstrcpy(&fout, fsource);
- zstrcat(&fout, registry_encoding);
- }
- }
-
- /* remove path prefix */
- zstrcpy(&t, basename(fout));
- zstrcpy(&fout, t);
-
- /* write new BDF file */
- fprintf(stderr, "Writing %d characters into file '%s'.\n",
- j, fout);
- fout_fp = fopen(fout, "w");
- if (fout_fp == NULL) {
- fprintf(stderr, "%s: Can't write file '%s': %s!\n",
- my_name, fout, strerror(errno));
- exit(1);
- }
-
- fprintf(fout_fp, "%s\n", startfont);
- fprintf(fout_fp, "%s",
- "COMMENT AUTOMATICALLY GENERATED FILE. DO NOT EDIT!\n");
- fprintf(fout_fp,
- "COMMENT Generated with 'ucs2any %s %s %s-%s'\n",
- fsource, fmap, registry, encoding);
- fprintf(fout_fp, "%s",
- "COMMENT from an ISO10646-1 encoded source BDF font.\n");
- fprintf(fout_fp, "%s",
- "COMMENT ucs2any by Ben Collver <collver1@attbi.com>, 2003, based on\n");
- fprintf(fout_fp, "%s",
- "COMMENT ucs2any.pl by Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/>, 2000.\n");
-
- for (i = 0; i <= nextheader; i++) {
- if (i == default_char_index)
- fprintf(fout_fp, "DEFAULT_CHAR %d\n", default_char);
- else if (i == startproperties_index)
- fprintf(fout_fp, "STARTPROPERTIES %d\n", properties);
- else if (i == fontname_index) {
- fprintf(fout_fp, "FONT %s%s\n", fontname, registry_encoding);
- }
- else if (i == charset_registry_index)
- fprintf(fout_fp, "CHARSET_REGISTRY \"%s\"\n", registry);
- else if (i == slant_index)
- fprintf(fout_fp, "SLANT \"%s\"\n", slant);
- else if (i == charset_encoding_index)
- fprintf(fout_fp, "CHARSET_ENCODING \"%s\"\n", encoding);
- else if (i == fontboundingbox_index)
- fprintf(fout_fp, "FONTBOUNDINGBOX %d %d %d %d\n", bbx.cwidth, bbx.cheight, bbx.cxoff, bbx.cyoff);
- else if (i == spacing_index)
- fprintf(fout_fp, "SPACING \"%s\"\n", spacing);
- else
- fprintf(fout_fp, "%s\n", da_fetch_str(headers, i));
- }
-
- fprintf(fout_fp, "CHARS %d\n", j);
-
- /* Write characters */
- for (i = 0; i < j; i++) {
- ucs = da_fetch_int(map, chars[i]);
- fprintf(fout_fp, "%s", da_fetch_str(startchar,
- ucs));
- fprintf(fout_fp, "ENCODING %d\n", chars[i]);
- fprintf(fout_fp, "%s", da_fetch_str(my_char,
- ucs));
- }
- fprintf(fout_fp, "%s", "ENDFONT\n");
- fclose(fout_fp);
- }
-
- exit(0);
-}
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ben Collver <collver1@attbi.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * This utility allows you to generate from an ISO10646-1 encoded
+ * BDF font other BDF fonts in any possible encoding. This way, you can
+ * derive from a single ISO10646-1 master font a whole set of 8-bit
+ * fonts in all ISO 8859 and various other encodings. (Hopefully
+ * a future XFree86 release will have a similar facility built into
+ * the server, which can reencode ISO10646-1 on the fly, because
+ * storing the same fonts in many different encodings is clearly
+ * a waste of storage capacity).
+*/
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#if !defined(NEED_BASENAME) && !defined(Lynx)
+#include <libgen.h>
+#endif
+#include <limits.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* global variable for argv[0] */
+static const char *my_name = NULL;
+
+#ifdef NEED_BASENAME
+static char *
+basename(char *pathname)
+{
+ char *ptr;
+
+ ptr = strrchr(pathname, '/');
+ return ((ptr == NULL) ? pathname : &ptr[1]);
+}
+#endif
+
+/* "CLASS" "z" string and memory manipulation */
+
+static void *
+zmalloc(size_t size)
+{
+ void *r;
+ r = malloc(size);
+ if (r == NULL) {
+ perror(my_name);
+ exit(errno);
+ }
+ memset(r, 0, size);
+ return r;
+}
+
+static void *
+zrealloc(void *ptr, size_t size)
+{
+ void *temp;
+ temp = realloc(ptr, size);
+ if (temp == NULL) {
+ perror(my_name);
+ exit(errno);
+ }
+ return temp;
+}
+
+static char *
+zstrdup(const char *str)
+{
+ char *retval;
+
+ if (str == NULL) {
+ fprintf(stderr, "%s: zstrdup(NULL)\n", my_name);
+ exit(1);
+ }
+ retval = strdup(str);
+ if (retval == NULL) {
+ perror(my_name);
+ exit(errno);
+ }
+ return retval;
+}
+
+static void
+zstrcpy(char **dest, const char *source)
+{
+ if (*dest != NULL)
+ free(*dest);
+ *dest = zstrdup(source);
+}
+
+static void
+zquotedcpy(char **dest, const char *source)
+{
+ const char *start, *end;
+
+ if (*dest != NULL)
+ free(*dest);
+ *dest = NULL;
+ start = source;
+ if (*start == '"') {
+ start = source+1;
+ end = strrchr(start, '"');
+ if (!end) return;
+ *dest = zmalloc(end-start+1);
+ strncpy(*dest, start, end-start);
+ (*dest)[end-start] = '\0';
+ } else {
+ *dest = zstrdup(source);
+ }
+}
+
+static void
+zstrcat(char **dest, const char *source)
+{
+ int dest_size = 1;
+ int source_size;
+
+ if (*dest != NULL)
+ dest_size = strlen(*dest) + 1;
+ source_size = strlen(source);
+ *dest = zrealloc(*dest, dest_size + source_size);
+ strcpy(*dest + dest_size - 1, source);
+}
+
+static void
+zstrtoupper(char *s)
+{
+ char *t;
+
+ for (t = s; *t != '\000'; t++)
+ *t = toupper(*t);
+}
+
+#define zs_true(x) (x != NULL && strcmp(x, "0") != 0)
+#define zi_true(x) (x == 1)
+
+/* "CLASS" "dynamic array" */
+
+typedef struct {
+ char *name;
+ int size;
+ int count;
+ void **values;
+ void *nv;
+} da_t;
+
+static da_t *
+da_new(char *name)
+{
+ da_t *da;
+
+ da = zmalloc(sizeof(da_t));
+ da->size = 0;
+ da->count = 0;
+ da->values = NULL;
+ da->nv = NULL;
+ da->name = NULL;
+ zstrcpy(&(da->name), name);
+ return da;
+}
+
+static void *
+da_fetch(da_t *da, int key)
+{
+ void *r = NULL;
+
+ if (key >= 0 && key < da->size && da->values[key] != NULL)
+ r = da->values[key];
+ else
+ if (key == -1 && da->nv != NULL)
+ r = da->nv;
+
+ return r;
+}
+
+static int
+da_fetch_int(da_t *da, int key)
+{
+ int *t;
+ int r = -1;
+ t = da_fetch(da, key);
+ if (t != NULL)
+ r = *t;
+ return r;
+}
+
+#define da_fetch_str(a,k) \
+ (char *)da_fetch(a,k)
+
+static void
+da_add(da_t *da, int key, void *value)
+{
+ int i = da->size;
+ if (key >= 0) {
+ if (key >= da->size) {
+ da->size = key + 1;
+ da->values = zrealloc(da->values,
+ da->size * sizeof(void *));
+ for (; i < da->size; i++)
+ da->values[i] = NULL;
+ }
+ if (da->values[key] != NULL) {
+ free(da->values[key]);
+ } else {
+ if (value == NULL) {
+ if (da->count > 0)
+ da->count--;
+ } else {
+ da->count++;
+ }
+ }
+ da->values[key] = value;
+ } else if (key == -1) {
+ if (da->nv != NULL)
+ free(da->nv);
+ da->nv = value;
+ }
+}
+
+static void
+da_add_str(da_t *da, int key, char *value)
+{
+ da_add(da, key, value?zstrdup(value):NULL);
+}
+
+static void
+da_add_int(da_t *da, int key, int value)
+{
+ int *v;
+
+ v = zmalloc(sizeof(int));
+ *v = value;
+ da_add(da, key, v);
+}
+
+#define da_count(da) (da->count)
+#define da_size(da) (da->size)
+
+static void
+da_clear(da_t *da)
+{
+ int i;
+
+ for (i = da->size; i; i--)
+ free(da->values[i]);
+ if (da->values != NULL)
+ free(da->values);
+ da->size = 0;
+ da->count = 0;
+ da->values = NULL;
+}
+
+/* "CLASS" file input */
+
+#define TYPICAL_LINE_SIZE (80)
+
+/* read a line and strip trailing whitespace */
+static int
+read_line(FILE *fp, char **buffer)
+{
+ int buffer_size = TYPICAL_LINE_SIZE;
+ int eof = 0;
+ int position = 0;
+ int c;
+
+ *buffer = zmalloc(TYPICAL_LINE_SIZE);
+ (*buffer)[0] = '\0';
+
+ if ((c = getc(fp)) == EOF)
+ eof = 1;
+
+ while (c != '\n' && !eof) {
+ if (position + 1 >= buffer_size) {
+ buffer_size = buffer_size * 2 + 1;
+ *buffer = zrealloc(*buffer, buffer_size);
+ }
+ (*buffer)[position++] = c;
+ (*buffer)[position] = '\0';
+ c = getc(fp);
+ if (c == EOF)
+ eof = 1;
+ }
+
+ if (eof) {
+ free(*buffer);
+ *buffer = NULL;
+ return 0;
+ }
+
+ while (position > 1) {
+ position--;
+ if (!isspace((*buffer)[position]))
+ break;
+ (*buffer)[position] = '\0';
+ }
+
+ return 1;
+}
+
+/* BEGIN */
+
+/*
+DEC VT100 graphics characters in the range 1-31 (as expected by
+some old xterm versions and a few other applications)
+*/
+#define decmap_size 31
+static int decmap[decmap_size] = {
+ 0x25C6, /* BLACK DIAMOND */
+ 0x2592, /* MEDIUM SHADE */
+ 0x2409, /* SYMBOL FOR HORIZONTAL TABULATION */
+ 0x240C, /* SYMBOL FOR FORM FEED */
+ 0x240D, /* SYMBOL FOR CARRIAGE RETURN */
+ 0x240A, /* SYMBOL FOR LINE FEED */
+ 0x00B0, /* DEGREE SIGN */
+ 0x00B1, /* PLUS-MINUS SIGN */
+ 0x2424, /* SYMBOL FOR NEWLINE */
+ 0x240B, /* SYMBOL FOR VERTICAL TABULATION */
+ 0x2518, /* BOX DRAWINGS LIGHT UP AND LEFT */
+ 0x2510, /* BOX DRAWINGS LIGHT DOWN AND LEFT */
+ 0x250C, /* BOX DRAWINGS LIGHT DOWN AND RIGHT */
+ 0x2514, /* BOX DRAWINGS LIGHT UP AND RIGHT */
+ 0x253C, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
+ 0x23BA, /* HORIZONTAL SCAN LINE-1 (Unicode 3.2 draft) */
+ 0x23BB, /* HORIZONTAL SCAN LINE-3 (Unicode 3.2 draft) */
+ 0x2500, /* BOX DRAWINGS LIGHT HORIZONTAL */
+ 0x23BC, /* HORIZONTAL SCAN LINE-7 (Unicode 3.2 draft) */
+ 0x23BD, /* HORIZONTAL SCAN LINE-9 (Unicode 3.2 draft) */
+ 0x251C, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
+ 0x2524, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT */
+ 0x2534, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL */
+ 0x252C, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
+ 0x2502, /* BOX DRAWINGS LIGHT VERTICAL */
+ 0x2264, /* LESS-THAN OR EQUAL TO */
+ 0x2265, /* GREATER-THAN OR EQUAL TO */
+ 0x03C0, /* GREEK SMALL LETTER PI */
+ 0x2260, /* NOT EQUAL TO */
+ 0x00A3, /* POUND SIGN */
+ 0x00B7 /* MIDDLE DOT */
+};
+
+static int
+is_control(int ucs)
+{
+ return ((ucs >= 0x00 && ucs <= 0x1f) ||
+ (ucs >= 0x7f && ucs <= 0x9f));
+}
+
+static int
+is_blockgraphics(int ucs)
+{
+ return ucs >= 0x2500 && ucs <= 0x25FF;
+}
+
+/* calculate the bounding box that covers both provided bounding boxes */
+typedef struct {
+ int cwidth;
+ int cheight;
+ int cxoff;
+ int cyoff;
+} bbx_t;
+
+static bbx_t *
+combine_bbx(int awidth, int aheight, int axoff, int ayoff,
+ int cwidth, int cheight, int cxoff, int cyoff, bbx_t *r)
+{
+ r->cwidth = cwidth;
+ r->cheight = cheight;
+ r->cxoff = cxoff;
+ r->cyoff = cyoff;
+
+ if (axoff < r->cxoff) {
+ r->cwidth += r->cxoff - axoff;
+ r->cxoff = axoff;
+ }
+ if (ayoff < r->cyoff) {
+ r->cheight += r->cyoff - ayoff;
+ r->cyoff = ayoff;
+ }
+ if (awidth + axoff > r->cwidth + r->cxoff) {
+ r->cwidth = awidth + axoff - r->cxoff;
+ }
+ if (aheight + ayoff > r->cheight + r->cyoff) {
+ r->cheight = aheight + ayoff - r->cyoff;
+ }
+
+ return r;
+}
+
+static void
+usage(void) {
+ printf("%s", "\n"
+"Usage: ucs2any [+d|-d] <source-name> { <mapping-file> <registry-encoding> }\n"
+"\n"
+"where\n"
+"\n"
+" +d put DEC VT100 graphics characters in the C0 range\n"
+" (default for upright charcell fonts)\n"
+"\n"
+" -d do not put DEC VT100 graphics characters in the\n"
+" C0 range (default for all other font types)\n"
+"\n"
+" <source-name> is the name of an ISO10646-1 encoded BDF file\n"
+"\n"
+" <mapping-file> is the name of a character set table like those on\n"
+" <ftp://ftp.unicode.org/Public/MAPPINGS/>\n"
+"\n"
+" <registry-encoding> are the CHARSET_REGISTRY and CHARSET_ENCODING\n"
+" field values for the font name (XLFD) of the\n"
+" target font, separated by a hyphen\n"
+"\n"
+"Example:\n"
+"\n"
+" ucs2any 6x13.bdf 8859-1.TXT iso8859-1 8859-2.TXT iso8859-2\n"
+"\n"
+"will generate the files 6x13-iso8859-1.bdf and 6x13-iso8859-2.bdf\n"
+"\n");
+}
+
+static int
+chars_compare(const void *aa, const void *bb)
+{
+ int a = *(int *)aa;
+ int b = *(int *)bb;
+
+ return a - b;
+}
+
+/*
+ * Return != 0 if "string" starts with "pattern" followed by whitespace.
+ * If it does, return a pointer to the first non space char.
+ */
+static const char *
+startswith(const char *string, const char *pattern)
+{
+ int l = strlen(pattern);
+
+ if (strlen(string) <= l) return NULL;
+ if (strncmp(string, pattern, l) != 0) return NULL;
+ string += l;
+ if (!isspace(*string)) return NULL;
+ while (isspace(*string))
+ string++;
+ return string;
+}
+
+int
+main(int argc, char *argv[])
+{
+ int ai = 1;
+ int dec_chars = -1;
+ char *fsource = NULL;
+ FILE *fsource_fp;
+ int properties;
+ int default_char;
+ char *l = NULL;
+ char *t = NULL;
+ const char *nextc = NULL;
+ char *startfont = NULL;
+ char *slant = NULL;
+ char *spacing = NULL;
+ char *sc = NULL;
+ int code = -1;
+ da_t *startchar;
+ da_t *my_char;
+ char *fmap = NULL;
+ char *registry = NULL;
+ char *encoding = NULL;
+ char *fontname = NULL;
+ FILE *fmap_fp;
+ da_t *map;
+ da_t *headers;
+ int nextheader = -1;
+ int default_char_index = -1;
+ int startproperties_index = -1;
+ int fontname_index = -1;
+ int charset_registry_index = -1;
+ int slant_index = -1;
+ int spacing_index = -1;
+ int charset_encoding_index = -1;
+ int fontboundingbox_index = -1;
+ int target;
+ int ucs;
+ int i;
+ int j;
+ int *chars = NULL;
+ bbx_t bbx;
+ char *fout = NULL;
+ FILE *fout_fp;
+ int k;
+ char *registry_encoding = NULL;
+
+ my_name = argv[0];
+ bbx.cheight = bbx.cxoff = bbx.cyoff = -1;
+
+ startchar = da_new("startchar");
+ my_char = da_new("my_char");
+ map = da_new("map");
+ headers = da_new("headers");
+
+ if (argc < 2) {
+ usage();
+ exit(0);
+ }
+
+ /* check options */
+ if (strcmp(argv[ai], "+d") == 0) {
+ ai++;
+ dec_chars = 1;
+ } else if (strcmp(argv[ai], "-d") == 0) {
+ ai++;
+ dec_chars = 0;
+ }
+ if (ai >= argc) {
+ usage();
+ exit(0);
+ }
+
+ /* open and read source file */
+ fsource = argv[ai];
+ fsource_fp = fopen(fsource, "r");
+ if (fsource_fp == NULL) {
+ fprintf(stderr, "%s: Can't read file '%s': %s!\n", my_name,
+ fsource, strerror(errno));
+ exit(1);
+ }
+
+ /* read header */
+ properties = 0;
+ default_char = 0;
+ while (read_line(fsource_fp, &l)) {
+ if (startswith(l, "CHARS"))
+ break;
+ if (startswith(l, "STARTFONT")) {
+ zstrcpy(&startfont, l);
+ } else if (startswith(l, "_XMBDFED_INFO") ||
+ startswith(l, "XFREE86_GLYPH_RANGES"))
+ {
+ properties--;
+ } else if ((nextc = startswith(l, "DEFAULT_CHAR")) != NULL)
+ {
+ default_char = atoi(nextc);
+ default_char_index = ++nextheader;
+ da_add_str(headers, default_char_index, NULL);
+ } else {
+ if ((nextc = startswith(l, "STARTPROPERTIES")) != NULL)
+ {
+ properties = atoi(nextc);
+ startproperties_index = ++nextheader;
+ da_add_str(headers, startproperties_index, NULL);
+ } else if ((nextc = startswith(l, "FONT")) != NULL)
+ {
+ char * term;
+ /* slightly simplistic check ... */
+ zquotedcpy(&fontname, nextc);
+ if ((term = strstr(fontname, "-ISO10646-1")) == NULL) {
+ fprintf(stderr,
+ "%s: FONT name in '%s' is '%s' and not '*-ISO10646-1'!\n",
+ my_name, fsource, fontname);
+ exit(1);
+ }
+ *term = '\0';
+ fontname_index = ++nextheader;
+ da_add_str(headers, fontname_index, NULL);
+ } else if ((nextc = startswith(l, "CHARSET_REGISTRY")) != NULL)
+ {
+ if (strcmp(nextc, "\"ISO10646\"") != 0) {
+ fprintf(stderr,
+ "%s: CHARSET_REGISTRY in '%s' is '%s' and not 'ISO10646'!\n",
+ my_name, fsource, nextc);
+ exit(1);
+ }
+ charset_registry_index = ++nextheader;
+ da_add_str(headers, charset_registry_index, NULL);
+ } else if ((nextc = startswith(l, "CHARSET_ENCODING")) != NULL)
+ {
+ if (strcmp(nextc, "\"1\"") != 0) {
+ fprintf(stderr,
+ "%s: CHARSET_ENCODING in '%s' is '%s' and not '1'!\n",
+ my_name, fsource, nextc);
+ exit(1);
+ }
+ charset_encoding_index = ++nextheader;
+ da_add_str(headers, charset_encoding_index, NULL);
+ } else if (startswith(l, "FONTBOUNDINGBOX")) {
+ fontboundingbox_index = ++nextheader;
+ da_add_str(headers, fontboundingbox_index, NULL);
+ } else if ((nextc = startswith(l, "SLANT")) != NULL)
+ {
+ zquotedcpy(&slant, nextc);
+ slant_index = ++nextheader;
+ da_add_str(headers, slant_index, NULL);
+ } else if ((nextc = startswith(l, "SPACING")) != NULL)
+ {
+ zquotedcpy(&spacing, nextc);
+ zstrtoupper(spacing);
+ spacing_index = ++nextheader;
+ da_add_str(headers, spacing_index, NULL);
+ } else if ((nextc = startswith(l, "COMMENT")) != NULL) {
+ if (strncmp(nextc, "$Id: ", 5)==0) {
+ char *header = NULL;
+ char *id = NULL, *end = NULL;
+ id = zstrdup(nextc + 5);
+ end = strrchr(id, '$');
+ if (end) *end = '\0';
+ zstrcpy(&header, "COMMENT Derived from ");
+ zstrcat(&header, id);
+ zstrcat(&header, "\n");
+ free(id);
+ da_add_str(headers, ++nextheader, header);
+ free(header);
+ } else {
+ da_add_str(headers, ++nextheader, l);
+ }
+ } else {
+ da_add_str(headers, ++nextheader, l);
+ }
+ }
+ free(l);
+ }
+
+ if (startfont == NULL) {
+ fprintf(stderr, "%s: No STARTFONT line found in '%s'!\n",
+ my_name, fsource);
+ exit(1);
+ }
+
+ /* read characters */
+ while (read_line(fsource_fp, &l)) {
+ if (startswith(l, "STARTCHAR")) {
+ zstrcpy(&sc, l);
+ zstrcat(&sc, "\n");
+ code = -1;
+ } else if ((nextc = startswith(l, "ENCODING")) != NULL) {
+ code = atoi(nextc);
+ da_add_str(startchar, code, sc);
+ da_add_str(my_char, code, "");
+ } else if (strcmp(l, "ENDFONT")==0) {
+ code = -1;
+ zstrcpy(&sc, "STARTCHAR ???\n");
+ } else {
+ zstrcpy(&t, da_fetch_str(my_char, code));
+ zstrcat(&t, l);
+ zstrcat(&t, "\n");
+ da_add_str(my_char, code, t);
+ if (strcmp(l, "ENDCHAR")==0) {
+ code = -1;
+ zstrcpy(&sc, "STARTCHAR ???\n");
+ }
+ }
+ free(l);
+ }
+
+ fclose(fsource_fp);
+
+ ai++;
+ while (ai < argc) {
+ zstrcpy(&fmap, argv[ai]);
+ i = ai + 1;
+ if (i < argc) {
+ char *temp = NULL;
+ char * hyphen = strchr(argv[i], '-');
+ if (!hyphen || strchr(hyphen+1, '-') != NULL) {
+ fprintf(stderr,
+ "%s: Argument registry-encoding '%s' not in expected format!\n",
+ my_name, i < argc ? fmap : "");
+ exit(1);
+ }
+ temp = zstrdup(argv[i]);
+ hyphen = strchr(temp, '-');
+ if (hyphen) *hyphen = 0;
+ zstrcpy(&registry, temp);
+ zstrcpy(&encoding, hyphen+1);
+ free(temp);
+ } else {
+ fprintf(stderr, "map file argument \"%s\" needs a "
+ "coresponding registry-encoding argument\n", fmap);
+ exit(0);
+ }
+
+ ai++;
+ ai++;
+
+ /* open and read source file */
+ fmap_fp = fopen(fmap, "r");
+ if (fmap_fp == NULL) {
+ fprintf(stderr,
+ "%s: Can't read mapping file '%s': %s!\n",
+ my_name, fmap, strerror(errno));
+ exit(1);
+ }
+
+ da_clear(map);
+
+ for (;read_line(fmap_fp, &l); free(l)) {
+ char *p, *endp;
+
+ for (p = l; isspace(p[0]); p++)
+ ;
+ if (p[0] == '\0' || p[0] == '#')
+ continue;
+ if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+ target = strtol(p+2, &endp, 16);
+ if (*endp == '\0') goto bad;
+ p = endp;
+ } else
+ goto bad;
+ for (; isspace(p[0]); p++)
+ ;
+ if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
+ ucs = strtol(p+2, &endp, 16);
+ if (*endp == '\0') goto bad;
+ p = endp;
+ } else
+ goto bad;
+
+ if (!is_control(ucs)) {
+ if (zs_true(da_fetch_str(startchar, ucs)))
+ {
+ da_add_int(map, target, ucs);
+ } else {
+ if (!((is_blockgraphics(ucs) &&
+ strcmp(slant, "R") != 0) ||
+ (ucs >= 0x200e &&
+ ucs <= 0x200f))) {
+ fprintf(stderr,
+ "No glyph for character U+%04X (0x%02x) available.\n",
+ ucs, target);
+ }
+ }
+ }
+ continue;
+ bad:
+ fprintf(stderr, "Unrecognized line in '%s':\n%s\n", fmap, l);
+ }
+ fclose(fmap_fp);
+
+ /* add default character */
+ if (!zi_true(da_fetch_int(map, 0))) {
+ if (zs_true(da_fetch_str(startchar, default_char))) {
+ da_add_int(map, 0, default_char);
+ da_add_str(startchar, default_char,
+ "STARTCHAR defaultchar\n");
+ } else {
+ fprintf(stderr, "%s",
+ "No default character defined.\n");
+ }
+ }
+
+ if (dec_chars == 1 ||
+ (dec_chars == -1 && strcmp(slant, "R") == 0 &&
+ strcmp(spacing, "C") == 0))
+ {
+ /* add DEC VT100 graphics characters in the range 1-31
+ (as expected by some old xterm versions) */
+ for (i = 0; i < decmap_size; i++) {
+ if (zs_true(da_fetch_str(startchar, decmap[i])))
+ {
+ da_add_int(map, i + 1, decmap[i]);
+ }
+ }
+ }
+
+ /* list of characters that will be written out */
+ j = da_count(map);
+ if (j < 0) {
+ fprintf(stderr,
+ "No characters found for %s-%s.\n",
+ registry, encoding);
+ continue;
+ }
+ if (chars != NULL)
+ free(chars);
+ chars = zmalloc(j * sizeof(int));
+ memset(chars, 0, j * sizeof(int));
+ for (k = 0, i = 0; k < da_count(map) && i < da_size(map); i++) {
+ if (da_fetch(map, i) != NULL)
+ chars[k++] = i;
+ }
+ qsort(chars, j, sizeof(int), chars_compare);
+
+ /* find overall font bounding box */
+ bbx.cwidth = -1;
+ for (i = 0; i < j; i++) {
+ ucs = da_fetch_int(map, chars[i]);
+ zstrcpy(&t, da_fetch_str(my_char, ucs));
+ if ((nextc = startswith(t, "BBX")) != NULL
+ || (nextc = strstr(t, "\nBBX")) != NULL)
+ {
+ char *endp;
+ long w, h, x, y;
+
+ if (*nextc == '\n') {
+ nextc += 4;
+ while (isspace(*nextc))
+ nextc++;
+ }
+ for (;isspace(*nextc);)
+ nextc++;
+ w = strtol(nextc, &endp, 10);
+ nextc = endp;
+ if (*nextc == '\0') goto bbxbad;
+ for (;isspace(*nextc);)
+ nextc++;
+ h = strtol(nextc, &endp, 10);
+ nextc = endp;
+ if (*nextc == '\0') goto bbxbad;
+ for (;isspace(*nextc);)
+ nextc++;
+ x = strtol(nextc, &endp, 10);
+ nextc = endp;
+ if (*nextc == '\0') goto bbxbad;
+ for (;isspace(*nextc);)
+ nextc++;
+ y = strtol(nextc, &endp, 10);
+ if (bbx.cwidth == -1) {
+ bbx.cwidth = w;
+ bbx.cheight = h;
+ bbx.cxoff = x;
+ bbx.cyoff = y;
+ } else {
+ combine_bbx(bbx.cwidth, bbx.cheight,
+ bbx.cxoff, bbx.cyoff,
+ w, h, x, y, &bbx);
+ }
+ continue;
+ bbxbad:
+ fprintf(stderr, "Unparsable BBX found for U+%04x!\n", ucs);
+ } else {
+ fprintf(stderr,
+ "Warning: No BBX found for U+%04X!\n",
+ ucs);
+ }
+ }
+
+ if (!registry) registry = zstrdup("");
+ if (!encoding) encoding = zstrdup("");
+
+ /* generate output file name */
+ zstrcpy(&registry_encoding, "-");
+ zstrcat(&registry_encoding, registry);
+ zstrcat(&registry_encoding, "-");
+ zstrcat(&registry_encoding, encoding);
+
+ {
+ char * p = strstr(fsource, ".bdf");
+ if (p) {
+ zstrcpy(&fout, fsource);
+ p = strstr(fout, ".bdf");
+ *p = 0;
+ zstrcat(&fout, registry_encoding);
+ zstrcat(&fout, ".bdf");
+ } else {
+ zstrcpy(&fout, fsource);
+ zstrcat(&fout, registry_encoding);
+ }
+ }
+
+ /* remove path prefix */
+ zstrcpy(&t, basename(fout));
+ zstrcpy(&fout, t);
+
+ /* write new BDF file */
+ fprintf(stderr, "Writing %d characters into file '%s'.\n",
+ j, fout);
+ fout_fp = fopen(fout, "w");
+ if (fout_fp == NULL) {
+ fprintf(stderr, "%s: Can't write file '%s': %s!\n",
+ my_name, fout, strerror(errno));
+ exit(1);
+ }
+
+ fprintf(fout_fp, "%s\n", startfont);
+ fprintf(fout_fp, "%s",
+ "COMMENT AUTOMATICALLY GENERATED FILE. DO NOT EDIT!\n");
+ fprintf(fout_fp,
+ "COMMENT Generated with 'ucs2any %s %s %s-%s'\n",
+ fsource, fmap, registry, encoding);
+ fprintf(fout_fp, "%s",
+ "COMMENT from an ISO10646-1 encoded source BDF font.\n");
+ fprintf(fout_fp, "%s",
+ "COMMENT ucs2any by Ben Collver <collver1@attbi.com>, 2003, based on\n");
+ fprintf(fout_fp, "%s",
+ "COMMENT ucs2any.pl by Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/>, 2000.\n");
+
+ for (i = 0; i <= nextheader; i++) {
+ if (i == default_char_index)
+ fprintf(fout_fp, "DEFAULT_CHAR %d\n", default_char);
+ else if (i == startproperties_index)
+ fprintf(fout_fp, "STARTPROPERTIES %d\n", properties);
+ else if (i == fontname_index) {
+ fprintf(fout_fp, "FONT %s%s\n", fontname, registry_encoding);
+ }
+ else if (i == charset_registry_index)
+ fprintf(fout_fp, "CHARSET_REGISTRY \"%s\"\n", registry);
+ else if (i == slant_index)
+ fprintf(fout_fp, "SLANT \"%s\"\n", slant);
+ else if (i == charset_encoding_index)
+ fprintf(fout_fp, "CHARSET_ENCODING \"%s\"\n", encoding);
+ else if (i == fontboundingbox_index)
+ fprintf(fout_fp, "FONTBOUNDINGBOX %d %d %d %d\n", bbx.cwidth, bbx.cheight, bbx.cxoff, bbx.cyoff);
+ else if (i == spacing_index)
+ fprintf(fout_fp, "SPACING \"%s\"\n", spacing);
+ else
+ fprintf(fout_fp, "%s\n", da_fetch_str(headers, i));
+ }
+
+ fprintf(fout_fp, "CHARS %d\n", j);
+
+ /* Write characters */
+ for (i = 0; i < j; i++) {
+ ucs = da_fetch_int(map, chars[i]);
+ fprintf(fout_fp, "%s", da_fetch_str(startchar,
+ ucs));
+ fprintf(fout_fp, "ENCODING %d\n", chars[i]);
+ fprintf(fout_fp, "%s", da_fetch_str(my_char,
+ ucs));
+ }
+ fprintf(fout_fp, "%s", "ENDFONT\n");
+ fclose(fout_fp);
+ }
+
+ exit(0);
+}