#!/usr/bin/perl
# polskie-krzaczki.pl
# (c) copyright 2001 by wojtek kaniewski <wojtekka@irc.pl>
# 
# this script modifies font.desc file so polish characters from iso-8859-2
# and windows-1250 charsets are in the right place.

%trans = qw( 0x104  0x104  0x105  0x105  0x106  0x107  0x118  0x119
	   0x141  0x142  0x143  0x144  0x15a  0x15a  0x15b  0x15b
	   0x179  0x179  0x17a  0x17a  0x17b  0x17c);

open (DESC, ($ARGV[0]) ? $ARGV[0] : "font.desc") ||
	die "Can't open font description file";

while (<DESC>) {
	chomp;
	
	if (!/^0x/) {
		next;
	}
	
	($char, $begin, $end) = split(/ +/, $_);

	foreach $i (keys %trans) {
		if ($char eq $trans{$i}) {
			$key = sprintf("0x%.2x", ord($i));
			$new{$key} = $begin . " " . $end;
		}
	}
}

seek (DESC, 0, 0);

while (<DESC>) {
	if (!/^0x/) {
		print $_;
		next;
	}

	($char) = split(/ +/, $_);

	if ($new{$char}) {
		print $char . " " . $new{$char} . "\n";
	} else {
		print $_;
	}
}

close (DESC);
