mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
junk
This commit is contained in:
parent
5af8dd63eb
commit
eaec1e5a39
5 changed files with 211 additions and 0 deletions
4
dist/troff/README
vendored
Normal file
4
dist/troff/README
vendored
Normal file
|
@ -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
|
93
dist/troff/afm2troff.c
vendored
Normal file
93
dist/troff/afm2troff.c
vendored
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
67
dist/troff/devutf.sam
vendored
Normal file
67
dist/troff/devutf.sam
vendored
Normal file
|
@ -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
|
4
dist/troff/mono.sam
vendored
Normal file
4
dist/troff/mono.sam
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
,s/^hy "\n//g
|
||||
,s/^-.*/&\nhy "/
|
||||
w
|
||||
q
|
43
dist/troff/tfont
vendored
Executable file
43
dist/troff/tfont
vendored
Executable file
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue