shithub: riscv

Download patch

ref: c539d64d22a0fdef1bd044a6e28e02a6bcfd0adf
parent: 566c5121064c4872fd9b21bfa37b1f997d779f18
author: Jacob Moody <[email protected]>
date: Fri Jul 8 23:43:33 EDT 2022

man: turn on troff -mnihongo if JP font is used

This specifically fixes
	% man -P ktrans

We dont have font widths for kanji in our troff
font files, so we can use aux/mnihongo to render
the character using libdraw, and grab the bitmap from
there. It's not pretty, but aux/mnihongo exists so
lets at least use it.

This also updates /sys/man/1/ktrans to specify the
Jp font to comply with aux/mnihongo.

--- a/rc/bin/man
+++ b/rc/bin/man
@@ -11,6 +11,7 @@
 
 fn roff {
 	preproc=()
+	Jpflag=()
 	postproc=cat
 	x=`{doctype $2}
 	if (~ $1 t) {
@@ -19,6 +20,8 @@
 		if(~ $x *pic*)
 			preproc=($preproc pic)
 		Nflag=-Tutf
+		if(grep -s '^.ft Jp|\f\[Jp\]' $2)
+			Jpflag='-mnihongo'
 	}
 	if not {
 		Nflag='-N'
@@ -34,17 +37,17 @@
 	{echo -n $FONTS; cat $2 </dev/null} |
 		switch($#preproc) {
 		case 0
-			troff $Nflag $Lflag -$MAN 
+			troff $Nflag $Lflag -$MAN $Jpflag
 		case 1
-			$preproc | troff $Nflag $Lflag -$MAN
+			$preproc | troff $Nflag $Lflag -$MAN $Jpflag
 		case 2
-			$preproc(1) | $preproc(2) | troff $Nflag $Lflag -$MAN
+			$preproc(1) | $preproc(2) | troff $Nflag $Lflag -$MAN $Jpflag
 		case 3
 			$preproc(1) | $preproc(2) | $preproc(3) |
-				troff $Nflag $Lflag -$MAN
+				troff $Nflag $Lflag -$MAN $Jpflag
 		case *
 			$preproc(1) | $preproc(2) | $preproc(3) |
-				$preproc(4) | troff $Nflag $Lflag -$MAN
+				$preproc(4) | troff $Nflag $Lflag -$MAN $Jpflag
 		} | $postproc
 }
 
--- a/sys/man/1/ktrans
+++ b/sys/man/1/ktrans
@@ -86,8 +86,10 @@
 .SH EXAMPLES
 If you want to make the Japanese text as below:
 
+.ft Jp
 私は毎日35分以上歩いて、 更に10分電車に乗って学校に通います。
  健康の維持にも役だっていますが、 なかなかたのしいものです。
+.ft
 
 your keyboard typing stream should be: