summaryrefslogtreecommitdiff
path: root/Build/source/texk/xdvipdfmx/src/mk_agl_standard_c.pl
blob: 93a7b7984fdf1c80ac44d823fa4eaf8ba787c45b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

# mk_agl_standard_nam_c.pl -- convert STANDARD.NAM and glyphlist.txt
# to C source for xdvipdfmx;
# this allows us to have the standard list compiled into the binary,
# and so the user doesn't have to install a glyphlist file separately.

# usage:
#
#   mk_agl_standard_nam_c.pl STANDARD.NAM glyphlist.txt > agl_standard.c
#
# where STANDARD.NAM is the glyph name list in FontLab's format,
# and glyphlist.txt is the Adobe glyph name list as found at
# http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt
#
# xdvipdfmx includes data derived from STANDARD.NAM
# by kind permission of Adam Twardoch.

print << "__EOT__";
#include "agl.h"

char* agl_standard_names[] = {
__EOT__

my %knownNames;
while (<ARGV>) {
	s/ *[\r\n]+$//;
	s/[\#%].*//;
	next if $_ eq '';
	if (m/^0x[0-9A-Fa-f]{4}/) {
		my ($unicode, $name) = split(/ +/);
		next unless defined $name and defined $unicode;
		$name =~ s/^!//;
		next if exists $knownNames{$name};
		$knownNames{$name} = 1;
		$unicode =~ s/^0x//;
		print "  \"$name;$unicode\",\n";
		next;
	}
	if (m/^.+;[0-9A-Fa-f]{4}/) {
		my ($name, $unicodes) = split(/;/);
		next unless defined $name and defined $unicodes;
		next if exists $knownNames{$name};
		print "  \"$name;$unicodes\",\n";
	}
}

print << "__EOT__";
  "" /* terminator */
};
__EOT__