+
+sub sprintIntervalls($)
+{
+ my ($rList) = @_;
+ my @out = ();
+ for my $rE (@{$rList}) {
+ if ($rE->[0] != $rE->[1]) {
+ push(@out, $rE->[0] . '-' . $rE->[1]);
+ }
+ else {
+ push(@out, $rE->[0]);
+ }
+ }
+ return join(',', @out);
+}
+
+sub buildFontName($$)
+{
+ my ($family, $style) = @_;
+
+ my $result = "";
+ $style =~ s/\\040//;
+ $family =~ s/\\040/\-/;
+ $family =~ s/\bcond\b/Condensed/i;
+ $family =~ s/\bblk\b/Black/i;
+ $family =~ s/\bsembd\b/SemiBold/i;
+ $family =~ s/\bsemcond\b/SemiCondensed/i;
+ $family =~ s/\bextcond\b/ExtraCondensed/i;
+ $family =~ s/\bextbd\b/ExtraBold/i;
+ $family =~ s/\bextlt\b/ExtraLight/i;
+ $family =~ s/\bmed\b/Medium/i;
+ if ($family =~ /^([A-Z]*[a-z]+)([A-Z]\w+)\b(.*)$/) {
+ $family = $1 . splitatlU($2) . $3;
+ }
+ $family =~ s/^Ant Polt\b/Antykwa Poltawskiego/;
+ $family =~ s/\b(Semi|Extra) (Bold|Condensed|Expanded|Light)\b/$1$2/;
+ my @style = &splitStyle($style);
+ for my $st (@style) {
+ $st = ucfirst($st);
+ if ($family !~ s/$st/$st/i) {
+ $family .= " $st";
+ }
+ else {
+ # check if $st in $family starts with ' '
+ $family =~ s/(\w)$st/$1 $st/i;
+ }
+ }
+ $result = $family;
+ return($result, join(' ', @style));
+}
+
+# split text at change from lower case to upper case
+sub splitatlU($)
+{
+ my ($txt) = @_;
+ if ($txt =~ /^([A-Z]+[a-z]*)(.*)$/) {
+ if (defined($mapShortcuts{$1})) {
+ return(" " . $mapShortcuts{$1} . splitatlU($2));
+ }
+ else {
+ return(" $1" . splitatlU($2));
+ }
+ }
+ return($txt);
+}
+
+sub splitStyle($)
+{
+ my @in = split(/[- ]/, $_[0]);
+ my @result = ();
+ my $prefix = "";
+ for my $en (@in) {
+ while ($en =~ s/^([A-Z][a-z]+)//) {
+ my $found = $1;
+ if ($found =~ /^(Semi|Extra)$/) {
+ $prefix = $found;
+ next;
+ }
+ elsif (defined($mapShortcuts{$found})) {
+ $found = $mapShortcuts{$found};
+ }
+ push(@result, "$prefix$found");
+ $prefix = "";
+ }
+ if ($en ne "") {
+ push(@result, "$prefix$en");
+ $prefix = "";
+ }
+ }
+ return(@result);
+}