File:  [Research Unix] / researchv10no / cmd / postscript / devpost / shell.lib
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:35 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

#
# Shell library - for building devpost tables. Original collection was
# built on a Version 47.0 PS-810.
#

RESOLUTION=720
UNITWIDTH=10

#
# BuiltinTables returns command lines that generate PostScript programs
# for building a typesetter description file and font width tables for
# a relatively standard collection of fonts. Use awk to select a command
# line or modify an existing command to build a width table for a new
# font.
#

BuiltinTables() {
	cat <<-'//End of BuiltinTables'
		Proportional	R	Times-Roman
		Proportional	I	Times-Italic
		Proportional	B	Times-Bold
		Proportional	BI	Times-BoldItalic
		Proportional	AB	AvantGarde-Demi
		Proportional	AI	AvantGarde-BookOblique
		Proportional	AR	AvantGarde-Book
		Proportional	AX	AvantGarde-DemiOblique
		Proportional	H	Helvetica
		Proportional	HB	Helvetica-Bold
		Proportional	HI	Helvetica-Oblique
		Proportional	HX	Helvetica-BoldOblique
		Proportional	Hb	Helvetica-Narrow-Bold
		Proportional	Hi	Helvetica-Narrow-Oblique
		Proportional	Hr	Helvetica-Narrow
		Proportional	Hx	Helvetica-Narrow-BoldOblique
		Proportional	KB	Bookman-Demi
		Proportional	KI	Bookman-LightItalic
		Proportional	KR	Bookman-Light
		Proportional	KX	Bookman-DemiItalic
		Proportional	NB	NewCenturySchlbk-Bold
		Proportional	NI	NewCenturySchlbk-Italic
		Proportional	NR	NewCenturySchlbk-Roman
		Proportional	NX	NewCenturySchlbk-BoldItalic
		Proportional	PA	Palatino-Roman
		Proportional	PB	Palatino-Bold
		Proportional	PI	Palatino-Italic
		Proportional	PX	Palatino-BoldItalic
		Proportional	ZI	ZapfChancery-MediumItalic
		FixedWidth	C	Courier
		FixedWidth	CB	Courier-Bold
		FixedWidth	CI	Courier-Oblique
		FixedWidth	CO	Courier
		FixedWidth	CW	Courier
		FixedWidth	CX	Courier-BoldOblique
		Dingbats	ZD	ZapfDingbats
		Greek		GR	Symbol
		Symbol		S	Symbol
		Special		S1	Times-Roman
		Description	DESC	---
	//End of BuiltinTables
}

#
# AllTables prints the complete list of builtin font names.
#

AllTables() {
	BuiltinTables | awk '{print $2}'
}

#
# Charset functions generate keyword/value pairs (as PostScript objects)
# that describe the character set available in a font. The keyword is a
# PostScript string that represents troff's name for the character. The
# value is usually the literal name (i.e. begins with a /) assigned to
# the character in the PostScript font. The value can also be an integer
# or a PostScript string. An integer value is used as an index in the
# current font's Encoding array. A string value is returned to the host
# unchanged when the entry for the character is constructed. Entries that
# have (") as their value are synonyms for the preceeding character.
#

StandardCharset() {
	cat <<-'//End of StandardCharset'
		(!)	/exclam
		(")	/quotedbl
		(#)	/numbersign
		($)	/dollar
		(%)	/percent
		(&)	/ampersand
		(')	/quoteright
		(\()	/parenleft
		(\))	/parenright
		(*)	/asterisk
		(+)	/plus
		(,)	/comma
		(hy)	/hyphen
		(-)	(")			% synonym
		(.)	/period
		(/)	/slash
		(0)	/zero
		(1)	/one
		(2)	/two
		(3)	/three
		(4)	/four
		(5)	/five
		(6)	/six
		(7)	/seven
		(8)	/eight
		(9)	/nine
		(:)	/colon
		(;)	/semicolon
		(<)	/less
		(=)	/equal
		(>)	/greater
		(?)	/question
		(@)	/at
		(A)	/A
		(B)	/B
		(C)	/C
		(D)	/D
		(E)	/E
		(F)	/F
		(G)	/G
		(H)	/H
		(I)	/I
		(J)	/J
		(K)	/K
		(L)	/L
		(M)	/M
		(N)	/N
		(O)	/O
		(P)	/P
		(Q)	/Q
		(R)	/R
		(S)	/S
		(T)	/T
		(U)	/U
		(V)	/V
		(W)	/W
		(X)	/X
		(Y)	/Y
		(Z)	/Z
		([)	/bracketleft
		(\\)	/backslash
		(])	/bracketright
		(^)	/asciicircum
		(_)	/underscore
		(`)	/quoteleft
		(a)	/a
		(b)	/b
		(c)	/c
		(d)	/d
		(e)	/e
		(f)	/f
		(g)	/g
		(h)	/h
		(i)	/i
		(j)	/j
		(k)	/k
		(l)	/l
		(m)	/m
		(n)	/n
		(o)	/o
		(p)	/p
		(q)	/q
		(r)	/r
		(s)	/s
		(t)	/t
		(u)	/u
		(v)	/v
		(w)	/w
		(x)	/x
		(y)	/y
		(z)	/z
		({)	/braceleft
		(|)	/bar
		(})	/braceright
		(~)	/asciitilde
		(---)	/exclamdown
		(ct)	/cent
		(ps)	/sterling
		(fr)	/fraction
		(yn)	/yen
		(fn)	/florin
		(sc)	/section
		(cr)	/currency
		(---)	/quotesingle
		(``)	/quotedblleft
		(---)	/guillemotleft
		(---)	/guilsinglleft
		(---)	/guilsinglright
		(fi)	/fi
		(fl)	/fl
		(en)	/endash
		(\\-)	(")
		(dg)	/dagger
		(dd)	/daggerdbl
		(---)	/periodcentered
		(pg)	/paragraph
		(---)	/bullet
		(---)	/quotesinglbase
		(---)	/quotedblbase
		('')	/quotedblright
		(---)	/guillemotright
		(---)	/ellipsis
		(---)	/perthousand
		(---)	/questiondown
		(ga)	/grave
		(\\`)	(")
		(aa)	/acute
		(\\')	(")
		(^a)	/circumflex
		(~a)	/tilde
		(-a)	/macron
		(Ua)	/breve
		(.a)	/dotaccent
		(:a)	/dieresis
		(oa)	/ring
		(,a)	/cedilla
		("a)	/hungarumlaut
		(Ca)	/ogonek
		(va)	/caron
		(em)	/emdash
		(---)	/AE
		(---)	/ordfeminine
		(---)	/Lslash
		(---)	/Oslash
		(---)	/OE
		(---)	/ordmasculine
		(---)	/ae
		(---)	/dotlessi
		(---)	/lslash
		(---)	/oslash
		(---)	/oe
		(---)	/germandbls
	//End of StandardCharset
}

SymbolCharset() {
	cat <<-'//End of SymbolCharset'
		(---)	/exclam
		(fa)	/universal
		(---)	/numbersign
		(te)	/existential
		(---)	/percent
		(---)	/ampersand
		(st)	/suchthat
		(---)	/parenleft
		(---)	/parenright
		(**)	/asteriskmath
		(pl)	/plus
		(---)	/comma
		(mi)	/minus
		(---)	/period
		(sl)	/slash
		(---)	/zero
		(---)	/one
		(---)	/two
		(---)	/three
		(---)	/four
		(---)	/five
		(---)	/six
		(---)	/seven
		(---)	/eight
		(---)	/nine
		(---)	/colon
		(---)	/semicolon
		(<)	/less
		(eq)	/equal
		(>)	/greater
		(---)	/question
		(cg)	/congruent
		(*A)	/Alpha
		(*B)	/Beta
		(*X)	/Chi
		(*D)	/Delta
		(*E)	/Epsilon
		(*F)	/Phi
		(*G)	/Gamma
		(*Y)	/Eta
		(*I)	/Iota
		(---)	/theta1
		(*K)	/Kappa
		(*L)	/Lambda
		(*M)	/Mu
		(*N)	/Nu
		(*O)	/Omicron
		(*P)	/Pi
		(*H)	/Theta
		(*R)	/Rho
		(*S)	/Sigma
		(*T)	/Tau
		(*U)	/Upsilon
		(ts)	/sigma1
		(*W)	/Omega
		(*C)	/Xi
		(*Q)	/Psi
		(*Z)	/Zeta
		(---)	/bracketleft
		(tf)	/therefore
		(---)	/bracketright
		(pp)	/perpendicular
		(ul)	/underscore
		(_)	(")			% synonym
		(rn)	/radicalex
		(*a)	/alpha
		(*b)	/beta
		(*x)	/chi
		(*d)	/delta
		(*e)	/epsilon
		(*f)	/phi
		(*g)	/gamma
		(*y)	/eta
		(*i)	/iota
		(---)	/phi1
		(*k)	/kappa
		(*l)	/lambda
		(*m)	/mu
		(*n)	/nu
		(*o)	/omicron
		(*p)	/pi
		(*h)	/theta
		(*r)	/rho
		(*s)	/sigma
		(*t)	/tau
		(*u)	/upsilon
		(---)	/omega1
		(*w)	/omega
		(*c)	/xi
		(*q)	/psi
		(*z)	/zeta
		(---)	/braceleft
		(or)	/bar
		(---)	/braceright
		(ap)	/similar
		(---)	/Upsilon1
		(fm)	/minute
		(<=)	/lessequal
		(---)	/fraction
		(if)	/infinity
		(---)	/florin
		(---)	/club
		(---)	/diamond
		(---)	/heart
		(---)	/spade
		(ab)	/arrowboth
		(<-)	/arrowleft
		(ua)	/arrowup
		(->)	/arrowright
		(da)	/arrowdown
		(de)	/degree
		(+-)	/plusminus
		(---)	/second
		(>=)	/greaterequal
		(mu)	/multiply
		(pt)	/proportional
		(pd)	/partialdiff
		(bu)	/bullet
		(di)	/divide
		(!=)	/notequal
		(==)	/equivalence
		(~~)	/approxequal
		(el)	/ellipsis
		(av)	/arrowvertex
		(ah)	/arrowhorizex
		(CR)	/carriagereturn
		(af)	/aleph
		(If)	/Ifraktur
		(Rf)	/Rfraktur
		(ws)	/weierstrass
		(Ox)	/circlemultiply
		(O+)	/circleplus
		(es)	/emptyset
		(ca)	/intersection
		(cu)	/union
		(sp)	/propersuperset
		(ip)	/reflexsuperset
		(!b)	/notsubset
		(sb)	/propersubset
		(ib)	/reflexsubset
		(mo)	/element
		(!m)	/notelement
		(an)	/angle
		(gr)	/gradient
		(rg)	/registerserif
		(co)	/copyrightserif
		(tm)	/trademarkserif
		(---)	/product
		(sr)	/radical
		(c.)	/dotmath
		(no)	/logicalnot
		(l&)	/logicaland
		(l|)	/logicalor
		(---)	/arrowdblboth
		(---)	/arrowdblleft
		(---)	/arrowdblup
		(---)	/arrowdblright
		(---)	/arrowdbldown
		(lz)	/lozenge
		(b<)	/angleleft
		(RG)	/registersans
		(CO)	/copyrightsans
		(TM)	/trademarksans
		(---)	/summation
		(LT)	/parenlefttp
		(br)	/parenleftex
		(LX)	(")			% synonym
		(LB)	/parenleftbt
		(lc)	/bracketlefttp
		(lx)	/bracketleftex
		(lf)	/bracketleftbt
		(lt)	/bracelefttp
		(lk)	/braceleftmid
		(lb)	/braceleftbt
		(bv)	/braceex
		(|)	(")			% synonym
		(b>)	/angleright
		(is)	/integral
		(---)	/integraltp
		(---)	/integralex
		(---)	/integralbt
		(RT)	/parenrighttp
		(RX)	/parenrightex
		(RB)	/parenrightbt
		(rc)	/bracketrighttp
		(rx)	/bracketrightex
		(rf)	/bracketrightbt
		(rt)	/bracerighttp
		(rk)	/bracerightmid
		(rb)	/bracerightbt
		(~=)	(55	0	1)	% charlib
	//End of SymbolCharset
}

SpecialCharset() {
	cat <<-'//End of SpecialCharset'
		(ru)	/underscore
		(ff)	(60	2	1)	% charlib
		(Fi)	(84	2	1)	% charlib
		(Fl)	(84	2	1)	% charlib
		(14)	(75	2	1)	% charlib
		(12)	(75	2	1)	% charlib
		(34)	(75	2	1)	% charlib
		(bx)	(50	2	1)	% charlib
		(ob)	(38	2	1)	% charlib
		(ci)	(75	0	1)	% charlib
		(sq)	(50	2	1)	% charlib
		(Sl)	(50	2	1)	% charlib
		(L1)	(110	1	2)	% charlib
		(LA)	(110	1	2)	% charlib
		(LV)	(110	3	1)	% charlib
		(LH)	(210	1	1)	% charlib
		(lh)	(100	0	1)	% charlib
		(rh)	(100	0	1)	% charlib
		(lH)	(100	0	1)	% charlib
		(rH)	(100	0	1)	% charlib
		(PC)	(220	2	1)	% charlib
		(DG)	(185	2	1)	% charlib
	//End of SpecialCharset
}

DingbatsCharset() {
	cat <<-'//End of DingbatsCharset'
		(!)	33
		(")	34
		(#)	35
		($)	36
		(%)	37
		(&)	38
		(')	39
		(\()	40
		(\))	41
		(*)	42
		(+)	43
		(,)	44
		(-)	45
		(.)	46
		(/)	47
		(0)	48
		(1)	49
		(2)	50
		(3)	51
		(4)	52
		(5)	53
		(6)	54
		(7)	55
		(8)	56
		(9)	57
		(:)	58
		(;)	59
		(<)	60
		(=)	61
		(>)	62
		(?)	63
		(@)	64
		(A)	65
		(B)	66
		(C)	67
		(D)	68
		(E)	69
		(F)	70
		(G)	71
		(H)	72
		(I)	73
		(J)	74
		(K)	75
		(L)	76
		(M)	77
		(N)	78
		(O)	79
		(P)	80
		(Q)	81
		(R)	82
		(S)	83
		(T)	84
		(U)	85
		(V)	86
		(W)	87
		(X)	88
		(Y)	89
		(Z)	90
		([)	91
		(\\)	92
		(])	93
		(^)	94
		(_)	95
		(`)	96
		(a)	97
		(b)	98
		(c)	99
		(d)	100
		(e)	101
		(f)	102
		(g)	103
		(h)	104
		(i)	105
		(j)	106
		(k)	107
		(l)	108
		(m)	109
		(n)	110
		(o)	111
		(p)	112
		(q)	113
		(r)	114
		(s)	115
		(t)	116
		(u)	117
		(v)	118
		(w)	119
		(x)	120
		(y)	121
		(z)	122
		({)	123
		(|)	124
		(})	125
		(~)	126
		(hy)	161
		(em)	162
		(de)	163
		(\\-)	164
		(en)	165
		(ff)	166
		(fi)	167
		(fl)	168
		(Fi)	169
		(Fl)	170
		(fm)	171
		(ru)	172
		(dg)	173
		(bu)	174
		(14)	175
		(34)	176
		(12)	177
		(ct)	178
		(rg)	179
		(sq)	180
		(sl)	181
		(ul)	182
		(or)	183
		(no)	184
		(->)	185
		(<-)	186
		(da)	187
		(lh)	188
		(ua)	189
		(ab)	190
		(!b)	191
		(aa)	192
		(!m)	193
		(ga)	194
		(pl)	195
		(mi)	196
		(mu)	197
		(di)	198
		(eq)	199
		(==)	200
		(>=)	201
		(<=)	202
		(!=)	203
		(+-)	204
		(-+)	205
		(ap)	206
		(~=)	207
		(gr)	208
		(is)	209
		(pd)	210
		(if)	211
		(sr)	212
		(rn)	213
		(sb)	214
		(sp)	215
		(cu)	216
		(ca)	217
		(ib)	218
		(ip)	219
		(mo)	220
		(es)	221
		(sc)	222
		(dd)	223
		(lc)	224
		(rc)	225
		(lf)	226
		(rf)	227
		(bv)	228
		(**)	229
		(br)	230
		(ci)	231
		(ts)	232
		(co)	233
		(lt)	234
		(rt)	235
		(lb)	236
		(rb)	237
		(lk)	238
		(rk)	239
		(rh)	241
		(tm)	242
		(Sl)	243
		(ps)	244
		(cs)	245
		(cy)	246
		(as)	247
		(os)	248
		(=.)	249
		(ld)	250
		(rd)	251
		(le)	252
		(ge)	253
		(pp)	254
	//End of DingbatsCharset
}

#
# Generating functions output PostScript programs that build font width
# tables or a typesetter description file. Send the program to a printer
# and the complete table will come back on the serial port. All write on
# stdout and assume the prologue and other required PostScript files are
# all available.
#

Proportional() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		# Get <>_ and | from S. Use accents for ascii ^ and ~.
		StandardCharset | awk '
			$1 == "(<)" && $2 == "/less" {$1 = "(---)"}
			$1 == "(>)" && $2 == "/greater" {$1 = "(---)"}
			$1 == "(_)" && $2 == "/underscore" {$1 = "(---)"}
			$1 == "(|)" && $2 == "/bar" {$1 = "(---)"}
			$1 == "(^)" && $2 == "/asciicircum" {$1 = "(---)"}
			$1 == "(~)" && $2 == "/asciitilde" {$1 = "(---)"}
			{printf "%s\t%s\n", $1, $2}
			$2 == "/circumflex" {printf "(^)\t(\")\n"}
			$2 == "/tilde" {printf "(~)\t(\")\n"}
		'
	echo "] def"

	echo "/$2 SelectFont"
	echo "(opO) SetAscender"

	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(ligatures fi fl 0\\\\n) Print"
	echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

FixedWidth() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		# awk is not important - it's only here for compatibility
		StandardCharset | awk '
			$1 == "(fi)" || $1 == "(fl)" {next}
			{printf "%s\t%s\n", $1, $2}
			$2 == "/circumflex" {printf "(^)\t(\")\n"}
			$2 == "/tilde" {printf "(~)\t(\")\n"}
	'
	echo "] def"

	echo "/$2 SelectFont"
	echo "(opO) SetAscender"

	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

Dingbats() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		DingbatsCharset
	echo "] def"

	echo "/$2 SelectFont"
	echo "(   ) SetAscender"

	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

Greek() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		SymbolCharset | awk '$1 ~ /\(\*[a-zA-Z]\)/'
	echo "] def"

	echo "/$2 SelectFont"
	echo "(orO) SetAscender"

	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(spacewidth ) Print 32 GetWidth Print (\n) Print"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

Symbol() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		SymbolCharset
	echo "] def"

	echo "ChangeMetrics"
	echo "/S SelectFont"
	echo "(orO) SetAscender"

	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(special\\\\n) Print"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

Special() {
	echo "/unitwidth $UNITWIDTH def"
	echo "/resolution $RESOLUTION def"
	echo "/charset ["
		SpecialCharset
	echo "] def"

	echo "ChangeMetrics"
	echo "/S1 SelectFont"

	echo "(# Times-Roman special font\\\\n) Print"
	echo "(name $1\\\\n) Print"
	echo "(fontname $2\\\\n) Print"
	echo "/$1 NamedInPrologue"
	echo "(special\\\\n) Print"
	echo "(charset\\\\n) Print"
	echo "BuildFontCharset"
}

#
# The DESC file doesn't have to be built on a printer. It's only here for
# consistency.
#

Description() {
	echo "/charset ["	# awk - so the stack doesn't overflow
		StandardCharset | awk '$1 != "(---)" {print $1}'
		SymbolCharset | awk '$1 != "(---)" {print $1}'
		SpecialCharset | awk '$1 != "(---)" {print $1}'
		DingbatsCharset | awk '$1 != "(---)" {print $1}'
	echo "] def"

	cat <<-//DESC
		(#Device Description - original PostScript character set

		PDL PostScript

		fonts 10 R I B BI CW H HI HB S1 S
		sizes 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
		23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 40 42 44 46
		48 50 52 54 56 58 60 64 68 72 78 84 90 96 100 105 110 115
		120 125 130 135 140 145 150 155 160 0

		res $RESOLUTION
		hor 1
		vert 1
		unitwidth $UNITWIDTH

		) Print
	//DESC
	echo "(charset\\\\n) Print"
	echo "BuildDescCharset"
	echo "(\\\\n) Print"
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.