Ajustement taille des accords selon taille des paroles
authorHugo Villeneuve <hugo@hugovil.com>
Thu, 17 Mar 2022 03:44:51 +0000 (23:44 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Thu, 17 Mar 2022 04:32:27 +0000 (00:32 -0400)
gtx2tex.pl

index 4717d85..01bf47e 100644 (file)
@@ -54,6 +54,9 @@ $verbose && print "$output\n";
 
 $libpath="/usr/local/lib/guitartex";
 
+$song_size = "normalsize";
+$new_song_init = "1";
+
 # load configuration file
 $home=$ENV{"HOME"};
 $verbose && print "home=$home\n";
@@ -150,6 +153,22 @@ while ( <CHORDPRO> ) {
 
     $verbose && print "  chordpro data\n";
 
+    if ($new_song_init) {
+       # Augmente la taille des accords par rapport à la taille des paroles:
+       $inc_song_size = $song_size;
+       if ($song_size eq "footnotesize") { $inc_song_size = "small" }
+       if ($song_size eq "small")        { $inc_song_size = "normalsize" }
+       if ($song_size eq "normalsize")   { $inc_song_size = "large" }
+       if ($song_size eq "large")        { $inc_song_size = "Large" }
+       if ($song_size eq "Large")        { $inc_song_size = "LARGE" }
+       if ($song_size eq "LARGE")        { $inc_song_size = "huge" }
+       if ($song_size eq "huge")         { $inc_song_size = "Huge" }
+
+        print TEX "\\renewcommand{\\gtxchordsize}{\\$inc_song_size}\n";
+
+       $new_song_init = "";
+    }
+
     crdpro();
 }
 
@@ -315,6 +334,8 @@ sub directive{
 
         # Réinitialisation à la fonte normale
         print TEX "\\normalsize\n";
+       $song_size = "normalsize";
+       $new_song_init = "1";
 
         if ( $output eq "pdf" ) { print TEX "\\pdfdest name {$_} fith \\pdfoutline goto name {$_} {$_}" }
 
@@ -396,6 +417,8 @@ sub directive{
     }elsif ( /{size:/ ) {
         s/(\{.*:)(.+)(\})/\2/;
         print TEX "\\$_\n";
+       $song_size = $_;
+       $verbose && print "Song size: $song_size\n";
     }
 }
 
@@ -612,7 +635,7 @@ sub latex_header {
                                                                               %\\makebox[0.5cm][r]{\\scriptsize\\theverscnt\\normalsize}%
                                                                               %\\makebox[0.5cm]{}}
     %
-                                                    \\newcommand{\\gtxchordsize}{\\footnotesize}
+                                                    \\newcommand{\\gtxchordsize}{\\$song_size}
     \\setlength{\\parindent}{0pt}
 
     % Modification pour augmenter la taille des accords.
@@ -630,10 +653,10 @@ sub latex_header {
     \\ifthenelse{\\lengthtest{\\wd\\textbox>\\wd\\gtxchordbox}}%
     {%
          % Boîte pour les accords (plus gros)
-         \\raisebox{2.5ex}[2ex][2.5ex]{\\makebox[0pt][l]{\\small\\bf#1}}#2%
+         \\raisebox{2.5ex}[2ex][2.5ex]{\\makebox[0pt][l]{\\gtxchordsize\\bf#1}}#2%
                                        }{%
                                              % Boîte pour les accords (plus gros)
-                                             \\raisebox{2.5ex}[2ex][2.5ex]{\\makebox[0pt][l]{\\small\\bf#1}}\\makebox[\\wd\\gtxchordbox+0.5em][l]{#2}%
+                                             \\raisebox{2.5ex}[2ex][2.5ex]{\\makebox[0pt][l]{\\gtxchordsize\\bf#1}}\\makebox[\\wd\\gtxchordbox+0.5em][l]{#2}%
                                                                            }%
                                          }%