Skip to content

Commit

Permalink
Added an optional argument to allow per-brace rendering choice.
Browse files Browse the repository at this point in the history
  • Loading branch information
henryso committed Jan 29, 2016
1 parent a4832e5 commit 944c3fe
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- With thanks to an anonymous contributor, the shape of the MetaPost-drawn curly brace has been improved (see [#797](https://github.com/gregorio-project/gregorio/issues/797)).
- Support for elisions, text between `<e>` and `</e>` in gabc, styled according to the `elision` style, which are excluded when determining where to position the text under its notes (see [#838](https://github.com/gregorio-project/gregorio/issues/838)).
- Special characters (between `<sp>` and `</sp>` in gabc) may now be customized using the `\gresetspecial` and `\greunsetspecial` commands. See GregorioRef for details (for the change request, see [#846](https://github.com/gregorio-project/gregorio/issues/846)).

- `\gresetbracerendering` can now take an optional argument to change the rendering of a single type of brace. See GregorioRef for details (for the change request, see [#850](https://github.com/gregorio-project/gregorio/issues/850)).

### Deprecated
- `initial-style` gabc header, supplanted by the `\gresetinitiallines` TeX command.
Expand Down
11 changes: 8 additions & 3 deletions doc/Command_Index_User.tex
Original file line number Diff line number Diff line change
Expand Up @@ -981,16 +981,21 @@ \subsubsection{Clivis Alignment}

\subsubsection{Braces}

\macroname{\textbackslash gresetbracerendering}{\{\#1\}}{gregoriotex-signs.tex}
\macroname{\textbackslash gresetbracerendering}{[\optional{\#1}]\{\#2\}}{gregoriotex-signs.tex}
Macro to tell Gregorio\TeX{} whether to use \MP{} or fonts to render
braces. \MP{} braces, the default, are tailored to better maintain
optical line weight when stretched. \MP{} braces are designed to
harmonize (and thus match best) with greciliae, but they still look good
with the other score fonts.

\begin{argtable}
\#1 & \texttt{metapost} & \MP{} will be used to render braces (default)\\
& \texttt{font} & The score font will be used to render braces
\#1 & \textit{(omitted)} & change all braces\\
& \texttt{brace} & change round braces that appear over the staff\\
& \texttt{underbrace} & change round braces that appear under the staff\\
& \texttt{curlybrace} & change curly braces\\
& \texttt{barbrace} & change round braces that appear over divisio bars\\
\#2 & \texttt{metapost} & \MP{} will be used to render braces\\
& \texttt{font} & The score font will be used to render braces\\
\end{argtable}

\macroname{\textbackslash grebarbracewidth}{}{gregoriotex-signs.tex}
Expand Down
61 changes: 59 additions & 2 deletions doc/Command_Index_internal.tex
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,40 @@ \section{Gregorio\TeX{} Controls}
\#3 & \TeX\ code & Arbitrary code to typeset, in the \texttt{modedifferentia} style, after \#2.\\
\end{argtable}
\macroname{\textbackslash gre@setallbracerendering}{\#1}{gregoriotex-signs.tex}
Macro used by \verb=\gresetbracerendering= to change all braces.
\begin{argtable}
\#1 & \texttt{metapost} & \MP{} will be used to render braces\\
& \texttt{font} & The score font will be used to render braces\\
\end{argtable}
\macroname{\textbackslash gre@setbracerendering}{[\#1]\#2}{gregoriotex-signs.tex}
Macro used by \verb=\gresetbracerendering= to change a single type of brace.
\begin{argtable}
\#1 & \texttt{brace} & change round braces that appear over the staff\\
& \texttt{underbrace} & change round braces that appear under the staff\\
& \texttt{curlybrace} & change curly braces\\
& \texttt{barbrace} & change round braces that appear over divisio bars\\
\#2 & \texttt{metapost} & \MP{} will be used to render braces\\
& \texttt{font} & The score font will be used to render braces\\
\end{argtable}
\macroname{\textbackslash gre@@setbracerendering}{\#1\#2}{gregoriotex-signs.tex}
Secondary macro used by \verb=\gre@setallbracerendering= and
\verb=\gre@setbracerendering= to change a single type of brace. As a
secondary macro, it doesn't check its first argument.
\begin{argtable}
\#1 & \texttt{brace} & change round braces that appear over the staff\\
& \texttt{underbrace} & change round braces that appear under the staff\\
& \texttt{curlybrace} & change curly braces\\
& \texttt{barbrace} & change round braces that appear over divisio bars\\
\#2 & \texttt{metapost} & \MP{} will be used to render braces\\
& \texttt{font} & The score font will be used to render braces\\
\end{argtable}
\macroname{\textbackslash gre@brace@common}{\#1\#2\#3\#4\#5\#6\#7}{gregoriotex-signs.tex}
Common macro used internally to render braces.
Expand All @@ -284,6 +318,9 @@ \section{Gregorio\TeX{} Controls}
\#7 & csname & The control sequence name representing the brace.
\end{argtable}
\macroname{\textbackslash gre@render@barbrace}{}{gregoriotex-signs.tex}
Draws a divisio brace.
\macroname{\textbackslash grebracemetapostpreamble}{\#1}{gregoriotex-signs.tex}
Returns the \MP{} preamble for braces. The control sequence name does
not have the \texttt{@} symbol because this macro is used within \MP{}.
Expand All @@ -306,6 +343,14 @@ \section{Gregorio\TeX{} Controls}
\#1 & string & the width of the brace; if \texttt{*}, use the bar brace width.
\end{argtable}
\macroname{\textbackslash gre@render@fontbrace}{\#1\#2}{gregoriotex-signs.tex}
Draws a brace using the score font.
\begin{argtable}
\#1 & string & the width of the brace.\\
\#2 & \TeX\ code & \TeX\ code that renders the brace using the score font.\\
\end{argtable}
\macroname{\textbackslash gre@draw@underbrace}{\#1}{gregoriotex-signs.tex}
Draws a round under-brace using \MP{}.
Expand Down Expand Up @@ -1321,8 +1366,20 @@ \subsection{Flags}
\macroname{\textbackslash ifgre@hepisemabridge}{}{gregoriotex-signs.tex}
Boolean used to specify whether adjacent horizontal episemata should be joined together.
\macroname{\textbackslash ifgre@drawbraces}{}{gregoriotex-signs.tex}
Boolean used to specify whether braces should be drawn by \MP{} as
\macroname{\textbackslash ifgre@metapost@brace}{}{gregoriotex-signs.tex}
Boolean used to specify whether round over-the-staff braces should be drawn by
\MP{} as opposed to rendered via the score font.
\macroname{\textbackslash ifgre@metapost@underbrace}{}{gregoriotex-signs.tex}
Boolean used to specify whether round under-the-staff braces should be drawn by
\MP{} as opposed to rendered via the score font.
\macroname{\textbackslash ifgre@metapost@curlybrace}{}{gregoriotex-signs.tex}
Boolean used to specify whether curly braces should be drawn by \MP{} as
opposed to rendered via the score font.
\macroname{\textbackslash ifgre@metapost@barbrace}{}{gregoriotex-signs.tex}
Boolean used to specify whether divisio braces should be drawn by \MP{} as
opposed to rendered via the score font.
\macroname{\textbackslash gre@biginitial}{}{gregoriotex-main.tex}
Expand Down
84 changes: 57 additions & 27 deletions tex/gregoriotex-signs.tex
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,32 @@
%% macros for the typesetting of braces and other things above the score
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\ifgre@drawbraces\gre@drawbracestrue %
\def\gresetbracerendering#1%
{\IfStrEq{#1}{font}%
{\gre@drawbracesfalse}%
{\IfStrEq{#1}{metapost}%
{\gre@drawbracestrue}%
{\gre@error{Unrecognized option for \protect\gresetbracerendering}}%
}%
\newif\ifgre@metapost@brace\gre@metapost@bracetrue %
\newif\ifgre@metapost@underbrace\gre@metapost@underbracetrue %
\newif\ifgre@metapost@curlybrace\gre@metapost@curlybracetrue %
\newif\ifgre@metapost@barbrace\gre@metapost@barbracetrue %
\def\gresetbracerendering{%
\@ifnextchar[{\gre@setbracerendering}{\gre@setallbracerendering}%
}%
\def\gre@setallbracerendering#1{%
\gre@@setbracerendering{brace}{#1}%
\gre@@setbracerendering{underbrace}{#1}%
\gre@@setbracerendering{curlybrace}{#1}%
\gre@@setbracerendering{barbrace}{#1}%
}%
\def\gre@setbracerendering[#1]#2{%
\IfStrEqCase{#1}{%
{brace}{\gre@@setbracerendering{#1}{#2}}%
{underbrace}{\gre@@setbracerendering{#1}{#2}}%
{curlybrace}{\gre@@setbracerendering{#1}{#2}}%
{barbrace}{\gre@@setbracerendering{#1}{#2}}%
}[\gre@error{Unrecognized option for \protect\gresetbracerendering}]%
}%
\def\gre@@setbracerendering#1#2{%
\IfStrEqCase{#2}{%
{font}{\csname gre@metapost@#1false\endcsname}%
{metapost}{\csname gre@metapost@#1true\endcsname}%
}[\gre@error{Unrecognized option for \protect\gresetbracerendering}]%
}%

\gdef\gre@fontchar@curlybrace{\gre@font@music\GreCPCurlyBrace}%
Expand Down Expand Up @@ -572,21 +590,28 @@
\gre@skip@temp@four = #3\relax %
\kern\gre@skip@temp@four %
\raise\gre@dimen@glyphraisevalue\hbox{%
\ifgre@drawbraces%
\ifx#7\gre@fontchar@curlybrace %
\ifx#7\gre@fontchar@curlybrace %
\ifgre@metapost@curlybrace %
\gre@draw@curlybrace{#1}%
\else %
\ifx#7\gre@fontchar@brace %
\gre@draw@fontbrace{#1}{#7}%
\fi %
\else %
\ifx#7\gre@fontchar@brace %
\ifgre@metapost@brace %
\gre@draw@brace{#1}%
\else %
\ifx#7\gre@fontchar@underbrace %
\gre@draw@fontbrace{#1}{#7}%
\fi %
\else %
\ifx#7\gre@fontchar@underbrace %
\ifgre@metapost@underbrace %
\gre@draw@underbrace{#1}%
\else %
\gre@draw@fontbrace{#1}{#7}%
\fi %
\fi %
\fi %
\else %
\setbox\gre@box@temp@sign=\hbox{#7}%
\gre@resizebox{#1}{\ht\gre@box@temp@sign}{#7}%
\fi %
}%
\hss %
Expand All @@ -604,6 +629,12 @@
\fi %
\relax %
}%
% #1 : the width
% #2 : the brace character
\def\gre@draw@fontbrace#1#2{%
\setbox\gre@box@temp@sign=\hbox{#2}%
\gre@resizebox{#1}{\ht\gre@box@temp@sign}{#2}%
}%

% #1: the width, or * for the bar brace width
% this can't have @ in the name because of the metapost catcode settings
Expand Down Expand Up @@ -1020,13 +1051,7 @@
\or % choral sign
\setbox\gre@box@temp@sign=\hbox{#7}%
\or % brace above bar
\setbox\gre@box@temp@sign=\hbox{%
\ifgre@drawbraces %
\gre@draw@brace{*}%
\else %
\gre@fontchar@abovebarbrace %
\fi %
}%
\setbox\gre@box@temp@sign=\hbox{\gre@render@barbrace}%
\fi %
% we set tempwidth to half a punctum malus half the sign width, so that the centers are aligned
\gre@dimen@temp@two=\dimexpr(\wd\gre@box@temp@sign / 2)\relax %
Expand Down Expand Up @@ -1082,14 +1107,19 @@

\def\GreBarBrace#1{%
\gre@vepisemaorrare{\gre@pitch@overbraceglyph}{#1}{%
\ifgre@drawbraces %
\hbox{\gre@draw@brace{*}}%
\else %
\GreCPBarBrace %
\fi %
\gre@render@barbrace%
}{4}{}%
\relax %
}%
\def\gre@render@barbrace{%
\hbox{%
\ifgre@metapost@barbrace %
\gre@draw@brace{*}%
\else %
\gre@fontchar@abovebarbrace %
\fi %
}%
}%

\def\GreBarVEpisema#1{%
\gre@vepisemaorrare{\gre@pitch@barvepisema}{#1}{\GreCPVEpisema}{1}{}%
Expand Down

0 comments on commit 944c3fe

Please sign in to comment.