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 comma separated glyphs",}],
89 type => "=s", alias=>["lang"],
90 comment => "Comma separated list of desired languages"},],
92 {fieldname => "PrintLangs", alias => ["printlangs"],
93 comment => "Print supported languages"},],
95 {fieldname => "PrintProperties", alias => ["printproperties"],
96 comment => "Print properties from weight, slant and width"},],
98 {fieldname => "PrintScripts", alias => ["printscripts"],
99 comment => "Print supported scripts"},],
101 {fieldname => "PrintFiles", alias => ["printfiles"],
102 comment => "Print font file names"},],
104 {fieldname => "PrintWarnings",
105 comment => "Print warnings about discarded/overwritten fonts, conflicting styles"},],
107 my %options = %{&handleOptions(\@optionsDef)};
109 $options{Lang} = "" if (! defined($options{Lang}));
111 #############################################################
113 my @langs = split(',', $options{Lang});
114 for my $lg (@langs) {
115 $lg = &convertlang($lg);
119 if (defined($options{Contains})) {
120 for my $a (@{$options{Contains}}) {
121 push(@glyphs, decimalUnicode($a));
126 if (defined($langs[0])) {
127 $cmd .= " :lang=" . join(',', @langs);
130 my $format = "foundry=\"%{foundry}\"" .
131 " postscriptname=\"%{postscriptname}\"" .
132 " fn=\"%{fullname}\" fnl=\"%{fullnamelang}\"" .
133 " family=\"%{family}\" flang=\"%{familylang}\" " .
134 " style=\"%{style}\" stylelang=\"%{stylelang}\"";
136 if (exists($options{PrintScripts}) || defined($options{Scripts}) || defined($options{NSpripts}) || exists($options{Math})) {
137 $format .= " script=\"%{capability}\"";
139 if (exists($options{PrintLangs}) || defined($langs[0])) {
140 $format .= " lang=\"%{lang}\"";
142 if (exists($options{PrintProperties}) || defined($options{Property})) {
143 $format .= " weight=%{weight} slant=%{slant} width=%{width} spacing=%{spacing}";
145 if (defined($options{Contains})) {
146 $format .= " charset=\"%{charset}\"";
148 $format .= " file=\"%{file}\" abcd\\n";
149 $cmd .= " -f '$format'";
161 "default" => "Serif",
185 50 => "Ultracondensed",
186 63 => "Extracondensed",
188 87 => "Semicondensed",
190 113 => "Semiexpanded",
192 150 => "Extraexpanded",
193 200 => "Ultraexpanded",
201 "default" => "Proportional",
204 # Build reverse mappings, (not needed yet)
205 for my $txt (qw(ftypes weights slants widths spacings)) {
207 eval "\$map = \\%$txt";
208 for my $key (keys %{$map}) {
209 next if ($key !~ /^\d+$/);
210 my $value = lc($map->{$key});
211 $map->{"r"}->{$value} = $key;
218 my %collectedfonts = ();
220 otf => 0, # type 2, opentype CFF (Compact Font Format)
221 ttc => 1.1, # type 1 (True Type font Collection)
222 ttf => 1.2, # type 1 (True Type Font)
223 woff=> 1.3, # type 1 (Web Open Font Format)
224 t1 => 1.4, # type 1 (postscript)
225 pfb => 1.5, # type 1 (Printer Font Binary)
226 pfa => 1.6, # type 1 (Printer Font Ascii)
227 pcf => 5, # Bitmap (Packaged Collaboration Files)?
231 # list of regexes for known sans serif fonts
233 "value" => 100, # Sans serif
234 "a" => qr/^(arial|andika|angostura|anonymous|arab|aroania|arimo|asap)/i,
235 "b" => qr/^b(aekmuk|ebas|erenika|eteckna|euron|lue)/i,
236 "c" => qr/^c(abin|aliban|antarell|arbon|arlito|handas|hivo|mu bright|omfortaa|omic|oolvetica|ortoba|ousine|uprum|wtex(hei|yen)|yklop|ypro)/i,
237 "d" => qr/^(d2coding|dimnah|dosis|dyuthi)/i,
238 "e" => qr/^(electron|engebrechtre)/i,
239 "f" => qr/^(fandolhei|fetamont|fira|font awesome 5|forgotten)/i,
240 "g" => qr/^(gardiner|garuda|gfs ?neo|gillius|granada|graph|guanine|gunplay)/i,
241 "h" => qr/^(hack|hani|haramain|harano|harmattan|hor\b)/i,
242 "i" => qr/^(ibm plex|ikarius|inconsolata|induni.?h|iwona)/i,
243 "j" => qr/^(jara|jura)/i,
244 "k" => qr/^(kalimati|kanji|karla|kayrawan|kenyan|keraleeyam|khalid|khmer [or]|kiloji|klaudia|komatu|kurier)/i,
245 "l" => qr/^l(aksaman|arabie|ato|eague|exend|exigulim|ibel|iberation|ibre franklin|ibris|inux biolinum|obster|ogix|ohit|oma)/i,
246 "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,
247 "n" => qr/^(nachlieli|nada|nafees|nagham|nanum(barunpen|square)|nice)/i,
248 "o" => qr/^(ocr|okolaks|opendyslexic|ostorah|ouhud|over|oxygen)/i,
249 "p" => qr/^(padauk|padmaa|pagul|paktype|pakenham|palladio|petra|phetsarath|play\b|poiret|port\b|primer\b|prociono|pt\b|purisa)/i,
250 "q" => qr/^(qt(ancient|helvet|avanti|doghaus|eratype|eurotype|floraline|frank|fritz|future|greece|howard|letter|optimum)|quercus)/i,
251 "r" => qr/^(rachana|radio\b|raleway|ricty|roboto|rosario)/i,
252 "s" => qr/^(salem|samanata|sawasdee|shado|sharja|simple|sophia|soul|source|switzera)/i,
253 "t" => qr/^(tarablus|teen|texgyre(adventor|heros)|tiresias|trebuchet|tscu|tuffy)/i,
254 "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,
255 "v" => qr/^(veranda|vn ?urwclassico)/i,
256 "w" => qr/^(waree)/i,
257 "y" => qr/^(yanone)/i,
258 "z" => qr/^(zekton|zero)/i,
261 "value" => 110, # Script
262 "c" => qr/^(chancery)/i,
263 "d" => qr/^(dancing)/i,
264 "e" => qr/^(elegante)/i,
265 "k" => qr/^(kaushan|karumbi)/i,
266 "m" => qr/^(mathjax_script|miama)/i,
267 "n" => qr/^(nanum (brush|pen) script)/i,
268 "q" => qr/^qt(arabian|boulevard|brushstroke|chancery|coronation|florencia|handwriting|linostroke|merry|pandora|slogan)/i,
269 "r" => qr/^(romande.*|ruf)script/i,
270 "u" => qr/^(un ?pilgi|urw ?chancery)/i,
274 "value" => 120, # Fraktur
275 "j" => qr/^(jsmath.?euf)/i,
276 "m" => qr/^(missaali)/i,
277 "o" => qr/^(oldania)/i,
278 "q" => qr/^qt(blackforest|cloisteredmonk|dublinirish|fraktur|heidelbergtype|(lino|london)scroll)/i,
282 "value" => 130, # Fancy
283 "c" => qr/^(cretino)/i,
284 "g" => qr/^(gfs.?theo)/i,
288 "value" => 140, # Initials
289 "e" => qr/^(eb.?garamond.?init)/i,
290 "l" => qr/^(libertinus|linux).*initials/i,
291 "y" => qr/^(yinit)/i,
295 "value" => 200, # Symbol
296 "a" => qr/^(academicons)/i,
297 "c" => qr/^(caladings|ccicons|chess)/i,
298 "d" => qr/^(dingbats|drmsym)/i,
299 "e" => qr/^(elusiveicons|emoji)/i,
300 "f" => qr/^(fdsymbol|fourierorns)/i,
302 "m" => qr/^(marvosym|material)/i,
303 "n" => qr/^(noto.*emoji)/i,
304 "o" => qr/^(octicons)/i,
305 "q" => qr/^(qtdingbits)/i,
306 "t" => qr/^(typicons|twemoji)/i,
307 "w" => qr/^(webdings)/i,
310 if (open(FI, "$cmd |")) {
311 NXTLINE: while (my $l = <FI>) {
313 while ($l !~ /abcd$/) {
319 if ($l =~ /file=\"([^\"]+)\"/) {
321 #next if ($file !~ /\.(otf|ttf|pfa|pfb|pcf|ttc)$/i);
322 if ($file !~ /\.([a-z0-9]{2,5})$/i) {
323 print "Unhandled extension for file $file\n";
327 if (! defined($fontpriority{$fonttype})) {
328 print "Added extension $fonttype for file $file\n";
329 $fontpriority{$fonttype} = $nexttype;
334 if ($l =~ / lang=\"([^\"]+)\"/) {
335 my @ll = split(/\|/, $1);
337 $usedlangs{&convertlang($lx)} = 1;
341 for my $lang (@langs) {
342 next NXTLINE if (! defined($usedlangs{$lang}));
344 if (defined($options{Contains})) {
346 if ($l =~ / charset=\"([^\"]+)\"/) {
347 my @list = split(/\s+/, $1);
349 my ($l, $h) = split('-', $e);
350 $h = $l if (! defined($h));
351 push(@charlist, [hex($l), hex($h)]);
354 for my $g (@glyphs) {
355 next NXTLINE if (! contains($g, \@charlist));
358 my $style = &getVal($l, "style", "stylelang");
359 $style =~ s/^\\040//;
360 my $fullname = &getVal($l, "fn", "fnl");
361 my $postscriptname = "";
362 if ($l =~ /postscriptname=\"([^\"]+)\"/) {
363 $postscriptname = $1;
365 my $family = &getVal($l, "family", "flang");
366 $family =~ s/\\040/\-/;
368 if (length($fullname) < 3) {
369 if (length($postscriptname) < 2) {
370 $fontname = "$family $style";
373 $fontname = $postscriptname;
377 $fontname = $fullname;
379 if (defined($options{NFontName})) {
380 for my $fn (@{$options{NFontName}}) {
381 next NXTLINE if ($fontname =~ /$fn/i);
384 if (defined($options{FontName})) {
385 for my $fn (@{$options{FontName}}) {
386 next NXTLINE if ($fontname !~ /$fn/i);
391 if (exists($options{PrintProperties}) || defined($options{Property}) || defined($options{NProperty})) {
392 my $properties = getproperties($l, $fontname, $style, \@errors);
393 if (defined($options{Property})) {
394 for my $pn (@{$options{Property}}) {
395 next NXTLINE if ($properties !~ /$pn/i);
398 if (defined($options{NProperty})) {
399 for my $pn (@{$options{NProperty}}) {
400 next NXTLINE if ($properties =~ /$pn/i);
403 if (exists($options{PrintProperties})) {
404 $props .= " ($properties)";
408 if (exists($options{PrintLangs})) {
409 $props .= '(' . join(',', sort keys %usedlangs) . ')';
411 if (exists($options{PrintScripts}) || defined($options{Scripts}) || defined($options{NScripts}) || exists($options{Math})) {
414 if ($l =~ / script=\"([^\"]+)\"/) {
415 @scripts = split(/\s+/, $1);
416 for my $ent (@scripts) {
417 $ent =~ s/^\s*otlayout://;
420 $scripts = join(',', @scripts);
422 if (exists($options{Math})) {
423 next NXTLINE if (! &ismathfont($fontname,\@scripts));
425 if (exists($options{PrintScripts})) {
426 $props .= "($scripts)";
428 if (!defined($scripts[0])) {
429 # No script defined in font, so check only $options{Scripts}
430 next NXTLINE if (defined($options{Scripts}));
433 if (defined($options{Scripts})) {
434 for my $s (@{$options{Scripts}}) {
435 next NXTLINE if ($scripts !~ /$s/i);
438 if (defined($options{NScripts})) {
439 for my $s (@{$options{NScripts}}) {
440 next NXTLINE if ($scripts =~ /$s/i);
446 if ($l =~ /foundry=\"([^\"]+)\"/) {
448 $foundry =~ s/^\s+//;
449 $foundry =~ s/\s+$//;
451 if (defined($collectedfonts{$fontname}->{$foundry}->{errors})) {
452 # Apparently not the first one, so add some info
453 my $oldfonttype = $collectedfonts{$fontname}->{$foundry}->{fonttype};
454 if (defined($errors[0])) {
455 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, @errors);
457 if ($fontpriority{$oldfonttype} > $fontpriority{$fonttype}) {
458 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, "Warning: overwriting old info for file: " . $collectedfonts{$fontname}->{$foundry}->{file});
461 push(@{$collectedfonts{$fontname}->{$foundry}->{errors}}, "Warning: discarding new info for file: $file");
466 $collectedfonts{$fontname}->{$foundry}->{errors} = \@errors;
468 $collectedfonts{$fontname}->{$foundry}->{props} = $props;
469 $collectedfonts{$fontname}->{$foundry}->{file} = $file;
470 $collectedfonts{$fontname}->{$foundry}->{fonttype} = $fonttype;
475 for my $fontname (sort keys %collectedfonts) {
476 my @foundries = sort keys %{$collectedfonts{$fontname}};
477 my $printfoundries = 0;
478 if (defined($foundries[1])) {
481 for my $foundry (@foundries) {
482 if (exists($options{PrintWarnings})) {
483 for my $err (@{$collectedfonts{$fontname}->{$foundry}->{errors}}) {
487 my $fn = "Font : $fontname";
488 if ($printfoundries && ($foundry ne "")) {
489 $fn .= " \[$foundry\]";
492 print $collectedfonts{$fontname}->{$foundry}->{props};
493 if (exists($options{PrintFiles})) {
494 print ": " . $collectedfonts{$fontname}->{$foundry}->{file} . "\n";
503 #################################################################################
507 if ($ilang =~ /^\s*([a-z]+)([\-_]([a-z]+))?\s*$/i) {
508 my ($x, $y) = ($1, $3);
510 $ilang = lc($x) . '-' . lc($y);
521 my ($l, $islang, $txt, $rres) = @_;
523 if ($l =~ /$txt=\"([^\"]+)\"/) {
524 @res = split(',', $1);
527 $lg = &convertlang($lg);
536 my ($lang, $rlangs) = @_;
539 for (my $i = 0; defined($rlangs->[$i]); $i++) {
540 if ($rlangs->[$i] eq $lang) {
549 my ($l, $txtval, $txtlang) = @_;
552 &extractlist($l, 0, $txtval, \@values);
553 return("") if (! defined($values[0]));
554 &extractlist($l, 1, $txtlang, \@langs);
555 my $i = &getIndexes("en", \@langs);
558 if (defined($values[$k]) && (length($values[$k]) > length($res))) {
562 return($values[0]) if ($res eq "");
566 sub getsinglevalue($$$)
568 my ($l, $txt, $rMap, $rget) = @_;
570 if ($l =~ / $txt=(\d+)/) {
572 # Search for nearest value to $val
573 if (defined($rMap->{$val})) {
574 return($rMap->{$val});
578 for my $key (keys %{$rMap}) {
579 next if ($key !~ /^\d+$/);
580 my $diff = abs($key - $val);
585 elsif ($diff == $minv) {
591 if (! defined($rMap->{$maxv})) {
592 print "ERROR2: txt=$txt, val=$val\n";
596 return($rMap->{$maxv} . "+$minv");
599 return($rMap->{$maxv} . "-$minv");
609 my ($txt, $val) = @_;
610 return("$txt($val)");
615 my ($fontname, $style) = @_;
616 if ($fontname =~ /(sans)[-_ ]?(serif)?/i) {
617 return($ftypes{100}); # Sans Serif
619 elsif ($fontname =~ /gothic|dotum|gulim/i) {
620 if ($fontname =~ /bisrat gothic/i) {
621 return($ftypes{0}); # Serif
624 return($ftypes{100}); # Sans Serif
627 elsif ($fontname =~ /serif|times|mincho|batang/i) {
628 if ($fontname =~ /good times/i) {
629 return($ftypes{100}); # Sans Serif
631 elsif ($fontname !~ /initials/i) {
632 return($ftypes{0}); # Serif
635 # Now check for fonts without a hint in font name
636 if ($fontname =~ /([a-z])/i) {
638 for my $rFonts (\%sansFonts, \%scriptFonts, \%fraktFonts, \%fancyFonts, \%initialFonts, \%symbolFonts) {
639 if (defined($rFonts->{$key})) {
640 if ($fontname =~ $rFonts->{$key}) {
641 return($ftypes{$rFonts->{"value"}});
646 if ("$fontname" =~ /^bpg/i) {
647 if ("$fontname" =~ /bpg (courier gpl|elite)/i) {
648 return($ftypes{0}); # Serif
651 return($ftypes{100}); # Sans Serif
654 elsif ("$fontname" =~ /^dustismo/i) {
655 if ("$fontname" =~ /^dustismo roman/i) {
656 return($ftypes{0}); # Serif
659 return($ftypes{100}); # Sans Serif
662 elsif ("$fontname" =~ /^go\b/i) {
663 if ("$fontname" =~ /^go mono/i) {
664 return($ftypes{0}); # Serif
667 return($ftypes{100}); # Sans Serif
677 my ($fontname, $style) = @_;
679 for my $key (keys %weights) {
680 next if ($key !~ /^\d+$/);
681 my $val = $weights{$key};
682 for my $info ($style, $fontname) {
683 if ($info =~ /\b$val\b/i) {
684 if ($val eq "Regular") {
685 $result = $val; # It may refer to width
698 my ($fontname, $style) = @_;
700 for my $key (keys %widths) {
701 next if ($key !~ /^\d+$/);
702 for my $info ($style, $fontname) {
703 if ($info =~ /\b$widths{$key}\b/i) {
704 return($widths{$key});
706 if ($info =~ /\bRegular\b/) {
707 if (!defined($result)) {
708 $result = $widths{100};
718 my ($fontname, $style) = @_;
719 for my $key (keys %slants) {
720 next if ($key !~ /^\d+$/);
721 if ($style =~ /\b$slants{$key}\b/i) {
722 return($slants{$key});
730 my ($fontname, $style) = @_;
731 for my $key (keys %spacings) {
732 next if ($key !~ /^\d+$/);
733 if ($style =~ /\b$spacings{$key}\b/i) {
734 return($spacings{$key});
737 if ("$fontname $style" =~ /(mono|typewriter|cursor|fixed)\b/i) {
738 return($spacings{100}); # Mono
747 my ($fontname, $rCapability) = @_;
749 return 1 if ($fontname =~ /math/i);
750 for my $cap (@{$rCapability}) {
751 return 1 if ($cap eq "math");
756 sub getproperties($$$$)
758 my ($l, $fontname, $style, $rerrors) = @_;
759 my $newstyle = &correctstyle($style);
760 my $newfam = &correctstyle($fontname);
763 for my $txt (qw(ftype weight width slant spacing)) {
765 eval("\$map = " . '\%' . $txt . 's');
766 eval('$rget = \&' . "get$txt");
767 my $val2 = getsinglevalue($l, $txt, $map);
768 my $val1 = $rget->($newfam, $newstyle);
770 if (defined($val2) && defined($val1) && ($val2 ne $val1)) {
771 push(@{$rerrors}, "Fontname($fontname),Style($style): Values for $txt ($val1 != $val2) differ, selecting internal $txt($val2)");
774 elsif (! defined($val2)) {
781 push(@properties, &addTxt($txt,$val));
784 if (defined($map->{"default"})) {
785 push(@properties, &addTxt($txt,$map->{"default"}));
788 push(@{$rerrors}, "Undefined value for $txt");
792 return(join(' ', @properties));
798 $style =~ s/^\\040//;
799 $style =~ s/^\s*\d+\s*//;
800 $style =~ s/\s*\d+$//;
801 $style =~ s/italic/ Italic/i;
802 $style =~ s/oblique/ Oblique/i;
803 $style =~ s/[\-_]/ /g;
804 $style =~ s/\breg\b/Regular/i;
805 $style =~ s/\bregita(lic)?\b/Regular Italic/i;
806 $style =~ s/\bregobl(ique)?\b/Regular Oblique/i;
807 $style =~ s/medium/Medium /i;
808 $style =~ s/\bmedita(lic)?\b/Medium Italic/i;
809 $style =~ s/\bmedobl(ique)?\b/Medium Oblique/i;
810 $style =~ s/\bmed\b/Medium /i;
811 $style =~ s/\bdemi\b/SemiBold/i;
812 $style =~ s/\bex(pd|t)\b/Expanded/i;
813 $style =~ s/semi ?cond(ensed)?/SemiCondensed/i;
814 $style =~ s/[sd]emi ?(bold|bd|bol)/SemiBold/i;
815 $style =~ s/semi ?(expanded|extended|expd)/SemiExpanded/i;
816 $style =~ s/[sd]emi ?light/SemiLight/i;
817 $style =~ s/ultra ?(expanded|extended|expd)/UltraExpanded/i;
818 $style =~ s/light/Light /i;
819 $style =~ s/\blt\b/Light /i;
820 $style =~ s/(ultra|extra)(light|lt)/ExtraLight /i;
821 $style =~ s/\bheavy\b/Extrabold/i;
822 $style =~ s/\bhairline\b/Extralight/i;
823 $style =~ s/\bcond\b/Condensed/i;
824 $style =~ s/(roman)?slanted/ Italic/i;
825 $style =~ s/\bslant\b/Italic/i;
826 $style =~ s/\b(SC|Small(caps(alt)?)?)\b/SmallCaps/i;
827 $style =~ s/w3 mono/Dual/i;
828 $style =~ s/Regul[ea]r/Regular/i;
833 sub decimalUnicode($)
836 if ($a =~ /^u\+(.+)$/i) {
838 if ($a =~ /^0?x(.+)$/) {
843 return(ord(decode('utf-8', $a)));
848 my ($d, $rList) = @_;
849 for my $re (@{$rList}) {
850 return 0 if ($re->[0] > $d);
851 return 1 if ($re->[1] >= $d);