]> git.lyx.org Git - lyx.git/blobdiff - development/autotests/useSystemFonts.pl
ctests: uninvert a few Farsi splash tests
[lyx.git] / development / autotests / useSystemFonts.pl
index 843a3d4f0912dc2d4d4a0f3b2e9b78d0994d804a..eca4508d2725a78d692788eb15ca63b8876f9d3c 100644 (file)
@@ -6,8 +6,8 @@
 # 2.) While copying,
 #   2a.) searches for relative references to files and
 #        replaces them with absolute ones
-#   2b.) In order to be able to compile with luatex or xetex
-#        changes default fonts to use non-tex-fonts instead
+#   2b.) Changes default fonts to use non-tex-fonts
+#   2c.) Changes the non-tex fonts setting if it is "default" (see below).
 #
 # Syntax: perl useSystemFonts.pl sourceFile destFile format
 # Each param represents a path to a file
@@ -65,7 +65,7 @@ sub getLangEntry();
 
 # convert lyx file to be compilable with xetex
 
-my ($source, $dest, $format, $fontT, $languageFile, $rest) = @ARGV;
+my ($source, $dest, $format, $fontT, $encodingT, $languageFile, $rest) = @ARGV;
 my %encodings = ();      # Encoding with TeX fonts, depending on language tag
 
 diestack("Too many arguments") if (defined($rest));
@@ -73,6 +73,7 @@ diestack("Sourcefilename not defined") if (! defined($source));
 diestack("Destfilename not defined") if (! defined($dest));
 diestack("Format (e.g. pdf4) not defined") if (! defined($format));
 diestack("Font type (e.g. texF) not defined") if (! defined($fontT));
+diestack("Encoding (e.g. ascii) not defined") if (! defined($encodingT));
 
 $source = File::Spec->rel2abs($source);
 $dest = File::Spec->rel2abs($dest);
@@ -90,7 +91,7 @@ if ($fontT eq "systemF") {
     $font{sans} = "DejaVu Sans";
     $font{typewriter} = "DejaVu Sans Mono";
   }
-  elsif ($lang =~ /^(he|el|main)$/) {
+  elsif ($lang =~ /^(he)$/) {
     $font{roman} = "FreeSans";
     $font{sans} = "FreeSans";
     $font{typewriter} = "FreeSans";
@@ -100,16 +101,11 @@ if ($fontT eq "systemF") {
     $font{sans} = "FreeFarsi";
     $font{typewriter} = "FreeFarsi Monospace";
   }
-  elsif ($lang eq "zh_CN") {
-    $font{roman} = "WenQuanYi Micro Hei";
-    $font{sans} = "WenQuanYi Micro Hei";
-    $font{typewriter} = "WenQuanYi Micro Hei";
-  }
-  elsif ($lang eq "ko" ) {
-    $font{roman} = "NanumGothic"; # NanumMyeongjo, NanumGothic Eco, NanumGothicCoding
-    $font{sans} = "NanumGothic";
-    $font{typewriter} = "NanumGothic";
-  }
+  # elsif ($lang eq "ko" ) {
+  #   $font{roman} = "NanumGothic"; # NanumMyeongjo, NanumGothic Eco, NanumGothicCoding
+  #   $font{sans} = "NanumGothic";
+  #   $font{typewriter} = "NanumGothic";
+  # }
   elsif ($lang eq "ar" ) {
     # available in 'fonts-sil-scheherazade' package
     $font{roman} = "Scheherazade";
@@ -123,6 +119,13 @@ if ($fontT eq "systemF") {
     $font{typewriter} = "FreeMono";
   }
 }
+elsif ($encodingT ne "default") {
+  # set input encoding to the requested value
+  $inputEncoding = {
+        "search" => '.*', # this will be substituted from '\inputencoding'-line
+       "out" => $encodingT,
+    };
+}
 elsif (0) { # set to '1' to enable setting of inputencoding
   # use tex font here
   my %encoding = ();
@@ -152,7 +155,7 @@ elsif (0) { # set to '1' to enable setting of inputencoding
 my $sourcedir = dirname($source);
 my $destdir = dirname($dest);
 if (! -d $destdir) {
-  diestack("could not make dir \"$destdir\"") if (! mkdir $destdir);
+  diestack("could not make dir \"$destdir\"") if (! mkpath $destdir);
 }
 
 my $destdirOfSubdocuments;
@@ -165,7 +168,7 @@ my $destdirOfSubdocuments;
 if(-d $destdirOfSubdocuments) {
   rmtree($destdirOfSubdocuments);
 }
-mkdir($destdirOfSubdocuments); #  for possibly included files
+mkpath($destdirOfSubdocuments);        #  for possibly included files
 
 my %IncludedFiles = ();
 my %type2hash = (
@@ -205,8 +208,12 @@ sub interpretedCopy($$$$)
 
   initLyxStack(\%font, $fontT, $inputEncoding);
 
+  my $fi_line_no = 0;
+  my @path_errors = ();
   while (my $l = <FI>) {
-    chomp($l);
+    $fi_line_no += 1;
+    $l =~ s/[\n\r]+$//;
+    #chomp($l);
     my $rStatus = checkLyxLine($l);
     if ($rStatus->{found}) {
       my $rF = $rStatus->{result};
@@ -243,6 +250,24 @@ sub interpretedCopy($$$$)
              $res += $res1;
            }
          }
+         else {
+           if (! -e "$f") {
+             # Non relative (e.g. with absolute path) file should exist
+             if ($rStatus->{"filetype"} eq "interpret") {
+               # filetype::interpret should be interpreted by lyx or latex and therefore emit error
+               # We prinnt a warning instead
+               print "WARNING: Interpreted file \"$f\" not found, at \"$source:$fi_line_no\"\n";
+             }
+             elsif ($rStatus->{"filetype"} eq "prefix_only") {
+               # filetype::prefix_only should be interpreted by latex
+               print "WARNING: Prefixed file \"$f\" not found, at \"$source:$fi_line_no\"\n";
+             }
+             else {
+               # Collect the path-error-messages
+               push(@path_errors, "File \"$f(" . $rStatus->{"filetype"} . ")\" not found, at \"$source:$fi_line_no\"");
+             }
+           }
+         }
        }
        if ($foundrelative) {
          $rF->[$fidx] = join($separator, @{$filelist});
@@ -254,6 +279,12 @@ sub interpretedCopy($$$$)
   }
   close(FI);
   close(FO);
+  if (@path_errors > 0) {
+    for my $entry (@path_errors) {
+      print "ERROR: $entry\n";
+    }
+    diestack("Aborted because of path errors in \"$source\"");
+  }
 
   closeLyxStack();
   return($res);