ref: 40a644556006e9fdf7be238c4e0c7a55c65bb3fd
parent: ec27ab6323d4290518a9f2ea84237871ac575dfb
author: sl <sl@x1yg3>
date: Sun Jul 6 18:41:27 EDT 2025
add mkufont
--- a/INDEX
+++ b/INDEX
@@ -33,6 +33,7 @@
joy.gp100 - Configure the Rii GP 100 USB game controller.
mailclean - Clean up IMAP litter.
mkfile - $home/mkfile
+mkufont - Borrow from other fonts to create unicode.font (by cinap_lenrek)
n700 - Set preferred X11 mouse acceleration for Lenovo N700 wireless mouse.
nauth - rcpu to or rimport from auth.inri.net
nn - run webcookies/webfs, populate factotum from secstore, perform some binds, run plumber.
--- /dev/null
+++ b/mkufont
@@ -1,0 +1,77 @@
+#!/bin/rc
+# Borrow from other fonts to create unicode.font (by cinap_lenrek)
+if(~ $#* 0){
+ echo usage: $0 file ... >[1=2]
+ exit usage
+}
+awk 'BEGIN{
+ n=0
+}
+function hex(h){
+ v=0
+ h=tolower(h)
+ if(!sub(/^0x/, "", h))
+ return h
+ for(i=1; i<=length(h); ++i){
+ x=index("0123456789abcdef", substr(h, i, 1))
+ if(!x)
+ return -1
+ v=(16*v)+x-1
+ }
+ return v
+}
+{
+ if(FNR == 1){
+ if(NR == 1){
+ hx=$1
+ hy=$2
+ }
+ next
+ }
+ if(length($3) == 0)
+ next
+ f=$3
+ d=FILENAME
+ if(sub(/\/[^\/]+$/, "", d))
+ f=sprintf("%s/%s", d, f)
+ if(system(sprintf("test -e %s", f))){
+ printf("%s:%d missing %s\n", FILENAME, FNR, f) >"/fd/2"
+ next
+ }
+ s = hex($1)
+ e = hex($2)
+ if(e < s)
+ next
+ for(i=0; i<n; i++){
+ if(s >= as[i] && s <= ae[i])
+ s = ae[i]+1
+ if(e >= as[i] && e <= ae[i])
+ e = as[i]-1
+ if(s > e)
+ next
+ }
+ as[n] = hex($1)
+ ae[n] = hex($2)
+ ax[n] = f
+ n++;
+}
+END{
+ printf("%d %d\n", hx, hy)
+ for(i=0; i<n; i++){
+ printf("0x%.4x 0x%.4x ", as[i], ae[i])
+ system(sprintf("cleanname %s", ax[i]))
+ }
+}' $1 `{awk '{
+ x=$1
+ y=$2
+ if(NR == 1){
+ hx=x
+ hy=y
+ }
+ a=y-hy
+ if(a < 0)
+ a = -a
+ printf("%d %s\n", a, FILENAME)
+ nextfile
+}' $* | sort | uniq | awk '{print $2}'}
+
--
⑨