summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/hyph-utf8/make-exhyph.pl
blob: 3fe44239d21a19ce5c614f6320f726a30d0daacf (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
#!/usr/bin/perl
# -*- coding: utf-8; -*-
# Copyright (C) 2008 Vladimir Volovich.
# You may freely use, modify and/or distribute this file.
#
# Generate additional patterns (for some language), to be used in case
# there is an alternative hyphen character available.
#
# It enables the hyphenation of words containing explicit hyphens
# when using fonts with \hyphenchar\font <> `\- (e.g. T1 or T2A encoding).
#
# sample usage: perl make-exhyph.pl ru > exhyph-ru.tex

use strict;
use utf8;
binmode(STDOUT, ":utf8");

my %alphabet = (
  'ru' => [ qw( а б в г д е ё ж з и й к л м н о п р с т у ф х ц ч ш щ ъ ы ь э ю я ) ],
  'uk' => [ qw( а б в г ґ д е є ж з и і ї й к л м н о п р с т у ф х ц ч ш щ ь ю я ' ) ]
);

my $lang = $ARGV[0];
die "unspecified lang" if ! defined $lang;
die "invalid lang" if ! exists $alphabet{$lang};

my @alphabet = @{$alphabet{$lang}};

print <<\EOF;
\begingroup
\lccode45=45 % Make hyphen "-" a word constituent
\patterns{
8-7
--8
EOF

for my $l (@alphabet) {
  print ".${l}-8\n";
}

for my $l1 (@alphabet) {
  for my $l2 (@alphabet) {
    print "-${l1}8${l2}8\n8${l1}8${l2}-\n";
  }
}

print <<\EOF;
}
\endgroup
EOF