% Copyright (C) 2014 The Patacrep Team
% Copyright (C) 2009-2010 Romain Goffe, Alexandre Dupas
% Copyright (C) 2008 Kevin W. Hamlen
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program; if not, write to the Free Software
% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
% MA  02110-1301, USA.

(* variables *)
schema:
  type: //rec
  optional:
    chordfont: //str
    chordcolor: //str
    versefont: //str
    chorusfont: //str
    geometry: //str
    column_adjustment:
      type: //any
      of:
        - type: //str
          value: "only_one"
        - type: //str
          value: "one_more"
        - type: //str
          value: "none"
default:
  en:
    chordfont: "i"
    chordcolor: "000000"
    versefont: ""
    chorusfont: "i"
    geometry: "a4paper"
    column_adjustment: none
description:
  en:
    chordfont: "Chord font (i, b, n)"
    chordcolor: "Chord color, hexadecimal notation"
    versefont: "Verse font (i, b, n)"
    chorusfont: "Chorus font (i, b, n)"
    geometry: "Paper geometry (size, margin, orientation...), as options of the LaTeX geometry package."
    column_adjustment: "Column adjsutment."
  fr:
    chordfont: "Police des accords"
    chordcolor: "Couleur des accords en notation hexadécimale"
    versefont: "Police des couplets"
    chorusfont: "Police des refrains"
    geometry: "Format du papier (taille, marges, orientation...), avec le même format que les options du paquet LaTeX geometry."
    column_adjustment: "Ajustement des colonnes."


(* endvariables *)

% begin document
(* extends "patacrep.tex" *)

(* block preambule *)
(*- set template_var = _template["data.tex"] -*)
\usepackage{licence}

%! Font management
\makeatletter
\renewcommand{\chorusfont}{%
   (* for letter in template_var.chorusfont *)
   (* if letter=="i" *)   \it %
   (* elif letter=='b' *)   \bf %
   (* elif letter=='n' *)   \normalfont %
   (* endif *)
   (* endfor *)
}

\def\@chordfont{%
   (* for letter in template_var.chordfont *)
   (* if letter=="i" *)   \it %
   (* elif letter=='b' *)   \bf %
   (* elif letter=='n' *)   \normalfont %
   (* endif *)
   (* endfor *)
}
\definecolor{ChordColor}{HTML}{(( template_var.chordcolor ))}
\renewcommand{\printchord}[1]{\@chordfont\textcolor{ChordColor}{#1}}

\renewcommand{\lyricfont}{%
   (* for letter in template_var.versefont *)
   (* if letter=="i" *)   \it %
   (* elif letter=='b' *)   \bf %
   (* elif letter=='n' *)   \normalfont %
   (* endif *)
   (* endfor *)
}
\makeatother
%! End of font management

\geometry{
 ((template_var.geometry))
}

%! Temporary hack for columns management
\let\OldSongColumns=\songcolumns
\def\songcolumns#1{%
(* if template_var.column_adjustment=="only_one" *)
    \OldSongColumns{1}
(* elif template_var.column_adjustment=="one_more" *)
    \count0=#1\relax\advance\count0 by 1\relax%
    \OldSongColumns{\count0}
(* else *)
    \OldSongColumns{#1}
(* endif *)
}
%! End of columns management
(* endblock *)

(* block preface *)
% Licence
\newpage
\input{license}
\newpage
(* endblock *)
% end document
