Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/lab/fontmix/fontmix.awk

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/awk -f
# Example:
# 	gofonts = (-v 'fR=GoRegular' -v 'fL=GoMono' -v 'fHB=Go-Bold' -v 'fHI=Go-Italic' -v 'fHX=Go-BoldItalic')
#	awk -v 'vsz=16a' -v 'msz=14a' $gofonts -f fontmix.awk > regular.16.font
#	awk -v 'vsz=32a' -v 'msz=30a' $gofonts -f fontmix.awk > regular.32.font
#
# Load using this command:
#	Font /path/to/lib/font/go/regular.16.font,/path/to/lib/lib/font/go/regular.32.font
#
# "If font name has form x,y use x for lodpi, y for hidpi."
#
# Sample display:
#
# 	ABCDEFGHIJKLMNOPQRSTUVWXYZ
# 	abcdefghijklmnopqrstuvwxyz
# 	0123456789
# 	𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉
# 	𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣
# 	𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿
# 	𝗔𝗕𝗖𝗗𝗘𝗙𝗚𝗛𝗜𝗝𝗞𝗟𝗠𝗡𝗢𝗣𝗤𝗥𝗦𝗧𝗨𝗩𝗪𝗫𝗬𝗭
# 	𝗮𝗯𝗰𝗱𝗲𝗳𝗴𝗵𝗶𝗷𝗸𝗹𝗺𝗻𝗼𝗽𝗾𝗿𝘀𝘁𝘂𝘃𝘄𝘅𝘆𝘇
# 	𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵
# 	𝘼𝘽𝘾𝘿𝙀𝙁𝙂𝙃𝙄𝙅𝙆𝙇𝙈𝙉𝙊𝙋𝙌𝙍𝙎𝙏𝙐𝙑𝙒𝙓𝙔𝙕
# 	𝙖𝙗𝙘𝙙𝙚𝙛𝙜𝙝𝙞𝙟𝙠𝙡𝙢𝙣𝙤𝙥𝙦𝙧𝙨𝙩𝙪𝙫𝙬𝙭𝙮𝙯
# 	𝘈𝘉𝘊𝘋𝘌𝘍𝘎𝘏𝘐𝘑𝘒𝘓𝘔𝘕𝘖𝘗𝘘𝘙𝘚𝘛𝘜𝘝𝘞𝘟𝘠𝘡
# 	𝘢𝘣𝘤𝘥𝘦𝘧𝘨𝘩𝘪𝘫𝘬𝘭𝘮𝘯𝘰𝘱𝘲𝘳𝘴𝘵𝘶𝘷𝘸𝘹𝘺𝘻
#

BEGIN {
	# vsz = "32a"; fR = "GoRegular"
	# msz = "30a"; fL = "GoMono"; fHB = "Go-Bold"; fHI = "Go-Italic"; fHX = "Go-BoldItalic"
	if(!msz)
		msz=vsz
	cmd = "fontsrv -p " fR "/" vsz "/font"
	while(cmd | getline > 0){
		if(++nr == 1) {
			print
			printoverlay()
		} else {
			fixpath()
			print
		}
	}
}

function fixpath() {
	$3 = "/mnt/font/" fR "/" vsz "/" $3
}

function printoverlay() {
	# monotype
	if(length(fL) > 0) {
		print "0x1d670 0x1d689 0x01 /mnt/font/" fL "/" msz "/x0040.bit"	# 𝙰-𝚉
		print "0x1d68a 0x1d6a3 0x01 /mnt/font/" fL "/" msz "/x0060.bit"	# 𝚊-𝚣
		print "0x1d7f6 0x1d7ff 0x10 /mnt/font/" fL "/" msz "/x0020.bit"  	# 𝟶-𝟿
	}
	# serif bold
	if(length(fHB) > 0) {
		print "0x1d5d4 0x1d5ed 0x01 /mnt/font/" fHB "/" vsz "/x0040.bit"	# 𝗔-𝗭
		print "0x1d5ee 0x1d607 0x01 /mnt/font/" fHB "/" vsz "/x0060.bit"	# 𝗮-𝘇
		print "0x1d7ec 0x1d7f5 0x10 /mnt/font/" fHB "/" vsz "/x0020.bit"	# 𝟬-𝟵
		# print "0x1d756 0x1d76e 0x11 /mnt/font/" fHB "/" vsz "/x0380.bit"	# 𝝖-𝝮
		# print "0x1d770 0x1d788 0x11 /mnt/font/" fHB "/" vsz "/x03a0.bit"	# 𝝰-𝞈
	}
	# serif italic
	if(length(fHI) > 0) {
		print "0x1d608 0x1d621 0x01 /mnt/font/" fHI "/" vsz "/x0040.bit"	# 𝘈-𝘡
		print "0x1d622 0x1d63b 0x01 /mnt/font/" fHI "/" vsz "/x0060.bit"	# 𝘢-𝘻
	}
	# serif bold italic
	if(length(fHX) > 0) {
		print "0x1d63c 0x1d655 0x01 /mnt/font/" fHX "/" vsz "/x0040.bit"	# 𝘼-𝙕
		print "0x1d656 0x1d66f 0x01 /mnt/font/" fHX "/" vsz "/x0060.bit"	# 𝙖-𝙯
		# print "0x1d790 0x1d7a8 0x11 /mnt/font/" fHX "/" vsz "/x0380.bit"	# 𝞐-𝞨
		# print "0x1d7aa 0x1d7c2 0x11 /mnt/font/" fHX "/" vsz "/x03a0.bit"	# 𝞪-𝟂
	}
}


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.