[Midnightbsd-cvs] src [11886] trunk/tools/tools/vt: add tools

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jul 17 20:52:31 EDT 2018


Revision: 11886
          http://svnweb.midnightbsd.org/src/?rev=11886
Author:   laffer1
Date:     2018-07-17 20:52:30 -0400 (Tue, 17 Jul 2018)
Log Message:
-----------
add tools

Added Paths:
-----------
    trunk/tools/tools/vt/
    trunk/tools/tools/vt/fontcvt/
    trunk/tools/tools/vt/fontcvt/terminus.sh
    trunk/tools/tools/vt/keymaps/
    trunk/tools/tools/vt/keymaps/KBDFILES.map
    trunk/tools/tools/vt/keymaps/LANG.map
    trunk/tools/tools/vt/keymaps/convert-INDEX.pl
    trunk/tools/tools/vt/keymaps/convert-keymap.pl
    trunk/tools/tools/vt/keymaps/convert-keymaps.pl
    trunk/tools/tools/vt/mkkfont/
    trunk/tools/tools/vt/mkkfont/Makefile
    trunk/tools/tools/vt/mkkfont/mkkfont.c
    trunk/tools/tools/vt/mkkfont/terminus.sh
    trunk/tools/tools/vt/setfont/
    trunk/tools/tools/vt/setfont/Makefile
    trunk/tools/tools/vt/setfont/setfont.c

Added: trunk/tools/tools/vt/fontcvt/terminus.sh
===================================================================
--- trunk/tools/tools/vt/fontcvt/terminus.sh	                        (rev 0)
+++ trunk/tools/tools/vt/fontcvt/terminus.sh	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,14 @@
+#!/bin/sh
+# $FreeBSD: stable/10/tools/tools/vt/fontcvt/terminus.sh 269041 2014-07-24 01:35:41Z emaste $
+
+for i in 6:12 8:14 8:16 10:18 10:20 11:22 12:24 14:28 16:32
+do
+	C=`echo $i | cut -f 1 -d :`
+	R=`echo $i | cut -f 2 -d :`
+	./vtfontcvt \
+		-w $C -h $R \
+		~/terminus-font-4.36/ter-u${R}n.bdf \
+		~/terminus-font-4.36/ter-u${R}b.bdf \
+		terminus-u${R}.vfnt
+	gzip -9nf terminus-u${R}.vfnt
+done


Property changes on: trunk/tools/tools/vt/fontcvt/terminus.sh
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/keymaps/KBDFILES.map
===================================================================
--- trunk/tools/tools/vt/keymaps/KBDFILES.map	                        (rev 0)
+++ trunk/tools/tools/vt/keymaps/KBDFILES.map	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,149 @@
+# $FreeBSD: stable/10/tools/tools/vt/keymaps/KBDFILES.map 271095 2014-09-04 13:45:16Z se $
+#
+# The Files are converted by "convert-keymaps.pl" from the given encoding to UCS.
+#
+# An additional "+EURO" causes the translation of the generic currency symbol to 
+# an Euro symbol, even if the source locale does not support an Euro symbol.
+# This conversion is only performed for the "E" key (not e.g. on Shift-4, which 
+# still generates the currency symbol).
+#
+# Encoding      syscons file name               newcons (vt) file name
+ISO8859-1+EURO	be.iso.kbd			be.kbd
+ISO8859-1+EURO	be.iso.acc.kbd			be.acc.kbd
+
+ISO8859-5	bg.bds.ctrlcaps.kbd		bg.bds.kbd
+ISO8859-5	bg.phonetic.ctrlcaps.kbd	bg.phonetic.kbd
+
+#ISO8859-1	br275.iso.kbd			br.kbd.from-iso1	(only AltGr-Shift-6 differs from CP850)
+ISO8859-1	br275.iso.acc.kbd		br.kbd
+CP850		br275.cp850.kbd			br.noacc.kbd
+
+#CP1131		by.cp1131.kbd			by.kbd.from-cp1131	(Shift-3 not OK)
+#CP1251		by.cp1251.kbd			by.kbd.from-cp1251	(result identical to CP1251)
+ISO8859-5	by.iso5.kbd			by.kbd
+
+ISO8859-2	ce.iso2.kbd			centraleuropean.qwerty.kbd
+
+ISO8859-1	colemak.iso15.acc.kbd		colemak.acc.kbd
+
+ISO8859-2	cs.latin2.qwertz.kbd		cz.kbd
+ISO8859-2	cz.iso2.kbd			cz.qwerty.kbd.from-ce
+
+ISO8859-1+EURO	danish.iso.kbd			dk.kbd
+ISO8859-1+EURO	danish.iso.acc.kbd		dk.acc.kbd
+CP865		danish.cp865.kbd		dk.kbd.from-cp865
+ISO8859-1	danish.iso.macbook.kbd		dk.macbook.kbd
+
+ISO8859-1	dutch.iso.acc.kbd		nl.kbd
+
+ISO8859-15	eee_nordic.kbd			nordic.asus-eee.kbd
+
+ISO8859-7	el.iso07.kbd			gr.kbd
+
+ISO8859-1	estonian.iso.kbd		ee.kbd.from-iso1
+ISO8859-15	estonian.iso15.kbd		ee.kbd
+CP850		estonian.cp850.kbd		ee.kbd.from-cp850
+
+ISO8859-1+EURO	finnish.iso.kbd			fi.kbd
+CP850		finnish.cp850.kbd		fi.kbd.from-cp850
+
+ISO8859-1+EURO	fr.iso.kbd			fr.kbd
+ISO8859-1+EURO	fr.iso.acc.kbd			fr.acc.kbd
+ISO8859-1+EURO	fr.macbook.acc.kbd		fr.macbook.kbd
+ISO8859-1+EURO	fr.dvorak.kbd			fr.dvorak.kbd
+ISO8859-1	fr.dvorak.acc.kbd		fr.dvorak.acc.kbd
+
+ISO8859-1+EURO	fr_CA.iso.acc.kbd		ca-fr.kbd
+
+ISO8859-1+EURO	german.iso.kbd			de.noacc.kbd
+ISO8859-1+EURO	german.iso.acc.kbd		de.acc.kbd
+CP850		german.cp850.kbd		de.kbd.from-cp850
+
+ISO8859-7	gr.elot.acc.kbd			gr.elot.acc.kbd
+ISO8859-7	gr.us101.acc.kbd		gr.101.acc.kbd
+
+ISO8859-8	iw.iso8.kbd			il.kbd
+
+ISO8859-2	hr.iso.kbd			hr.kbd
+
+ISO8859-2	hu.iso2.101keys.kbd		hu.101.kbd
+ISO8859-2	hu.iso2.102keys.kbd		hu.102.kbd
+
+ARMSCII-8	hy.armscii-8.kbd		am.kbd
+
+ISO8859-1	icelandic.iso.kbd		is.kbd
+ISO8859-1	icelandic.iso.acc.kbd		is.acc.kbd
+
+ISO8859-1+EURO	it.iso.kbd			it.kbd
+
+ISO8859-1+YEN	jp.106.kbd			jp.kbd
+ISO8859-1+YEN	jp.106x.kbd			jp.capsctrl.kbd
+ISO8859-1+YEN	jp.pc98.kbd			jp.pc98.kbd
+ISO8859-1+YEN	jp.pc98.iso.kbd			jp.pc98.iso.kbd
+
+PT154		kk.pt154.kst.kbd		kz.kst.kbd
+PT154		kk.pt154.io.kbd			kz.io.kbd
+
+ISO8859-1	latinamerican.kbd		latinamerican.kbd
+ISO8859-1	latinamerican.iso.acc.kbd	latinamerican.acc.kbd
+
+ISO8859-4	lt.iso4.kbd			lt.kbd
+
+ISO8859-1	norwegian.iso.kbd		no.kbd
+ISO8859-1	norwegian.dvorak.kbd		no.dvorak.kbd
+
+ISO8859-2	pl_PL.ISO8859-2.kbd		pl.kbd
+ISO8859-2	pl_PL.dvorak.kbd		pl.dvorak.kbd
+
+ISO8859-1+EURO	pt.iso.kbd			pt.kbd
+ISO8859-1+EURO	pt.iso.acc.kbd			pt.acc.kbd
+
+CP866		ru.cp866.kbd			ru.kbd.from-cp866
+ISO8859-5	ru.iso5.kbd			ru.kbd.from-iso5
+KOI8-R		ru.koi8-r.kbd			ru.kbd
+KOI8-R		ru.koi8-r.shift.kbd		ru.shift.kbd
+KOI8-R		ru.koi8-r.win.kbd		ru.win.kbd
+
+ISO8859-1+EURO	spanish.dvorak.kbd		es.dvorak.kbd
+ISO8859-1+EURO	spanish.iso.kbd			es.kbd.from-iso1
+ISO8859-1+EURO	spanish.iso.acc.kbd		es.acc.kbd
+ISO8859-1+EURO	spanish.iso15.acc.kbd		es.kbd
+
+ISO8859-2	si.iso.kbd			si.kbd
+
+ISO8859-2	sk.iso2.kbd			sk.kbd
+
+ISO8859-1+EURO	swedish.iso.kbd			se.kbd
+CP850		swedish.cp850.kbd		se.kbd.from-cp850
+
+ISO8859-1+EURO	swissfrench.iso.kbd		ch-fr.kbd
+ISO8859-1+EURO	swissfrench.iso.acc.kbd		ch-fr.acc.kbd
+CP850		swissfrench.cp850.kbd		ch-fr.kbd.from-cp850
+
+ISO8859-1+EURO	swissgerman.iso.kbd		ch.kbd
+ISO8859-1+EURO	swissgerman.iso.acc.kbd		ch.acc.kbd
+CP850		swissgerman.cp850.kbd		ch.kbd.from-cp850
+ISO8859-1+EURO	swissgerman.macbook.acc.kbd	ch.macbook.acc.kbd
+
+ISO8859-9	tr.iso9.q.kbd			tr.kbd
+
+ISO8859-1+EURO	uk.iso.kbd			uk.kbd
+ISO8859-1+EURO	uk.iso-ctrl.kbd			uk.capsctrl.kbd
+#CP850		uk.cp850.kbd			uk.kbd.from-cp850		(no \xA4 and different Alt/Alt-Shift encodings)
+#CP850		uk.cp850-ctrl.kbd		uk.capsctrl.kbd.from-cp850	(no \xA4 and different Alt/Alt-Shift encodings)
+ISO8859-15	uk.dvorak.kbd			uk.dvorak.kbd
+
+ISO8859-1	us.iso.kbd			us.kbd
+ISO8859-1	us.iso.acc.kbd			us.acc.kbd
+ISO8859-1	us.dvorak.kbd			us.dvorak.kbd
+ISO8859-1	us.dvorakr.kbd			us.dvorakr.kbd
+ISO8859-1	us.dvorakl.kbd			us.dvorakl.kbd
+ISO8859-1	us.dvorakp.kbd			us.dvorakp.kbd
+ISO8859-1	us.dvorakx.kbd			us.dvorakx.kbd
+ISO8859-1	us.emacs.kbd			us.emacs.kbd
+ISO8859-1	us.pc-ctrl.kbd			us.ctrl.kbd
+ISO8859-1	us.unix.kbd			us.unix.kbd
+
+#ISO8859-5	ua.iso5.kbd			ua.kbd.from-iso5
+KOI8-U		ua.koi8-u.kbd			ua.kbd
+KOI8-U		ua.koi8-u.shift.alt.kbd		ua.shift.alt.kbd


Property changes on: trunk/tools/tools/vt/keymaps/KBDFILES.map
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/tools/tools/vt/keymaps/LANG.map
===================================================================
--- trunk/tools/tools/vt/keymaps/LANG.map	                        (rev 0)
+++ trunk/tools/tools/vt/keymaps/LANG.map	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,29 @@
+# $FreeBSD: stable/10/tools/tools/vt/keymaps/LANG.map 270131 2014-08-18 09:40:19Z se $
+bg bg ISO8859-5
+cs cs ISO8859-2
+da da ISO8859-15
+de de ISO8859-15
+el el ISO8859-7
+en en ISO8859-1
+es es ISO8859-1
+fi fi ISO8859-1
+fr fr ISO8859-1
+hr hr ISO8859-2
+hu hu ISO8859-2
+hy hy ARMSCII-8
+is is ISO8859-1
+it it ISO8859-15
+iw he ISO8859-8
+ja ja ISO8859-1
+kk kk PT154
+nl nl ISO8859-15
+no no ISO8859-1
+pl pl ISO8859-2
+pt pt ISO8859-15
+ro ro ISO8859-1
+ru ru KOI8-R
+sk sk ISO8859-2
+sl sl ISO8859-2
+sv sv ISO8859-1
+tr tr ISO8859-9
+uk uk KOI8-U


Property changes on: trunk/tools/tools/vt/keymaps/LANG.map
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: trunk/tools/tools/vt/keymaps/convert-INDEX.pl
===================================================================
--- trunk/tools/tools/vt/keymaps/convert-INDEX.pl	                        (rev 0)
+++ trunk/tools/tools/vt/keymaps/convert-INDEX.pl	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,94 @@
+#!/usr/local/bin/perl
+# $FreeBSD: stable/10/tools/tools/vt/keymaps/convert-INDEX.pl 270131 2014-08-18 09:40:19Z se $
+
+use Text::Iconv;
+use Encode;
+use strict;
+use utf8;
+
+# directories and filenames
+$0 =~ m:^(.*)/:;
+my $dir_convtool = $1 || ".";
+
+my $dir_keymaps_syscons = "/usr/src/share/syscons/keymaps";
+my $dir_keymaps_config = "$dir_convtool";
+
+my $dir_keymaps_vt = "/usr/src/share/vt/keymaps";
+my $dir_keymaps_output = "$dir_keymaps_vt/OUTPUT";
+
+my $keymap_index = "$dir_keymaps_syscons/INDEX.keymaps";
+
+my $language_map = "$dir_keymaps_config/LANG.map";
+my $keymapfile_map = "$dir_keymaps_config/KBDFILES.map";
+
+# global variables
+my %LANG_NEW;		# index: lang_old
+my %ENCODING;		# index: lang_old, file_old
+my %FILE_NEW;		# index: file_old
+
+# subroutines
+sub local_to_UCS_string
+{
+    my ($string, $old_enc) = @_;
+    my $converter = Text::Iconv->new($old_enc, "UTF-8");
+    my $result = $converter->convert($string);
+    printf "!!! conversion failed for '$string' ($old_enc)\n"
+	unless $result;
+    return $result;
+}
+
+sub lang_fixup {
+    my ($langlist) = @_;
+    my $result;
+    my $lang;
+    for $lang (split(/,/, $langlist)) {
+	$result .= ","
+	    if $result;
+	$result .= $LANG_NEW{$lang};
+    }
+    return $result;
+}
+
+# main program
+open LANGMAP, "<$language_map"
+    or die "$!";
+while (<LANGMAP>) {
+    next
+	if m/^#/;
+    my ($lang_old, $lang_new, $encoding) = split(" ");
+#    print "$lang_old|$lang_new|$encoding\n";
+    $LANG_NEW{$lang_old} = $lang_new;
+    $ENCODING{$lang_old} = $encoding;
+    $ENCODING{$lang_new} = $encoding;
+}
+close LANGMAP;
+
+$FILE_NEW{"MENU"} = "MENU"; # dummy identity mapping
+$FILE_NEW{"FONT"} = "FONT"; # dummy identity mapping
+open FILEMAP, "<$keymapfile_map"
+    or die "$!";
+while (<FILEMAP>) {
+    next
+	if m/^#/;
+    my ($encoding, $file_old, $file_new) = split(" ");
+#    print "--> ", join("|", $encoding, $file_old, $file_new, $file_locale), "\n";
+    if ($encoding and $file_old and $file_new) {
+	$ENCODING{$file_old} = $encoding;
+	$FILE_NEW{$file_old} = $file_new;
+    }
+}
+close FILEMAP;
+
+open MENUFILE, "<$keymap_index"
+    or die "$!";
+while (<MENUFILE>) {
+    if (m/^$/ or m/^#/) {
+	print;
+    } else {
+	my ($file_old, $langlist, $menutext) = split(/:/);
+	my ($lang) = split(/,/, $langlist); # first language in list selects encoding
+	$menutext = local_to_UCS_string($menutext, $ENCODING{$lang})
+	    unless $file_old eq "FONT";
+	printf "%s:%s:%s", $FILE_NEW{$file_old}, lang_fixup($langlist), $menutext;
+    }
+}


Property changes on: trunk/tools/tools/vt/keymaps/convert-INDEX.pl
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/keymaps/convert-keymap.pl
===================================================================
--- trunk/tools/tools/vt/keymaps/convert-keymap.pl	                        (rev 0)
+++ trunk/tools/tools/vt/keymaps/convert-keymap.pl	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,155 @@
+#!/usr/bin/perl
+# $FreeBSD: stable/10/tools/tools/vt/keymaps/convert-keymap.pl 271109 2014-09-04 17:21:54Z se $
+
+use Text::Iconv;
+use Encode;
+use strict;
+use utf8;
+
+# command line parsing
+die "Usage: $0 filename.kbd charset [EURO|YEN]\n"
+    unless ($ARGV[1]);
+
+my $inputfile = shift;					# first command argument
+my $converter = Text::Iconv->new(shift, "UTF-8");	# second argument
+my $use_euro;
+my $use_yen;
+my $current_char;
+my $current_scancode;
+
+while (my $arg = shift) {
+    $use_euro = 1, next
+	if $arg eq "EURO";
+    $use_yen = 1, next
+	if $arg eq "YEN";
+    die "Unknown encoding option '$arg'\n";
+}
+
+# converter functions
+sub local_to_UCS_string
+{
+    my ($string) = @_;
+
+    return $converter->convert($string);
+}
+
+sub prettyprint_token
+{
+    my ($ucs_char) = @_;
+
+    return "'" . chr($ucs_char) . "'"
+        if 32 <= $ucs_char and $ucs_char <= 126; # print as ASCII if possible
+#    return sprintf "%d", $ucs_char; # <---- temporary decimal
+    return sprintf "0x%02x", $ucs_char
+        if $ucs_char <= 255;        # print as hex number, else
+    return sprintf "0x%04x", $ucs_char;
+}
+
+sub local_to_UCS_code
+{
+    my ($char) = @_;
+
+    my $ucs_char = ord(Encode::decode("UTF-8", local_to_UCS_string($char)));
+
+    $current_char = lc(chr($ucs_char))
+	if $current_char eq "";
+
+    $ucs_char = 0x20ac	# replace with Euro character
+	if $ucs_char == 0xa4 and $use_euro and $current_char eq "e";
+
+    $ucs_char = 0xa5	# replace with Jap. Yen character on PC kbd
+	if $ucs_char == ord('\\') and $use_yen and $current_scancode == 125;
+
+#    $ucs_char = 0xa5	# replace with Jap. Yen character on PC98x1 kbd
+#	if $ucs_char == ord('\\') and $use_yen and $current_scancode == 13;
+
+    return prettyprint_token($ucs_char);
+}
+
+sub malformed_to_UCS_code
+{
+    my ($char) = @_;
+
+    return prettyprint_token(ord(Encode::decode("UTF-8", $char)));
+}
+
+sub convert_token
+{
+    my ($C) = @_;
+
+    return $1
+        if $C =~ m/^([a-z][a-z0-9]*)$/;		# key token
+    return local_to_UCS_code(chr($1))
+        if $C =~ m/^(\d+)$/;			# decimal number
+    return local_to_UCS_code(chr(hex($1)))
+        if $C =~ m/^0x([0-9a-f]+)$/i;		# hex number
+    return local_to_UCS_code(chr(ord($1)))
+        if $C =~ m/^'(.)'$/;			# character
+    return malformed_to_UCS_code($1)
+        if $C =~ m/^'(.+)'$/;			# character
+    return "<?$C?>";				# uncovered case
+}
+
+sub tokenize { # split on white space and parentheses (but not within token)
+    my ($line) = @_;
+
+    $line =~ s/'\('/ _lpar_ /g; # prevent splitting of '('
+    $line =~ s/'\)'/ _rpar_ /g; # prevent splitting of ')'
+    $line =~ s/'''/'_squote_'/g; # remove quoted single quotes from matches below
+    $line =~ s/([()])/ $1 /g; # insert blanks around remaining parentheses
+    my $matches;
+    do {
+	$matches = ($line =~ s/^([^']*)'([^']+)'/$1_squoteL_$2_squoteR_/g);
+    } while $matches;
+    $line =~ s/_squoteL_ _squoteR_/ _spc_ /g; # prevent splitting of ' '
+    my @KEYTOKEN = split (" ", $line);
+    grep(s/_squote[LR]?_/'/g, @KEYTOKEN);
+    grep(s/_spc_/' '/, @KEYTOKEN);
+    grep(s/_lpar_/'('/, @KEYTOKEN);
+    grep(s/_rpar_/')'/, @KEYTOKEN);
+    return @KEYTOKEN;
+}
+
+# main program
+open FH, "<$inputfile";
+while (<FH>) {
+    if (m/^#/) {
+	print local_to_UCS_string($_);
+    } elsif (m/^\s*$/) {
+	print "\n";
+    } else {
+	my @KEYTOKEN = tokenize($_);
+	my $at_bol = 1;
+	my $C;
+	foreach $C (@KEYTOKEN) {
+	    if ($at_bol) {
+		$current_char = "";
+		$current_scancode = -1;
+		if ($C =~ m/^\s*\d/) { # line begins with key code number
+		    $current_scancode = $C;
+		    printf "  %03d   ", $C;
+		} elsif ($C =~ m/^[a-z]/) { # line begins with accent name or paren
+		    printf "  %-4s ", $C; # accent name starts accent definition
+		} elsif ($C eq "(") {
+		    printf "%17s", "( "; # paren continues accent definition
+		} else {
+		    print "Unknown input line format: $_";
+		}
+		$at_bol = 0;
+	    } else {
+		if ($C =~ m/^([BCNO])$/) {
+		    print " $1"; # special case: effect of Caps Lock/Num Lock
+		} elsif ($C eq "(") {
+		    $current_char = "";
+		    print " ( ";
+		} elsif ($C eq ")") {
+		    print " )";
+		} else {
+		    printf "%-6s ", convert_token($C);
+		}
+	    }
+	}
+	print "\n";
+    }
+}
+close FH;


Property changes on: trunk/tools/tools/vt/keymaps/convert-keymap.pl
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/keymaps/convert-keymaps.pl
===================================================================
--- trunk/tools/tools/vt/keymaps/convert-keymaps.pl	                        (rev 0)
+++ trunk/tools/tools/vt/keymaps/convert-keymaps.pl	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,100 @@
+#!/usr/local/bin/perl
+# $FreeBSD: stable/10/tools/tools/vt/keymaps/convert-keymaps.pl 270308 2014-08-21 21:53:43Z se $
+
+use Text::Iconv;
+use Encode;
+use strict;
+use utf8;
+
+# directories and filenames
+$0 =~ m:^(.*)/:;
+my $dir_convtool = $1 || ".";
+
+my $dir_keymaps_syscons = "/usr/src/share/syscons/keymaps";
+my $dir_keymaps_config = "$dir_convtool";
+
+my $dir_keymaps_vt = "/usr/src/share/vt/keymaps";
+my $dir_keymaps_output = "$dir_keymaps_vt/OUTPUT";
+
+my $keymap_index = "$dir_keymaps_syscons/INDEX.keymaps";
+
+my $language_map = "$dir_keymaps_config/LANG.map";
+my $keymapfile_map = "$dir_keymaps_config/KBDFILES.map";
+
+# global variables
+my %LANG_NEW;		# index: lang_old
+my %ENCODING;		# index: lang_old, file_old
+my %FILE_NEW;		# index: file_old
+
+# subroutines
+sub local_to_UCS_string
+{
+    my ($string, $old_enc) = @_;
+    my $converter = Text::Iconv->new($old_enc, "UTF-8");
+    my $result = $converter->convert($string);
+    printf "!!! conversion failed for '$string' ($old_enc)\n"
+	unless $result;
+    return $result;
+}
+
+sub lang_fixup {
+    my ($langlist) = @_;
+    my $result;
+    my $lang;
+    for $lang (split(/,/, $langlist)) {
+	$result .= ","
+	    if $result;
+	$result .= $LANG_NEW{$lang};
+    }
+    return $result;
+}
+
+# main program
+open LANGMAP, "<$language_map"
+    or die "$!";
+while (<LANGMAP>) {
+    next
+	if m/^#/;
+    my ($lang_old, $lang_new, $encoding) = split(" ");
+#    print "$lang_old|$lang_new|$encoding\n";
+    $LANG_NEW{$lang_old} = $lang_new;
+    $ENCODING{$lang_old} = $encoding;
+    $ENCODING{$lang_new} = $encoding;
+}
+close LANGMAP;
+
+$FILE_NEW{"MENU"} = "MENU"; # dummy identity mapping
+$FILE_NEW{"FONT"} = "FONT"; # dummy identity mapping
+open FILEMAP, "<$keymapfile_map"
+    or die "$!";
+while (<FILEMAP>) {
+    next
+	if m/^#/;
+    my ($encoding, $file_old, $file_new) = split(" ");
+#    print "--> ", join("|", $encoding, $file_old, $file_new, $file_locale), "\n";
+    if ($encoding and $file_old and $file_new) {
+	$ENCODING{$file_old} = $encoding;
+	$FILE_NEW{$file_old} = $file_new;
+    }
+}
+close FILEMAP;
+
+my $kbdfile;
+foreach $kbdfile (glob("$dir_keymaps_syscons/*.kbd")) {
+    my $basename;
+    ($basename = $kbdfile) =~ s:.*/::;
+    my ($encoding) = $ENCODING{$basename};
+    $encoding =~ s/\+/ /g;		# e.g. "ISO8859-1+EURO" -> "ISO8859-1 EURO"
+    my $outfile = $FILE_NEW{$basename};
+    if ($encoding and $outfile) {
+	if (-r $kbdfile) {
+	    print "converting from '$basename' ($encoding) to '$outfile' (UCS)\n";
+	    my $cmdline = "$dir_convtool/convert-keymap.pl $kbdfile $encoding > $dir_keymaps_output/$outfile";
+	    system "$cmdline";
+	} else {
+	    print "$kbdfile not found\n";
+	}
+    } else {
+	print "Ignore '$basename': No encoding defined in KBDFILES.map\n";
+    }
+}


Property changes on: trunk/tools/tools/vt/keymaps/convert-keymaps.pl
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/mkkfont/Makefile
===================================================================
--- trunk/tools/tools/vt/mkkfont/Makefile	                        (rev 0)
+++ trunk/tools/tools/vt/mkkfont/Makefile	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,7 @@
+# $MidnightBSD$
+PROG=	mkkfont
+MAN1=
+
+WARNS?=	6
+
+.include <bsd.prog.mk>


Property changes on: trunk/tools/tools/vt/mkkfont/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/mkkfont/mkkfont.c
===================================================================
--- trunk/tools/tools/vt/mkkfont/mkkfont.c	                        (rev 0)
+++ trunk/tools/tools/vt/mkkfont/mkkfont.c	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,181 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2009 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Ed Schouten under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/tools/tools/vt/mkkfont/mkkfont.c 268950 2014-07-21 18:13:14Z emaste $");
+
+#include <sys/endian.h>
+#include <sys/param.h>
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct file_mapping {
+	uint32_t	source;
+	uint16_t	destination;
+	uint16_t	length;
+} __packed;
+
+struct file_header {
+	uint8_t		magic[8];
+	uint8_t		width;
+	uint8_t		height;
+	uint16_t	pad;
+	uint32_t	glyph_count;
+	uint32_t	map_count[4];
+} __packed;
+
+static int
+print_glyphs(struct file_header *fh)
+{
+	unsigned int gbytes, glyph_count, j, k, total;
+	uint8_t *gbuf;
+
+	gbytes = howmany(fh->width, 8) * fh->height;
+	glyph_count = be32toh(fh->glyph_count);
+
+	printf("\nstatic uint8_t font_bytes[%u * %u] = {", glyph_count, gbytes);
+	total = glyph_count * gbytes;
+	gbuf = malloc(total);
+
+	if (fread(gbuf, total, 1, stdin) != 1) {
+		perror("glyph");
+		return (1);
+	}
+
+	for (j = 0; j < total; j += 12) {
+		for (k = 0; k < 12 && k < total - j; k++) {
+			printf(k == 0 ? "\n\t" : " ");
+			printf("0x%02hhx,", gbuf[j + k]);
+		}
+	}
+
+	free(gbuf);
+	printf("\n};\n");
+
+	return (0);
+}
+
+static const char *map_names[4] = {
+    "normal", "normal_right", "bold", "bold_right" };
+
+static int
+print_mappings(struct file_header *fh, int map_index)
+{
+	struct file_mapping fm;
+	unsigned int nmappings, i, col = 0;
+
+	
+	nmappings = be32toh(fh->map_count[map_index]);
+
+	if (nmappings == 0)
+		return (0);
+
+	printf("\nstatic struct vt_font_map font_mapping_%s[%u] = {",
+	    map_names[map_index], nmappings);
+
+	for (i = 0; i < nmappings; i++) {
+		if (fread(&fm, sizeof fm, 1, stdin) != 1) {
+			perror("mapping");
+			return (1);
+		}
+
+		printf(col == 0 ? "\n\t" : " ");
+		printf("{ 0x%04x, 0x%04x, 0x%02x },",
+		    be32toh(fm.source), be16toh(fm.destination),
+		    be16toh(fm.length));
+		col = (col + 1) % 2;
+	}
+
+	printf("\n};\n");
+
+	return (0);
+}
+
+static int
+print_info(struct file_header *fh)
+{
+	unsigned int i;
+
+	printf(
+	    "\nstruct vt_font vt_font_default = {\n"
+	    "\t.vf_width\t\t= %u,\n"
+	    "\t.vf_height\t\t= %u,\n"
+	    "\t.vf_bytes\t\t= font_bytes,\n",
+	    fh->width, fh->height);
+
+	printf("\t.vf_map\t\t\t= {\n");
+	for (i = 0; i < 4; i++) {
+		if (fh->map_count[i] > 0)
+			printf("\t\t\t\t    font_mapping_%s,\n", map_names[i]);
+		else
+			printf("\t\t\t\t    NULL,\n");
+	}
+	printf("\t\t\t\t  },\n");
+	printf("\t.vf_map_count\t\t= { %u, %u, %u, %u },\n",
+	    be32toh(fh->map_count[0]),
+	    be32toh(fh->map_count[1]),
+	    be32toh(fh->map_count[2]),
+	    be32toh(fh->map_count[3]));
+	printf("\t.vf_refcount\t\t= 1,\n};\n");
+
+	return (0);
+}
+
+int
+main(int argc __unused, char *argv[] __unused)
+{
+	struct file_header fh;
+	unsigned int i;
+
+	if (fread(&fh, sizeof fh, 1, stdin) != 1) {
+		perror("file_header");
+		return (1);
+	}
+
+	if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
+		fprintf(stderr, "Bad magic\n");
+		return (1);
+	}
+
+	printf("#include <dev/vt/vt.h>\n");
+
+	if (print_glyphs(&fh) != 0)
+		return (1);
+	for (i = 0; i < 4; i++)
+		if (print_mappings(&fh, i) != 0)
+			return (1);
+	if (print_info(&fh) != 0)
+		return (1);
+
+	return (0);
+}


Property changes on: trunk/tools/tools/vt/mkkfont/mkkfont.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/mkkfont/terminus.sh
===================================================================
--- trunk/tools/tools/vt/mkkfont/terminus.sh	                        (rev 0)
+++ trunk/tools/tools/vt/mkkfont/terminus.sh	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,5 @@
+#!/bin/sh
+for i in 12 14 16 20 22 24 28 32
+do
+	zcat ../fontcvt/terminus-u${i}.vfnt.gz | ./mkkfont > terminus-u${i}.c
+done


Property changes on: trunk/tools/tools/vt/mkkfont/terminus.sh
___________________________________________________________________
Added: mnbsd:nokeywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/setfont/Makefile
===================================================================
--- trunk/tools/tools/vt/setfont/Makefile	                        (rev 0)
+++ trunk/tools/tools/vt/setfont/Makefile	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,7 @@
+# $MidnightBSD$
+PROG=	setfont
+MAN1=
+
+WARNS?=	6
+
+.include <bsd.prog.mk>


Property changes on: trunk/tools/tools/vt/setfont/Makefile
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/tools/tools/vt/setfont/setfont.c
===================================================================
--- trunk/tools/tools/vt/setfont/setfont.c	                        (rev 0)
+++ trunk/tools/tools/vt/setfont/setfont.c	2018-07-18 00:52:30 UTC (rev 11886)
@@ -0,0 +1,90 @@
+/* $MidnightBSD$ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/tools/tools/vt/setfont/setfont.c 262861 2014-03-06 18:30:56Z jhb $");
+
+#include <sys/consio.h>
+#include <sys/endian.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+struct file_header {
+	uint8_t		magic[8];
+	uint8_t		width;
+	uint8_t		height;
+	uint16_t	pad;
+	uint32_t	glyph_count;
+	uint32_t	map_count[4];
+} __packed;
+
+static vfnt_map_t *
+load_mappingtable(unsigned int nmappings)
+{
+	vfnt_map_t *t;
+	unsigned int i;
+
+	if (nmappings == 0)
+		return (NULL);
+
+	t = malloc(sizeof *t * nmappings);
+
+	if (fread(t, sizeof *t * nmappings, 1, stdin) != 1) {
+		perror("mappings");
+		exit(1);
+	}
+
+	for (i = 0; i < nmappings; i++) {
+		t[i].src = be32toh(t[i].src);
+		t[i].dst = be16toh(t[i].dst);
+		t[i].len = be16toh(t[i].len);
+	}
+
+	return (t);
+}
+
+int
+main(int argc __unused, char *argv[] __unused)
+{
+	struct file_header fh;
+	static vfnt_t vfnt;
+	size_t glyphsize;
+	unsigned int i;
+
+	if (fread(&fh, sizeof fh, 1, stdin) != 1) {
+		perror("file_header");
+		return (1);
+	}
+
+	if (memcmp(fh.magic, "VFNT0002", 8) != 0) {
+		fprintf(stderr, "Bad magic\n");
+		return (1);
+	}
+
+	for (i = 0; i < VFNT_MAPS; i++)
+		vfnt.map_count[i] = be32toh(fh.map_count[i]);
+	vfnt.glyph_count = be32toh(fh.glyph_count);
+	vfnt.width = fh.width;
+	vfnt.height = fh.height;
+
+	glyphsize = howmany(vfnt.width, 8) * vfnt.height * vfnt.glyph_count;
+	vfnt.glyphs = malloc(glyphsize);
+
+	if (fread(vfnt.glyphs, glyphsize, 1, stdin) != 1) {
+		perror("glyphs");
+		return (1);
+	}
+
+	for (i = 0; i < VFNT_MAPS; i++)
+		vfnt.map[i] = load_mappingtable(vfnt.map_count[i]);
+
+	if (ioctl(STDOUT_FILENO, PIO_VFONT, &vfnt) == -1) {
+		perror("PIO_VFONT");
+		return (1);
+	}
+
+	return (0);
+}


Property changes on: trunk/tools/tools/vt/setfont/setfont.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list