tjunk - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit eaec1e5a39b6de1ed7c4c0e57b46c9e2de230ce3
 (DIR) parent 5af8dd63eb193290c1f9c316012eb14d538569f1
 (HTM) Author: rsc <devnull@localhost>
       Date:   Sun, 19 Mar 2006 06:13:42 +0000
       
       junk
       
       Diffstat:
         A dist/troff/README                   |       4 ++++
         A dist/troff/afm2troff.c              |      93 +++++++++++++++++++++++++++++++
         A dist/troff/devutf.sam               |      67 +++++++++++++++++++++++++++++++
         A dist/troff/mono.sam                 |       4 ++++
         A dist/troff/tfont                    |      43 ++++++++++++++++++++++++++++++
       
       5 files changed, 211 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/dist/troff/README b/dist/troff/README
       t@@ -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
 (DIR) diff --git a/dist/troff/afm2troff.c b/dist/troff/afm2troff.c
       t@@ -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);
       +                }
       +        }
       +}
 (DIR) diff --git a/dist/troff/devutf.sam b/dist/troff/devutf.sam
       t@@ -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
 (DIR) diff --git a/dist/troff/mono.sam b/dist/troff/mono.sam
       t@@ -0,0 +1,4 @@
       +,s/^hy "\n//g
       +,s/^-.*/&\nhy "/
       +w
       +q
 (DIR) diff --git a/dist/troff/tfont b/dist/troff/tfont
       t@@ -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
       +}