4 # file listFontWithLang.pl
5 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING
7 # or at http://www.lyx.org/about/licence.php
10 # Full author contact details are available in the file CREDITS
11 # or at https://www.lyx.org/Credits
13 # Usage: listFontWithLang.pl <options>
14 # Displays installed system font names selected by <options>
15 # Option-strings with more that 1 char need be prefixed by '--'
17 # Option to get list of options: -h
19 # Some equivalencies for instance with option -n
24 # Options and option-parameter are case insensitive
28 my $p = File::Spec->rel2abs( __FILE__ );
29 $p =~ s/[\/\\]?[^\/\\]+$//;
39 sub extractlist($$$); # my ($l, $islang, $txt, $rres) = @_;
41 sub getVal($$$); # my ($l, $txtval, $txtlang) = @_;
42 sub getproperties($$$$);
45 sub decimalUnicode($);
48 # Following fields for a parameter can be defined:
49 # fieldname: Name of entry in %options
50 # type: [:=][sif], ':' = optional, '=' = required, 's' = string, 'i' = integer, 'f' = float
51 # alias: reference to a list of aliases e.g. ["alias1", "alias2", ... ]
52 # listsep: Separator for multiple data
53 # comment: Parameter description
55 # help + verbose already handled in 'GetOptions'
57 {fieldname => "FontName", listsep => ',',
58 type => "=s", alias => ["name"],
59 comment => "Select font-names matching these (comma separated) regexes"},],
61 {fieldname => "NFontName",
62 type => "=s", listsep => ',',
63 comment => "Select font-names NOT matching these (comma separated) regexes"},],
65 {fieldname => "Property",
66 type => "=s", listsep => ',',
67 comment => "Select fonts with properties matching these (comma separated) regexes"},],
69 {fieldname => "NProperty",
70 type => "=s", listsep => ',',
71 comment => "Select fonts with properties NOT matching these (comma separated) regexes"},],
73 {fieldname => "Scripts",
74 type => "=s", listsep => ',',
75 comment => "Select fonts with scripts matching these (comma separated) regexes"},],
77 {fieldname => "NScripts",
78 type => "=s", listsep => ',',
79 comment => "Select fonts with scripts NOT matching these (comma separated) regexes"},],
82 comment => "Select fonts probably containing math glyphs"},],
84 {fieldname => "Contains",
85 type => "=s", listsep => ',',
86 comment => "Select fonts containing all these (possibly comma separated) glyphs",}],
89 type => "=s", alias=>["lang"],
90 comment => "Comma separated list of desired languages"},],
92 {fieldname => "PrintCharset", alias => ["printcharset"],
93 comment => "Print intervals of supported unicode character values"},],
95 {fieldname => "PrintLangs", alias => ["printlangs"],
96 comment => "Print supported languages"},],
98 {fieldname => "PrintProperties", alias => ["printproperties"],
99 comment => "Print properties from weight, slant and width"},],
101 {fieldname => "PrintScripts", alias => ["printscripts"],
102 comment => "Print supported scripts"},],
104 {fieldname => "PrintFiles", alias => ["printfiles"],
105 comment => "Print font file names"},],
107 {fieldname => "PrintWarnings",
108 comment => "Print warnings about discarded/overwritten fonts, conflicting styles"},],
110 my %options = %{&handleOptions(\@optionsDef)};
112 $options{Lang} = "" if (! defined($options{Lang}));
114 #############################################################
116 my @langs = split(',', $options{Lang});
117 for my $lg (@langs) {
118 $lg = &convertlang($lg);
122 if (defined($options{Contains})) {
123 for my $a (@{$options{Contains}}) {
124 push(@glyphs, decimalUnicode($a));
126 @glyphs = sort {$a <=> $b;} @glyphs;
130 if (defined($langs[0])) {
131 $cmd .= " :lang=" . join(',', @langs);
134 my $format = "foundry=\"%{foundry}\"" .
135 " postscriptname=\"%{postscriptname}\"" .
136 " fn=\"%{fullname}\" fnl=\"%{fullnamelang}\"" .
137 " family=\"%{family}\" flang=\"%{familylang}\" " .
138 " style=\"%{style}\" stylelang=\"%{stylelang}\"";
140 if (exists($options{PrintScripts}) || defined($options{Scripts}) || defined($options{NSpripts}) || exists($options{Math})) {
141 $format .= " script=\"%{capability}\"";
143 if (exists($options{PrintLangs}) || defined($langs[0])) {
144 $format .= " lang=\"%{lang}\"";
146 if (exists($options{PrintProperties}) || defined($options{Property}) || defined($options{NProperty})) {
147 $format .= " weight=%{weight} slant=%{slant} width=%{width} spacing=%{spacing}";
149 if (defined($options{Contains}) || exists($options{PrintCharset})) {
150 $format .= " charset=\"%{charset}\"";
152 $format .= " file=\"%{file}\" abcd\\n";
153 $cmd .= " -f '$format'";
165 "default" => "Serif",
189 50 => "Ultracondensed",
190 63 => "Extracondensed",
192 87 => "Semicondensed",
194 113 => "Semiexpanded",
196 150 => "Extraexpanded",
197 200 => "Ultraexpanded",
205 "default" => "Proportional",
208 # Build reverse mappings, (not needed yet)
209 for my $txt (qw(ftypes weights slants widths spacings)) {
211 eval "\$map = \\%$txt";
212 for my $key (keys %{$map}) {
213 next if ($key !~ /^\d+$/);
214 my $value = lc($map->{$key});
215 $map->{"r"}->{$value} = $key;
222 my %collectedfonts = ();
224 otf => 0, # type 2, opentype CFF (Compact Font Format)
225 ttc => 1.1, # type 1 (True Type font Collection)
226 ttf => 1.2, # type 1 (True Type Font)
227 woff=> 1.3, # type 1 (Web Open Font Format)
228 t1 => 1.4, # type 1 (postscript)
229 pfb => 1.5, # type 1 (Printer Font Binary)
230 pfa => 1.6, # type 1 (Printer Font Ascii)
231 pcf => 5, # Bitmap (Packaged Collaboration Files)?
235 # list of regexes for known sans serif fonts
237 "value" => 100, # Sans serif
238 "a" => qr/^(arial|andika|angostura|anonymous|arab|aroania|arimo|asap)/i,
239 "b" => qr/^b(aekmuk|ebas|erenika|eteckna|euron|lue)/i,
240 "c" => qr/^c(abin|aliban|antarell|arbon|arlito|handas|hivo|mu bright|omfortaa|omic|oolvetica|ortoba|ousine|uprum|wtex(hei|yen)|yklop|ypro)/i,
241 "d" => qr/^(d2coding|dimnah|dosis|dyuthi)/i,
242 "e" => qr/^(electron|engebrechtre)/i,
243 "f" => qr/^(fandolhei|fetamont|fira|font awesome 5|forgotten)/i,
244 "g" => qr/^(gardiner|garuda|gfs ?neo|gillius|granada|graph|guanine|gunplay)/i,
245 "h" => qr/^(hack|hani|haramain|harano|harmattan|hor\b)/i,
246 "i" => qr/^(ibm plex|ikarius|inconsolata|induni.?h|iwona)/i,
247 "j" => qr/^(jara|jura)/i,
248 "k" => qr/^(kalimati|kanji|karla|kayrawan|kenyan|keraleeyam|khalid|khmer [or]|kiloji|klaudia|komatu|kurier)/i,
249 "l" => qr/^l(aksaman|arabie|ato|eague|exend|exigulim|ibel|iberation|ibre franklin|ibris|inux biolinum|obster|ogix|ohit|oma)/i,
250 "m" => qr/^m(\+ |anchu|anjari|arcellus|ashq|eera|etal|igmix|igu|ikachan|intspirit|ona|onlam|ono(fonto|id|isome|noki)|ontserrat|otoyal|ukti|usica)/i,
251 "n" => qr/^(nachlieli|nada|nafees|nagham|nanum(barunpen|square)|nice)/i,
252 "o" => qr/^(ocr|okolaks|opendyslexic|ostorah|ouhud|over|oxygen)/i,
253 "p" => qr/^(padauk|padmaa|pagul|paktype|pakenham|palladio|petra|phetsarath|play\b|poiret|port\b|primer\b|prociono|pt\b|purisa)/i,
254 "q" => qr/^(qt(ancient|helvet|avanti|doghaus|eratype|eurotype|floraline|frank|fritz|future|greece|howard|letter|optimum)|quercus)/i,
255 "r" => qr/^(rachana|radio\b|raleway|ricty|roboto|rosario)/i,
256 "s" => qr/^(salem|samanata|sawasdee|shado|sharja|simple|sophia|soul|source|switzera)/i,
257 "t" => qr/^(tarablus|teen|texgyre(adventor|heros)|tiresias|trebuchet|tscu|tuffy)/i,
258 "u" => qr/^(ubuntu|ukij (bom|chechek|cjk|diwani|ekran|elipbe|inchike|jelliy|kufi|qara|qolyazma|teng|title|tor)|umpush|un ?(dinaru|jamo|graphic|taza|vada|yetgul)|uni(kurd|space|versalis)|uroob|urw ?classico)/i,
259 "v" => qr/^(veranda|vn ?urwclassico)/i,
260 "w" => qr/^(waree)/i,
261 "y" => qr/^(yanone)/i,
262 "z" => qr/^(zekton|zero)/i,
265 "value" => 110, # Script
266 "c" => qr/^(chancery)/i,
267 "d" => qr/^(dancing)/i,
268 "e" => qr/^(elegante)/i,
269 "k" => qr/^(kaushan|karumbi)/i,
270 "m" => qr/^(mathjax_script|miama)/i,
271 "n" => qr/^(nanum (brush|pen) script)/i,
272 "q" => qr/^qt(arabian|boulevard|brushstroke|chancery|coronation|florencia|handwriting|linostroke|merry|pandora|slogan)/i,
273 "r" => qr/^(romande.*|ruf)script/i,
274 "u" => qr/^(un ?pilgi|urw ?chancery)/i,
278 "value" => 120, # Fraktur
279 "j" => qr/^(jsmath.?euf)/i,
280 "m" => qr/^(missaali)/i,
281 "o" => qr/^(oldania)/i,
282 "q" => qr/^qt(blackforest|cloisteredmonk|dublinirish|fraktur|heidelbergtype|(lino|london)scroll)/i,
286 "value" => 130, # Fancy
287 "c" => qr/^(cretino)/i,
288 "g" => qr/^(gfs.?theo)/i,
292 "value" => 140, # Initials
293 "e" => qr/^(eb.?garamond.?init)/i,
294 "l" => qr/^(libertinus|linux).*initials/i,
295 "y" => qr/^(yinit)/i,
299 "value" => 200, # Symbol
300 "a" => qr/^(academicons)/i,
301 "c" => qr/^(caladings|ccicons|chess)/i,
302 "d" => qr/^(dingbats|drmsym)/i,
303 "e" => qr/^(elusiveicons|emoji)/i,
304 "f" => qr/^(fdsymbol|fourierorns)/i,
306 "m" => qr/^(marvosym|material)/i,
307 "n" => qr/^(noto.*emoji)/i,
308 "o" => qr/^(octicons)/i,
309 "q" => qr/^(qtdingbits)/i,
310 "t" => qr/^(typicons|twemoji)/i,
311 "w" => qr/^(webdings)/i,
314 if (open(FI, "$cmd |")) {
315 NXTLINE: while (my $l = <FI>) {
317 while ($l !~ /abcd$/) {
323 if ($l =~ /file=\"([^\"]+)\"/) {
325 #next if ($file !~ /\.(otf|ttf|pfa|pfb|pcf|ttc)$/i);
326 if ($file !~ /\.([a-z0-9]{2,5})$/i) {
327 print "Unhandled extension for file $file\n";
331 if (! defined($fontpriority{$fonttype})) {
332 print "Added extension $fonttype for file $file\n";
333 $fontpriority{$fonttype} = $nexttype;
338 if ($l =~ / lang=\"([^\"]+)\"/) {
339 my @ll = split(/\|/, $1);
341 $usedlangs{&convertlang($lx)} = 1;
345 for my $lang (@langs) {
346 next NXTLINE if (! defined($usedlangs{$lang}));
349 if (defined($options{Contains}) || exists($options{PrintCharset})) {
350 if ($l =~ / charset=\"([^\"]+)\"/) {
351 my @list = split(/\s+/, $1);
353 my ($l, $h) = split('-', $e);
354 $h = $l if (! defined($h));
355 push(@charlist, [hex($l), hex($h)]);
358 if (defined($options{Contains})) {
359 for my $g (@glyphs) {
360 next NXTLINE if (! contains($g, \@charlist));
364 my $style = &getVal($l, "style", "stylelang");
365 $style =~ s/^\\040//;
366 my $fullname = &getVal($l, "fn", "fnl");
367 my $postscriptname = "";
368 if ($l =~ /postscriptname=\"([^\"]+)\"/) {
369 $postscriptname = $1;
371 my $family = &getVal($l, "family", "flang");
372 $family =~ s/\\040/\-/;
374 if (length($fullname) < 3) {
375 if (length($postscriptname) < 2) {
376 $fontname = "$family $style";
379 $fontname = $postscriptname;
383 $fontname = $fullname;
385 if (defined($options{NFontName})) {
386 for my $fn (@{$options{NFontName}}) {
387 next NXTLINE if ($fontname =~ /$fn/i);
390 if (defined($options{FontName})) {
391 for my $fn (@{$options{FontName}}) {
392 next NXTLINE if ($fontname !~ /$fn/i);
397 if (exists($options{PrintProperties}) || defined($options{Property}) || defined($options{NProperty})) {
398 my $properties = getproperties($l, $fontname, $style, \@errors);
399 if (defined($options{Property})) {
400 for my $pn (@{$options{Property}}) {
401 next NXTLINE if ($properties !~ /$pn/i);
404 if (defined($options{NProperty})) {
405 for my $pn (@{$options{NProperty}}) {
406 next NXTLINE if ($properties =~ /$pn/i);
409 if (exists($options{PrintProperties})) {
410 $props .= " ($properties)";
414 if (exists($options{PrintLangs})) {
415 $props .= '(' . join(',', sort keys %usedlangs) . ')';
417 if (exists($options{PrintCharset})) {
419 for my $rE (@charlist) {
420 if ($rE->[0] != $rE->[1]) {
421 push(@out, $rE->[0] . '-' . $rE->[1]);
424 push(@out, $rE->[0]);
427 $props .= '(' . join(',', @out) . ')';
429 if (exists($options{PrintScripts}) || defined($options{Scripts}) || defined($options{NScripts}) || exists($options{Math})) {
432 if ($l =~ / script=\"([^\"]+)\"/) {
433 @scripts = split(/\s+/, $1);
434 for my $ent (@scripts) {
435 $ent =~ s/^\s*otlayout://;
438 $scripts = join(',', @scripts);
440 if (exists($options{Math})) {
441 next NXTLINE if (! &ismathfont($fontname,\@scripts));
443 if (exists($options{PrintScripts})) {
444 $props .= "($scripts)";
446 if (!defined($scripts[0])) {
447 # No script defined in font, so check only $options{Scripts}
448 next NXTLINE if (defined($options{Scripts}));
451 if (defined($options{Scripts})) {
452 for my $s (@{$options{Scripts}}) {
453 next NXTLINE if ($scripts !~ /$s/i);
456 if (defined($options{NScripts})) {
457 for my $s (@{$options{NScripts}}) {
458 next NXTLINE if ($scripts =~ /$s/i);
464 if ($l =~ /foundry=\"([^\"]+)\"/) {
466 $foundry =~ s/^\s+//;
467 $foundry =~ s/\s+$//;
469 if (defined($collectedfonts{$fontname}->{$foundry}->{errors})) {
470 # Apparently not the first one, so add some info
471 my $oldfonttype = $collectedfonts{$fontname}->{$foundry}->{fonttype};
472 if (defined($errors[0])) {
473 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, @errors);
475 if ($fontpriority{$oldfonttype} > $fontpriority{$fonttype}) {
476 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, "Warning: overwriting old info for file: " . $collectedfonts{$fontname}->{$foundry}->{file});
479 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, "Warning: discarding new info for file: $file");
484 $collectedfonts{$fontname}->{$foundry}->{errors} = \@errors;
486 $collectedfonts{$fontname}->{$foundry}->{props} = $props;
487 $collectedfonts{$fontname}->{$foundry}->{file} = $file;
488 $collectedfonts{$fontname}->{$foundry}->{fonttype} = $fonttype;
493 for my $fontname (sort keys %collectedfonts) {
494 my @foundries = sort keys %{$collectedfonts{$fontname}};
495 my $printfoundries = 0;
496 if (defined($foundries[1])) {
499 for my $foundry (@foundries) {
500 if (exists($options{PrintWarnings})) {
501 for my $err (@{$collectedfonts{$fontname}->{$foundry}->{errors}}) {
505 my $fn = "Font : $fontname";
506 if ($printfoundries && ($foundry ne "")) {
507 $fn .= " \[$foundry\]";
510 print $collectedfonts{$fontname}->{$foundry}->{props};
511 if (exists($options{PrintFiles})) {
512 print ": " . $collectedfonts{$fontname}->{$foundry}->{file} . "\n";
521 #################################################################################
525 if ($ilang =~ /^\s*([a-z]+)([\-_]([a-z]+))?\s*$/i) {
526 my ($x, $y) = ($1, $3);
528 $ilang = lc($x) . '-' . lc($y);
539 my ($l, $islang, $txt, $rres) = @_;
541 if ($l =~ /$txt=\"([^\"]+)\"/) {
542 @res = split(',', $1);
545 $lg = &convertlang($lg);
554 my ($lang, $rlangs) = @_;
557 for (my $i = 0; defined($rlangs->[$i]); $i++) {
558 if ($rlangs->[$i] eq $lang) {
567 my ($l, $txtval, $txtlang) = @_;
570 &extractlist($l, 0, $txtval, \@values);
571 return("") if (! defined($values[0]));
572 &extractlist($l, 1, $txtlang, \@langs);
573 my $i = &getIndexes("en", \@langs);
576 if (defined($values[$k]) && (length($values[$k]) > length($res))) {
580 return($values[0]) if ($res eq "");
584 sub getsinglevalue($$$)
586 my ($l, $txt, $rMap, $rget) = @_;
588 if ($l =~ / $txt=(\d+)/) {
590 # Search for nearest value to $val
591 if (defined($rMap->{$val})) {
592 return($rMap->{$val});
596 for my $key (keys %{$rMap}) {
597 next if ($key !~ /^\d+$/);
598 my $diff = abs($key - $val);
603 elsif ($diff == $minv) {
609 if (! defined($rMap->{$maxv})) {
610 print "ERROR2: txt=$txt, val=$val\n";
614 return($rMap->{$maxv} . "+$minv");
617 return($rMap->{$maxv} . "-$minv");
627 my ($txt, $val) = @_;
628 return("$txt($val)");
633 my ($fontname, $style) = @_;
634 if ($fontname =~ /(sans)[-_ ]?(serif)?/i) {
635 return($ftypes{100}); # Sans Serif
637 elsif ($fontname =~ /gothic|dotum|gulim/i) {
638 if ($fontname =~ /bisrat gothic/i) {
639 return($ftypes{0}); # Serif
642 return($ftypes{100}); # Sans Serif
645 elsif ($fontname =~ /serif|times|mincho|batang/i) {
646 if ($fontname =~ /good times/i) {
647 return($ftypes{100}); # Sans Serif
649 elsif ($fontname !~ /initials/i) {
650 return($ftypes{0}); # Serif
653 # Now check for fonts without a hint in font name
654 if ($fontname =~ /([a-z])/i) {
656 for my $rFonts (\%sansFonts, \%scriptFonts, \%fraktFonts, \%fancyFonts, \%initialFonts, \%symbolFonts) {
657 if (defined($rFonts->{$key})) {
658 if ($fontname =~ $rFonts->{$key}) {
659 return($ftypes{$rFonts->{"value"}});
664 if ("$fontname" =~ /^bpg/i) {
665 if ("$fontname" =~ /bpg (courier gpl|elite)/i) {
666 return($ftypes{0}); # Serif
669 return($ftypes{100}); # Sans Serif
672 elsif ("$fontname" =~ /^dustismo/i) {
673 if ("$fontname" =~ /^dustismo roman/i) {
674 return($ftypes{0}); # Serif
677 return($ftypes{100}); # Sans Serif
680 elsif ("$fontname" =~ /^go\b/i) {
681 if ("$fontname" =~ /^go mono/i) {
682 return($ftypes{0}); # Serif
685 return($ftypes{100}); # Sans Serif
695 my ($fontname, $style) = @_;
697 for my $key (keys %weights) {
698 next if ($key !~ /^\d+$/);
699 my $val = $weights{$key};
700 for my $info ($style, $fontname) {
701 if ($info =~ /\b$val\b/i) {
702 if ($val eq "Regular") {
703 $result = $val; # It may refer to width
716 my ($fontname, $style) = @_;
718 for my $key (keys %widths) {
719 next if ($key !~ /^\d+$/);
720 for my $info ($style, $fontname) {
721 if ($info =~ /\b$widths{$key}\b/i) {
722 return($widths{$key});
724 if ($info =~ /\bRegular\b/) {
725 if (!defined($result)) {
726 $result = $widths{100};
736 my ($fontname, $style) = @_;
737 for my $key (keys %slants) {
738 next if ($key !~ /^\d+$/);
739 if ($style =~ /\b$slants{$key}\b/i) {
740 return($slants{$key});
748 my ($fontname, $style) = @_;
749 for my $key (keys %spacings) {
750 next if ($key !~ /^\d+$/);
751 if ($style =~ /\b$spacings{$key}\b/i) {
752 return($spacings{$key});
755 if ("$fontname $style" =~ /(mono|typewriter|cursor|fixed)\b/i) {
756 return($spacings{100}); # Mono
765 my ($fontname, $rCapability) = @_;
767 return 1 if ($fontname =~ /math/i);
768 for my $cap (@{$rCapability}) {
769 return 1 if ($cap eq "math");
774 sub getproperties($$$$)
776 my ($l, $fontname, $style, $rerrors) = @_;
777 my $newstyle = &correctstyle($style);
778 my $newfam = &correctstyle($fontname);
781 for my $txt (qw(ftype weight width slant spacing)) {
783 eval("\$map = " . '\%' . $txt . 's');
784 eval('$rget = \&' . "get$txt");
785 my $val2 = getsinglevalue($l, $txt, $map);
786 my $val1 = $rget->($newfam, $newstyle);
788 if (defined($val2) && defined($val1) && ($val2 ne $val1)) {
789 push(@{$rerrors}, "Fontname($fontname),Style($style): Values for $txt ($val1 != $val2) differ, selecting internal $txt($val2)");
792 elsif (! defined($val2)) {
799 push(@properties, &addTxt($txt,$val));
802 if (defined($map->{"default"})) {
803 push(@properties, &addTxt($txt,$map->{"default"}));
806 push(@{$rerrors}, "Undefined value for $txt");
810 return(join(' ', @properties));
816 $style =~ s/^\\040//;
817 $style =~ s/^\s*\d+\s*//;
818 $style =~ s/\s*\d+$//;
819 $style =~ s/italic/ Italic/i;
820 $style =~ s/oblique/ Oblique/i;
821 $style =~ s/[\-_]/ /g;
822 $style =~ s/\breg\b/Regular/i;
823 $style =~ s/\bregita(lic)?\b/Regular Italic/i;
824 $style =~ s/\bregobl(ique)?\b/Regular Oblique/i;
825 $style =~ s/medium/Medium /i;
826 $style =~ s/\bmedita(lic)?\b/Medium Italic/i;
827 $style =~ s/\bmedobl(ique)?\b/Medium Oblique/i;
828 $style =~ s/\bmed\b/Medium /i;
829 $style =~ s/\bdemi\b/SemiBold/i;
830 $style =~ s/\bex(pd|t)\b/Expanded/i;
831 $style =~ s/semi ?cond(ensed)?/SemiCondensed/i;
832 $style =~ s/[sd]emi ?(bold|bd|bol)/SemiBold/i;
833 $style =~ s/semi ?(expanded|extended|expd)/SemiExpanded/i;
834 $style =~ s/[sd]emi ?light/SemiLight/i;
835 $style =~ s/ultra ?(expanded|extended|expd)/UltraExpanded/i;
836 $style =~ s/light/Light /i;
837 $style =~ s/\blt\b/Light /i;
838 $style =~ s/(ultra|extra)(light|lt)/ExtraLight /i;
839 $style =~ s/\bheavy\b/Extrabold/i;
840 $style =~ s/\bhairline\b/Extralight/i;
841 $style =~ s/\bcond\b/Condensed/i;
842 $style =~ s/(roman)?slanted/ Italic/i;
843 $style =~ s/\bslant\b/Italic/i;
844 $style =~ s/\b(SC|Small(caps(alt)?)?)\b/SmallCaps/i;
845 $style =~ s/w3 mono/Dual/i;
846 $style =~ s/Regul[ea]r/Regular/i;
851 # return list of unicode values of the input string
852 sub decimalUnicode($)
856 while ($a =~ s/u\+(0?x[\da-f]+|\d+)//i) {
858 if ($d =~ /^0?x(.+)$/) {
863 # maybe $a is a string of unicode chars?
864 my $u = decode('utf-8', $a);
865 my @a = split(//, $u);
872 # check if the glyph-value $d is contained
873 # in one of the (sorted) intervals
876 my ($d, $rList) = @_;
877 for my $re (@{$rList}) {
878 next if ($re->[1] < $d);
879 return 1 if ($re->[0] <= $d);