chiark / gitweb /
rule generation machinery
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jan 2012 15:54:41 +0000 (15:54 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 8 Jan 2012 15:54:41 +0000 (15:54 +0000)
.gitignore
Makefile [new file with mode: 0644]
Trad,6,13,0,-2.rules [deleted file]
bad/6x13.pcf.gz [new file with mode: 0644]
debian/copyright
foundries [deleted file]
good/6x13.pcf.gz [new file with mode: 0644]
mkrules [new file with mode: 0755]
printrule [new file with mode: 0755]
specs [new file with mode: 0644]

index b25c15b81fae06e1c55946ac6270bfdb293870e8..ba4dfe1cfffb3369fd00c990c7b7d3cff8a80049 100644 (file)
@@ -1 +1,6 @@
 *~
 *~
+bad/*.bdf
+good/*.bdf
+rules/*.rules
+rules/foundries
+rules/foundries.new
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f447dfc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,5 @@
+SHELL=/bin/bash
+
+clean:
+       rm -f rules/*.rules
+       rm -f good/*.bdf bad/*.bdf
diff --git a/Trad,6,13,0,-2.rules b/Trad,6,13,0,-2.rules
deleted file mode 100644 (file)
index 8bf133e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-sub {
-    s/00(;..)$/A8$1/;
-}
diff --git a/bad/6x13.pcf.gz b/bad/6x13.pcf.gz
new file mode 100644 (file)
index 0000000..c652655
Binary files /dev/null and b/bad/6x13.pcf.gz differ
index 30890f08616c4277ba5ddd753c070804840967f8..d61e1820972bd8c69e9e965b2031afa5bdc3e9ae 100644 (file)
@@ -1,15 +1,39 @@
-Some font glyph shape information was copied out of bdfs recreated
-from pcfs in xfonts-base_3.3.6-2_i386.deb, and transferred into
-*.rules files in this package.
+The machinery in this package is Copyright (C)2012 Ian Jackson.
+It is released under the following licence:
 
 
-The pcfs in that .deb were originally generated from source code in
-that xfonts-base; but here, in xfonts-traditional, we simply use the
-hex values in the regexps in the files *.rules.  Ie so the hex values
-themselves are now the preferred form for modification.
+  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 copyright file for xfonts-base 3.3.6-2 follows.
+  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
+  SOFTWARE IN THE PUBLIC INTEREST, INC.  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.
+
+The font glyph shape information is from pcfs which were copied out of
+xfonts-base.  For "good", version 3.3.6-2 and for "bad" 1:1.0.1.
+
+These pcfs were originally generated from source code in that
+xfonts-base; but here, in xfonts-traditional, we do not modify them
+any longer.  (It would be possible to build-depend on the relevant
+xfonts-base, but this would make life worse rather than better because
+it would make the resulting xfonts-traditional binary package
+nonfunction if you happened to already have a traditional xfonts-base
+installed.)
+
+The copyright files for the xfonts-base packages follow.
+
+======================================================================
+======================================================================
 
 This package is part of the Debian pre-packaged version of XFree86
 release 3.3.6.
 
 This package is part of the Debian pre-packaged version of XFree86
 release 3.3.6.
@@ -74,3 +98,223 @@ other dealings in this Software without prior written authorization
 from the X Consortium.
 
 X Window System is a trademark of X Consortium, Inc.
 from the X Consortium.
 
 X Window System is a trademark of X Consortium, Inc.
+
+======================================================================
+======================================================================
+
+Source package: xfonts-base
+Obtained from:
+    http://xorg.freedesktop.org/releases/individual/font/
+        font-arabic-misc-X11R7.0-1.0.0
+        font-cursor-misc-X11R7.0-1.0.0
+        font-daewoo-misc-X11R7.0-1.0.0
+        font-dec-misc-X11R7.0-1.0.0
+        font-isas-misc-X11R7.0-1.0.0
+        font-jis-misc-X11R7.0-1.0.0
+        font-micro-misc-X11R7.0-1.0.0
+        font-misc-misc-X11R7.0-1.0.0
+        font-mutt-misc-X11R7.0-1.0.0
+        font-schumacher-misc-X11R7.0-1.0.0
+        font-sony-misc-X11R7.0-1.0.0
+        font-sun-misc-X11R7.0-1.0.0
+Upstream author(s):
+    various; see copyright notices below
+Debian package author(s):
+    Stephen Early
+    Mark Eichin
+    Branden Robinson
+    ISHIKAWA Mutsumi
+    Scott James Remnant
+    Daniel Stone
+    David Nusinow
+
+Debian copyright(s)/licence(s):
+
+Unless otherwise noted, all modifications and additions to the upstream sources
+found in this Debian package bear the following copyright and license terms:
+
+    Copyright 1996-2004 Branden Robinson
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to
+    deal in the Software without restriction, including without limitation the
+    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+    sell copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+    AUTHOR(S) AND COPYRIGHT HOLDER(S) 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.
+
+Upstream copyright(s)/licence(s):
+
+font-arabic-misc-X11R7.0-1.0.0/COPYING:
+    Copyright 1996, 1997, 1998, 1999 Computing Research Labs, New Mexico State
+    University
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to
+    deal in the Software without restriction, including without limitation the
+    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+    sell copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+    COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY 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.
+
+font-cursor-misc-X11R7.0-1.0.0/COPYING:
+    "These ""glyphs"" are unencumbered"
+
+font-daewoo-misc-X11R7.0-1.0.0/COPYING:
+    "Copyright (c) 1987, 1988 Daewoo Electronics Co.,Ltd."
+
+font-dec-misc-X11R7.0-1.0.0/COPYING:
+    "Copyright (c) Digital Equipment Corporation,1988. All rights reserved"
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose and without fee is hereby granted, provided
+    that the above copyright notices appear in all copies and that both those
+    copyright notices and this permission notice appear in supporting
+    documentation, and that the name Digital Equipment Corporation not be used
+    in advertising or publicity pertaining to distribution of the software
+    without specific, written prior permission.  Digital Equipment Corporation
+    makes no representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied warranty.
+
+    DIGITAL EQUIPMENT CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+    IN NO EVENT SHALL DIGITAL EQUIPMENT CORPORATION 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.
+
+font-isas-misc-X11R7.0-1.0.0/COPYING:
+    Copyright (C) 1988  The Institute of Software, Academia Sinica.
+
+    Correspondence Address:  P.O.Box 8718, Beijing, China 100080.
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose and without fee is hereby granted, provided
+    that the above copyright notices appear in all copies and that both those
+    copyright notices and this permission notice appear in supporting
+    documentation, and that the name of "the Institute of Software, Academia
+    Sinica" not be used in advertising or publicity pertaining to distribution
+    of the software without specific, written prior permission.  The Institute
+    of Software, Academia Sinica, makes no representations about the suitability
+    of this software for any purpose.  It is provided "as is" without express or
+    implied warranty.
+
+    THE INSTITUTE OF SOFTWARE, ACADEMIA SINICA, DISCLAIMS ALL WARRANTIES WITH
+    REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+    AND FITNESS, IN NO EVENT SHALL THE INSTITUTE OF SOFTWARE, ACADEMIA SINICA,
+    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.
+
+font-jis-misc-X11R7.0-1.0.0/COPYING:
+    from Japanese Industrial Standard, JIS X 9051-1984
+    named "16-dots Matrix Character Patterns for Display Devices"
+    "from JIS X 9051-1984, by permission to use"
+
+font-micro-misc-X11R7.0-1.0.0/COPYING:
+    "Public domain font.  Share and enjoy."
+
+font-misc-misc-X11R7.0-1.0.0/COPYING:
+    "Public domain font.  Share and enjoy."
+
+font-mutt-misc-X11R7.0-1.0.0/COPYING:
+    Copyright 2002 Computing Research Labs, New Mexico State University
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to
+    deal in the Software without restriction, including without limitation the
+    rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+    sell copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in
+    all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+    COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY 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.
+
+font-schumacher-misc-X11R7.0-1.0.0/COPYING:
+    Copyright 1989 Dale Schumacher, dal@syntel.mn.org
+                   399 Beacon Ave.
+                   St. Paul, MN  55104-3527
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose and without fee is hereby granted, 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 Dale Schumacher not be used in
+    advertising or publicity pertaining to distribution of the software without
+    specific, written prior permission.  Dale Schumacher makes no
+    representations about the suitability of this software for any purpose.  It
+    is provided "as is" without express or implied warranty.
+
+font-sony-misc-X11R7.0-1.0.0/COPYING:
+    Copyright 1989 by Sony Corp.
+
+    Permission to use, copy, modify, and distribute this software and its
+    documentation for any purpose and without fee is hereby granted, provided
+    that the above copyright notices appear in all copies and that both those
+    copyright notices and this permission notice appear in supporting
+    documentation, and that the name of Sony Corp.  not be used in advertising
+    or publicity pertaining to distribution of the software without specific,
+    written prior permission.  Sony Corp. makes no representations about the
+    suitability of this software for any purpose.  It is provided "as is"
+    without express or implied warranty.
+
+    SONY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SONY 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.
+
+font-sun-misc-X11R7.0-1.0.0/COPYING:
+    Copyright 1989 by Sun Microsystems, Inc. Mountain View, CA.
+
+    Permission to use, copy, modify, and distribute this software and
+    its documentation for any purpose and without fee is hereby granted,
+    provided that the above copyright notices appear in all copies and
+    that both those copyright notices and this permission notice appear
+    in supporting documentation, and that the name of Sun Microsystems
+    not be used in advertising or publicity pertaining to distribution
+    of the software without specific, written prior permission.  Sun
+    Microsystems make no representations about the suitability of this
+    software for any purpose.  It is provided "as is" without express or
+    implied warranty.
+
+    SUN MICROSYSTEMS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS 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.
+
+vim:set ai et sw=4 ts=4 tw=80:
diff --git a/foundries b/foundries
deleted file mode 100644 (file)
index 78a533e..0000000
--- a/foundries
+++ /dev/null
@@ -1 +0,0 @@
-Misc   Trad
diff --git a/good/6x13.pcf.gz b/good/6x13.pcf.gz
new file mode 100644 (file)
index 0000000..5a9ccc0
Binary files /dev/null and b/good/6x13.pcf.gz differ
diff --git a/mkrules b/mkrules
new file mode 100755 (executable)
index 0000000..734e2a2
--- /dev/null
+++ b/mkrules
@@ -0,0 +1,68 @@
+#!/bin/bash
+set -e
+set -o pipefail
+rm -f rules/foundries
+rm -f rules/*.rules rules/foundries.new
+
+chars () {
+       for c in $rest; do
+               ord=`perl -e 'print ord($ARGV[0]),"\n" or die $!' "$c"`
+               ./printrule >&3 "$bad" "$good" $height \
+                       "^ENCODING $ord$" $partial "$c"
+       done
+}
+
+while read keyword rest; do
+       case "$keyword" in
+       '#'|'') continue ;;
+       pcf)
+               pcf=$rest
+               for f in good bad; do
+                       out=$f/$pcf.bdf
+                       zcat $f/$pcf.pcf.gz | pcf2bdf >$out
+                       eval "$f=\$out"
+               done
+               ;;
+       rules)
+               newfoundry=$rest
+               eval `perl -ne '
+                       next unless s/^BBX\s+//;
+                       s/\s+$//;
+                       s/\s+/,/g;
+                       s/[-+]?\b\d+\b/ sprintf "%d", $& /ge;
+                       m/^\d+\,(\d+)\b/ or die;
+                       print "key=$_; height=$1\n" or die $!;
+                       exit;
+               ' <$good`
+               oldfoundry=`perl -ne '
+                       next unless s/^FOUNDRY\s+\"?//;
+                       s/\"?\s+$//;
+                       print or die $!;
+                       exit;
+               ' <$good`
+               printf "%s %s" "$oldfoundry" "$newfoundry" >>rules/foundries.new
+               exec 3>rules/$newfoundry,$key.rules
+               echo >&3 '# -*- perl -*-'
+               echo >&3 '# autogenerated by mkrules'
+               echo >&3 'sub {'
+               ;;
+       endrules)
+               echo >&3 '}'
+               exec 3</dev/null
+               ;;
+       entire)
+               partial=0
+               chars
+               ;;
+       partial)
+               partial=1
+               chars
+               ;;
+       *)
+               echo >&2 "??? $keyword"
+               exit 1
+               ;;
+       esac
+done
+
+mv rules/foundries.new rules/foundries
diff --git a/printrule b/printrule
new file mode 100755 (executable)
index 0000000..4c16d9b
--- /dev/null
+++ b/printrule
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -w
+# usage:
+#  printrule bad.bdf good.bdf <height> '^ENCODING <nn>$' 0|1 <comment>
+#  printrule bad.bdf good.bdf <height> '^STARTCHAR <name>$' 0|1 <comment>
+
+# This script is an assistant for printing rules for pasting into
+# *.rules files.  The idea is that you get bdfs of the font you don't
+# and do like, and specify the character, and it will print a rule
+# that fixes it.  
+#
+# Final argument, if 1, says the glyph is a letter without an
+# ascender, and edits the regexp not to match the whitespace where
+# accents might go.
+
+use strict;
+use IO::File;
+
+die unless @ARGV==6;
+our ($badf,$goodf,$height,$regexp,$partial,$comment) = @ARGV;
+
+sub get ($) {
+    my ($p) = @_;
+    my $f = new IO::File $p or die "$p $!";
+    while (<$f>) {
+       last if m/$regexp/o;
+    }
+    die $p unless defined;
+    while (<$f>) {
+       last if m/^BITMAP$/;
+    }
+    my $glyph='';
+    for (my $y=0; $y<$height; $y++) {
+       <$f> =~ m/^([0-9a-f]+)$/i or die "$p $_ ?";
+       $glyph.="$1;";
+    }
+    $glyph =~ s/\;$//;
+    return $glyph;
+}
+
+my $bad = get($badf);
+my $good = get($goodf);
+my $s;
+if ($partial) {
+    $bad  =~ s/^(?:00\;)+//;  my $badrm= $&;
+    $good =~ s/^(?:00\;)+//;  my $goodrm= $&;
+    die "$badrm $bad   $goodrm $good " unless $badrm eq $goodrm;
+    $s = sprintf 's/\\b%s$/%s/', $bad, $good;
+} else {    
+    $s = sprintf 's/^%s$/%s/', $bad, $good;
+}
+printf "    %s; # %s\n", $s, $comment or die $!;
diff --git a/specs b/specs
new file mode 100644 (file)
index 0000000..71e00a3
--- /dev/null
+++ b/specs
@@ -0,0 +1,9 @@
+# If you add new fonts to good and bad remember that you are copying
+# font data from the bdfs to the rules files, so you may need to
+# update the copyright.
+
+pcf            6x13
+rules          Trad
+partial                a
+# entire               [ ] ( ) { } ` '
+endrules