aboutsummaryrefslogtreecommitdiff
path: root/dist/troff
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-03-19 06:13:42 +0000
committerrsc <devnull@localhost>2006-03-19 06:13:42 +0000
commiteaec1e5a39b6de1ed7c4c0e57b46c9e2de230ce3 (patch)
tree822806cf0c82b4cca763e90ca47a34f2107bb616 /dist/troff
parent5af8dd63eb193290c1f9c316012eb14d538569f1 (diff)
downloadplan9port-eaec1e5a39b6de1ed7c4c0e57b46c9e2de230ce3.tar.gz
plan9port-eaec1e5a39b6de1ed7c4c0e57b46c9e2de230ce3.tar.bz2
plan9port-eaec1e5a39b6de1ed7c4c0e57b46c9e2de230ce3.zip
junk
Diffstat (limited to 'dist/troff')
-rw-r--r--dist/troff/README4
-rw-r--r--dist/troff/afm2troff.c93
-rw-r--r--dist/troff/devutf.sam67
-rw-r--r--dist/troff/mono.sam4
-rwxr-xr-xdist/troff/tfont43
5 files changed, 211 insertions, 0 deletions
diff --git a/dist/troff/README b/dist/troff/README
new file mode 100644
index 00000000..80fbccb9
--- /dev/null
+++ b/dist/troff/README
@@ -0,0 +1,4 @@
+This directory contains tools used to import fonts for use in troff.
+
+afm2troff.c - simple AFM file reader, generates desc for troff/font/devutf.
+tfont - simple TTF or SFD converter
diff --git a/dist/troff/afm2troff.c b/dist/troff/afm2troff.c
new file mode 100644
index 00000000..da185230
--- /dev/null
+++ b/dist/troff/afm2troff.c
@@ -0,0 +1,93 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+int didname;
+int didfontname;
+int offset;
+void run(char*, int);
+Biobuf bout;
+
+void
+usage(void)
+{
+ fprint(2, "usage: afm2troff [-h] [-o offset] [file...]\n");
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ int i, fd;
+
+ ARGBEGIN{
+ case 'h':
+ didname = 1;
+ didfontname = 1;
+ break;
+ case 'o':
+ offset = atoi(EARGF(usage()));
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ Binit(&bout, 1, OWRITE);
+ if(argc == 0)
+ run("<stdin>", 0);
+ else{
+ for(i=0; i<argc; i++){
+ if((fd = open(argv[i], OREAD)) < 0)
+ sysfatal("open %s: %r", argv[i]);
+ run(argv[i], fd);
+ }
+ }
+ Bflush(&bout);
+}
+
+void
+run(char *name, int fd)
+{
+ char *p, *q, *f[100];
+ int nf, code, wid, ad;
+ Biobuf b;
+
+ Binit(&b, fd, OREAD);
+ while((p = Brdline(&b, '\n')) != nil){
+ p[Blinelen(&b)-1] = 0;
+ q = strchr(p, ' ');
+ if(q == nil)
+ continue;
+ *q++ = 0;
+ while(*q == ' ' || *q == '\t')
+ q++;
+ if(*q == 0)
+ continue;
+ if(strcmp(p, "FontName") == 0 && didname++ == 0)
+ Bprint(&bout, "name %s\n", q);
+ if(strcmp(p, "FullName") == 0 && didfontname++ == 0)
+ Bprint(&bout, "fontname %s\n", q);
+ if(strcmp(p, "C") == 0){
+ nf = getfields(q, f, nelem(f), 1, "\t\r\n\v ");
+ if(nf < 5 || strcmp(f[1], ";") != 0 || strcmp(f[2], "WX") != 0)
+ continue;
+ code = strtol(f[0], 0, 10);
+ wid = strtol(f[3], 0, 10);
+ wid = (wid+5)/10;
+ if(code == 0)
+ continue;
+ code += offset;
+ ad = 0;
+ if(nf < 6 || strcmp(f[nf-6], "B") != 0)
+ continue;
+ if(atoi(f[nf-4]) < -50)
+ ad |= 1;
+ if(atoi(f[nf-2]) > 600)
+ ad |= 2;
+ if(code == ' ')
+ Bprint(&bout, "spacewidth %d\ncharset\n", wid);
+ else
+ Bprint(&bout, "%C\t%d\t%d\t%d %04x\n", code, wid, ad, code, code);
+ }
+ }
+}
diff --git a/dist/troff/devutf.sam b/dist/troff/devutf.sam
new file mode 100644
index 00000000..4d423971
--- /dev/null
+++ b/dist/troff/devutf.sam
@@ -0,0 +1,67 @@
+,s/^`.*\n//
+,s/^'.*\n//
+,s/^‘.*/&\n` "/
+,s/^’.*/&\n' "/
+,s/^".*/&\ndq "/
+,s/^".*/&\ndq "/
+,s/^'.*/&\n’ "/
+,s/^\\.*/&\nbs "/
+,s/^`.*/&\n‘ "/
+,s/^\\`.*/&\nga "/
+,s/^­.*/&\nhy "/
+,s/^®.*/&\nrg "/
+,s/^±.*/&\n+- "/
+,s/^´.*/&\naa "/
+,s/^×.*/&\nmu "/
+,s/^÷.*/&\n-: "/
+,s/^-:.*/&\ndi "/
+,s/^–.*/&\nen "/
+,s/^en.*/&\n\\- "/
+,s/^—.*/&\nem "/
+,s/^em.*/&\n-- "/
+,s/^™.*/&\ntm "/
+,s/^←.*/&\n<- "/
+,s/^↑.*/&\nua "/
+,s/^→.*/&\n-> "/
+,s/^↓.*/&\nda "/
+,s/^↔.*/&\nab "/
+,s/^∀.*/&\nfa "/
+,s/^∂.*/&\npd "/
+,s/^∃.*/&\nte "/
+,s/^∅.*/&\nes "/
+,s/^∇.*/&\ngr "/
+,s/^∉.*/&\n!m "/
+,s/^∍.*/&\nst "/
+,s/^∗.*/&\n** "/
+,s/^∙.*/&\nbu "/
+,s/^√.*/&\nsr "/
+,s/^∝.*/&\npt "/
+,s/^∞.*/&\nif "/
+,s/^∠.*/&\nan "/
+,s/^∧.*/&\nl& "/
+,s/^∨.*/&\nl| "/
+,s/^∩.*/&\nca "/
+,s/^∪.*/&\ncu "/
+,s/^∫.*/&\nis "/
+,s/^∴.*/&\ntf "/
+,s/^≃.*/&\n~= "/
+,s/^≅.*/&\ncg "/
+,s/^≈.*/&\n~~ "/
+,s/^≠.*/&\n!= "/
+,s/^≡.*/&\n== "/
+,s/^≦.*/&\n<= "/
+,s/^≧.*/&\n>= "/
+,s/^⊂.*/&\nsb "/
+,s/^⊃.*/&\nsp "/
+,s/^⊄.*/&\n!b "/
+,s/^⊆.*/&\nib "/
+,s/^⊇.*/&\nip "/
+,s/^⊕.*/&\nO+ "/
+,s/^⊖.*/&\nO- "/
+,s/^⊗.*/&\nOx "/
+,s/^⊢.*/&\ntu "/
+,s/^⊨.*/&\nTu "/
+,s/^⋄.*/&\nlz "/
+,s/^⋯.*/&\nel "/
+w
+q
diff --git a/dist/troff/mono.sam b/dist/troff/mono.sam
new file mode 100644
index 00000000..48bd9362
--- /dev/null
+++ b/dist/troff/mono.sam
@@ -0,0 +1,4 @@
+,s/^hy "\n//g
+,s/^-.*/&\nhy "/
+w
+q
diff --git a/dist/troff/tfont b/dist/troff/tfont
new file mode 100755
index 00000000..ea99641c
--- /dev/null
+++ b/dist/troff/tfont
@@ -0,0 +1,43 @@
+#!/usr/local/plan9/bin/rc
+
+rm *.tpost *.troff *.pfb *.pfa *.afm map.sfd
+
+hex1=(0 1 2 3 4 5 6 7 8 9 A B C D E F)
+hex=()
+for(i in $hex1) for(j in $hex1) hex=($hex $i$j)
+{
+ for(h in $hex)
+ echo $h 0x$h^00_0x$h^FF
+} >map.sfd
+for(font){
+ f0=$font
+ if(~ $font *.ttf)
+ font=`{9 basename $font .ttf}
+ if not if(~ $font *.sfd)
+ font=`{9 basename $font .sfd}
+ fontforge -c 'Open($1); Generate($2, "", -1, 72, "map.sfd")' \
+ $f0 $font^%s.pfb map.sfd
+ {
+ echo name $font
+ echo fontname $font
+ } >$font.troff
+ >$font.tpost
+ for(h in $hex){
+ if(test -f $font$h.pfb){
+ pfb2pfa $font$h.pfb $font$h.pfa
+ mv $font$h.pfa /usr/local/plan9/postscript/font/dejavu/$font$h
+ afm2troff -h -o 0x$h^00 $font$h.afm >>$font.troff
+ echo 0x$h^00 0x$h^FF $font$h >>$font.tpost
+ }
+ }
+ {
+ echo '0x0027 0x0027 0x19 '$font'20 # map apostrophe to right quote'
+ echo '0x0060 0x0060 0x18 '$font'20 # map grave to left quote'
+ } >>$font.tpost
+
+ sam -d $font.troff <$PLAN9/dist/troff/devutf.sam
+ if(~ $font *Mono*)
+ sam -d $font.troff <$PLAN9/dist/troff/mono.sam
+ cp $font.troff /usr/local/plan9/troff/font/devutf/$font
+ cp $font.tpost /usr/local/plan9/postscript/troff/$font
+}