#!/usr/bin/octave --quiet
%
% Display results of Latex badbox test.
% These are generated from a shell script that runs latex.

types = {'cmr', 'times', 'newcent', 'palatino' }; 
%, ... 'cmr-microtype', 'times-microtype', 'newcent-microtype', 'palatino-microtype'};

hbmax = [];
hbmean = [];
hbcount = [];
for n = 1:numel(types),
	t = types{n};
	clear d; % expect input data in `d'
	source(['results_',t,'.m']);
	for m = 1:size(d,1),
		hbmax(n,m)    = max(d{m,2});
		hbmean(n,m)   = mean(d{m,2});
		hbcount(n,m)  = length(d{m,2});
	end
end
x = [ d{:,1} ];


tofile=0; % write figures to files rather than displaying them all

figure;
plot(x, hbmax);
legend(types);
grid('on');
xlabel('variation of textwidth [mm]');
ylabel('maximum overfullness of an hbox [pt]');
if tofile,
	print('max.png','-dpng');
	close;
end
figure;
plot(x, hbmean);
legend(types);
grid('on');
xlabel('variation of textwidth [mm]');
ylabel('mean overfullness of hboxes [pt]');
if tofile,
	print('mean.png','-dpng');
	close;
end
figure;
plot(x, hbcount);
legend(types);
grid('on');
xlabel('variation of textwidth [mm]');
ylabel('number of overfull hboxes');
if tofile,
	print('count.png','-dpng');
	close;
end


