-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use \parshape for multiline initials #1608
Draft
davidweichiang
wants to merge
8
commits into
gregorio-project:develop
Choose a base branch
from
davidweichiang:parshape
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
815ffcf
Use post_linebreak_filter to change staff lines to have the same widt…
davidweichiang aa786c6
build parshape in and align initial with baseline of last indented line
davidweichiang ade183a
delete some unused code
davidweichiang c78fb77
repair problem in last commit
davidweichiang 7cf4b1c
delete some more unused code
davidweichiang 86e474d
small fixes
davidweichiang 5f673e3
make initial descender not collide with the next line (should fix man…
davidweichiang dd09b3a
resize commentary in post_linebreak
davidweichiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,10 @@ | |
|
||
%%%%%%%%%%%%%%% | ||
|
||
\newluatexattribute\gre@attr@stafflines% | ||
\edef\gre@attrid@stafflines{\the\allocationnumber} | ||
\newluatexattribute\gre@attr@initial% | ||
\edef\gre@attrid@initial{\the\allocationnumber} | ||
|
||
% an attribute we put on the text nodes. | ||
% if it is 1, it means that there may be a dash here if this syllable is at the end of a line | ||
|
@@ -226,13 +230,10 @@ | |
\relax% | ||
}% | ||
|
||
|
||
% Eliminates the error for big initials where the second new line is at the end of the score | ||
\def\GreFinalNewLine{% | ||
\global\advance\gre@knownline by 1\relax % | ||
}% | ||
|
||
% the macro we call each time we force a changing of line, it automatically sets \gre@knownline, and adjusts left spaces | ||
% the macro we call each time we force a changing of line | ||
% #1 is 0 in case of gabc z, 1 for Z | ||
% #2 is 0 in the normal case, 1 after a bar in the new spacing algorithm | ||
\def\gre@newlinecommon#1#2{% | ||
|
@@ -241,16 +242,6 @@ | |
\gre@localrightbox{}% | ||
\fi\fi % | ||
\ifgre@boxing\else% | ||
\ifnum\gre@biginitial=1\relax % | ||
\ifcase\gre@knownline % | ||
% 0: should not happend... | ||
\or % 1 | ||
\gre@adjustsecondline % | ||
\or %2 | ||
\gre@adjustthirdline % | ||
\fi % | ||
\fi % | ||
\global\advance\gre@knownline by 1\relax % | ||
\global\gre@lastoflinecount=2\relax % | ||
\ifnum#2=0\relax % | ||
% we have to repeat the end of syllable shifts here because the manual line breaks will occur before we get to the regular shifting code in \GreSyllable | ||
|
@@ -274,7 +265,6 @@ | |
\fi % | ||
\gre@penalty{-10001}% | ||
\fi % | ||
\gre@adjustlineifnecessary\relax % | ||
%% | ||
\GreResetEolCustos\relax % | ||
\gre@trace@end% | ||
|
@@ -314,78 +304,12 @@ | |
%% box containing the initial, and dimen containing its width (and the width of the space after) | ||
\newbox\gre@box@initial% | ||
|
||
|
||
% gre@biginitial means that the inital takes two lines | ||
\newcount\gre@biginitial% | ||
|
||
% gre@knownline is the line we think we are in | ||
\newcount\gre@knownline% | ||
|
||
% macro to call before the call of \initial | ||
\def\gre@setbiginitial{% | ||
\gre@trace{gre@setbiginitial}% | ||
\global\gre@biginitial=1\relax % | ||
\relax % | ||
\gre@trace@end% | ||
}% | ||
|
||
% macro to cancel before the call of \initial | ||
\def\gre@normalinitial{% | ||
\gre@trace{gre@normalinitial}% | ||
\global\gre@biginitial=0\relax % | ||
\relax % | ||
\gre@trace@end% | ||
}% | ||
|
||
% macro to call before the first syllable, but after setinitialclef | ||
\def\gre@adjustsecondline{% | ||
\gre@trace{gre@adjustsecondline}% | ||
\gre@dimen@additionalleftspace=\gre@dimen@initialwidth\relax% | ||
\gre@updateleftbox % | ||
\relax % | ||
\gre@trace@end% | ||
}% | ||
|
||
% macro to call during the second line | ||
\def\gre@adjustthirdline{% | ||
\gre@trace{gre@adjustthirdline}% | ||
\gre@dimen@additionalleftspace= 0 pt\relax% | ||
\gre@updateleftbox % | ||
\relax % | ||
\gre@trace@end% | ||
}% | ||
|
||
\newif\ifgre@thirdlineadjustmentnecessary % | ||
\def\gre@adjustlineifnecessary{% | ||
\gre@trace{gre@adjustlineifnecessary}% | ||
\ifgre@thirdlineadjustmentnecessary % | ||
\gre@adjustthirdline % | ||
\gre@thirdlineadjustmentnecessaryfalse % | ||
\fi % | ||
\gre@trace@end% | ||
}% | ||
|
||
\def\gre@updateleftbox{% | ||
\gre@trace{gre@updateleftbox}% | ||
\gre@updatelinewidth % | ||
\gre@updatelinesclef % | ||
\gre@trace@end% | ||
}% | ||
|
||
\def\gre@updatelinewidth{% | ||
\gre@trace{gre@updatelinewidth}% | ||
\gre@debugmsg{ifdim}{ additionalleftspace = 0pt}% | ||
\ifdim\gre@dimen@additionalleftspace=0pt\relax% | ||
\gre@generatelines % | ||
\else % | ||
\gre@dimen@temp@five=\gre@dimen@stafflinewidth\relax% | ||
\global\advance\gre@dimen@stafflinewidth by -\gre@dimen@additionalleftspace\relax% | ||
\gre@generatelines % | ||
\global\gre@dimen@stafflinewidth=\gre@dimen@temp@five % | ||
\fi % | ||
\gre@trace@end% | ||
}% | ||
|
||
\def\greillumination#1{% | ||
\setbox\gre@box@initial=\hbox{#1}% | ||
}% | ||
|
@@ -405,96 +329,69 @@ | |
\gre@trace@end% | ||
} | ||
|
||
\def\gre@makeparshape#1#2{% | ||
\edef\gre@parshape@dims{\numexpr#1+1\relax}% | ||
\gre@count@temp@one=0\relax | ||
\loop | ||
\edef\gre@parshape@dims{\gre@parshape@dims#2\dimexpr\gre@dimen@linewidth-#2\relax}% | ||
\advance\gre@count@temp@one by 1\relax | ||
\ifnum\gre@count@temp@one<#1\repeat | ||
\parshape\gre@parshape@dims0pt\gre@dimen@linewidth | ||
} | ||
|
||
\def\gre@setinitial#1{% | ||
\gre@trace{gre@setinitial{#1}}% | ||
\gre@debugmsg{annotation}{Time to calculate the true raise.}% | ||
\gre@calculate@annotationtrueraise % | ||
% we print the initial always at the same place, and then we print the gre@box@annotation, centered | ||
% first we print the initial | ||
\gre@dimen@temp@five = \dimexpr(\gre@dimen@textlower+\gre@space@dimen@initialraise)\relax% | ||
% if it is a big initial we print it on the second line | ||
\ifnum\gre@biginitial=0\relax % | ||
\ifvoid\gre@box@initial% | ||
\gre@debugmsg{initial}{Fill initial box a}% | ||
\setbox\gre@box@initial=\hbox{\gre@style@initial\gre@fixedtextformat{#1}\endgre@style@initial}% | ||
\fi% | ||
\gre@debugmsg{ifdim}{ manualinitialwidth = 0pt}% | ||
\ifdim\gre@space@dimen@manualinitialwidth=0 pt\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@initial % | ||
\gre@style@initial% | ||
\ifdim\gre@dimen@initialwidth<\gre@space@dimen@minimalinitialwidth\relax% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@minimalinitialwidth\relax% | ||
\fi% | ||
\endgre@style@initial% | ||
\else% | ||
\gre@style@initial% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@manualinitialwidth\relax% | ||
\endgre@style@initial% | ||
\fi% | ||
\gre@debugmsg{ifdim}{ wd(gre@box@annotation) > initialwidth}% | ||
\ifdim\wd\gre@box@annotation>\gre@dimen@initialwidth\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@annotation% | ||
\fi% | ||
\gre@debugmsg{annotation}{Width check completed.}% | ||
\setbox\gre@box@initial=\hbox to \gre@dimen@initialwidth {\hss\raise \gre@dimen@temp@five\box\gre@box@initial\hss}% | ||
\gre@debugmsg{annotation}{Initial set.}% | ||
\ifvoid\gre@box@initial% | ||
\gre@debugmsg{initial}{Fill initial box a}% | ||
\setbox\gre@box@initial=\hbox{\gre@style@initial\gre@fixedtextformat{#1}\endgre@style@initial}% | ||
\fi% | ||
\gre@debugmsg{ifdim}{ manualinitialwidth = 0pt}% | ||
\ifdim\gre@space@dimen@manualinitialwidth=0 pt\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@initial % | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@beforeinitialshift\relax% | ||
\ifdim\gre@dimen@initialwidth<\gre@space@dimen@minimalinitialwidth\relax% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@minimalinitialwidth\relax% | ||
\fi% | ||
\endgre@style@initial% | ||
\else % | ||
\advance\gre@dimen@temp@five by \dimexpr(-\gre@dimen@additionalbottomspace % | ||
- \gre@space@dimen@spacebeneathtext % | ||
- \gre@space@dimen@spacelinestext % | ||
- 4\gre@dimen@interstafflinespace % | ||
- 4\gre@dimen@stafflineheight % | ||
- \gre@dimen@currenttranslationheight % | ||
- \f@size pt % | ||
+ \gre@space@dimen@initialraise)\relax% | ||
\ifvoid\gre@box@initial% | ||
\gre@debugmsg{initial}{fill big initial box}% | ||
\setbox\gre@box@initial=\hbox{\gre@style@initial\gre@fixedtextformat{#1}\endgre@style@initial}% | ||
\fi% | ||
\gre@debugmsg{ifdim}{ manualinitialwidth = 0pt}% | ||
\ifdim\gre@space@dimen@manualinitialwidth=0 pt\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@initial % | ||
\gre@style@initial% | ||
\ifdim\gre@dimen@initialwidth<\gre@space@dimen@minimalinitialwidth\relax% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@minimalinitialwidth\relax% | ||
\fi% | ||
\endgre@style@initial% | ||
\else% | ||
\gre@style@initial% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@manualinitialwidth\relax% | ||
\endgre@style@initial% | ||
\fi% | ||
\gre@debugmsg{ifdim}{ wd(GreAboveinitialfirstbox) > initialwidth}% | ||
\ifdim\wd\gre@box@annotation>\gre@dimen@initialwidth\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@annotation% | ||
\fi% | ||
\setbox\gre@box@initial=\hbox{\vtop to 0pt{\hbox to \gre@dimen@initialwidth {\hss\raise \gre@dimen@temp@five\box\gre@box@initial\hss}\vss}}% | ||
\else | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@beforeinitialshift\relax% | ||
\global\gre@dimen@initialwidth=\gre@space@dimen@manualinitialwidth\relax% | ||
\endgre@style@initial% | ||
\fi % | ||
\fi | ||
\gre@debugmsg{ifdim}{ wd(gre@box@annotation) > initialwidth}% | ||
\ifdim\wd\gre@box@annotation>\gre@dimen@initialwidth\relax% | ||
\global\gre@dimen@initialwidth=\wd\gre@box@annotation% | ||
\fi% | ||
\gre@debugmsg{annotation}{Width check completed.}% | ||
\setbox\gre@box@initial=\hbox to \gre@dimen@initialwidth {\hss\raise \gre@dimen@temp@five\box\gre@box@initial\hss}% | ||
\gre@debugmsg{annotation}{Initial set.}% | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@beforeinitialshift\relax% | ||
\endgre@style@initial% | ||
\setbox\gre@box@temp@width=\hbox attr \gre@attrid@initial=1 {% | ||
\gre@hskip\gre@dimen@temp@four % | ||
\global\advance\gre@dimen@initialwidth by \gre@dimen@temp@four % | ||
\gre@debugmsg{annotation}{Ready to place initial.}% | ||
\ifgre@showlyrics% | ||
\box\gre@box@initial% | ||
\smash{\box\gre@box@initial}% | ||
\else% | ||
\kern\wd\gre@box@initial% | ||
\fi% | ||
\ifnum\gre@biginitial=0\relax% | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@afterinitialshift\relax% | ||
\endgre@style@initial% | ||
\else% | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@afterinitialshift\relax% | ||
\endgre@style@initial% | ||
\fi% | ||
\gre@style@initial% | ||
\global\gre@dimen@temp@four = \gre@space@dimen@afterinitialshift\relax% | ||
\endgre@style@initial% | ||
\gre@hskip\gre@dimen@temp@four % | ||
\global\advance\gre@dimen@initialwidth by \gre@dimen@temp@four% | ||
}% | ||
% Set the paragraph shape. This should happen before anything is printed. | ||
\gre@makeparshape{\gre@count@initiallines}{\wd\gre@box@temp@width}% | ||
% Set the initial. | ||
\llap{\box\gre@box@temp@width}% | ||
% then we center the annotation box above the initial, if there is one | ||
\gre@debugmsg{annotation}{Time to set the annotation.}% | ||
\ifvoid\gre@box@annotation\relax% | ||
|
@@ -678,7 +575,10 @@ | |
%% has to be called before drawing the key, after drawing the initial | ||
\def\gre@beginnotes{% | ||
\gre@trace{gre@beginnotes}% | ||
\gre@drawfirstlines % | ||
% Draw the staff lines the same as the other staves; post_linebreak | ||
% will fix them. The \hbox is there so that post_linebreak can find | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hack. It would be better either to mark the initial with an attribute, or to draw all the lines using \localleftbox (I couldn't figure out how). |
||
% it more easily. | ||
\hbox{\copy\gre@box@lines}% | ||
%%localeleftbox is a primitive of Omega, it draws the same box at the beginning of new lines (here after the first) | ||
\gre@localleftbox{% | ||
\copy\gre@box@lines % | ||
|
@@ -816,77 +716,14 @@ | |
]% | ||
} | ||
|
||
%% macro that draws the stafflines on the first line, it is different from others due to the initial that can take some place, without lines | ||
\def\gre@drawfirstlines{% | ||
\gre@trace{gre@drawfirstlines}% | ||
\advance\gre@dimen@stafflinewidth by -\gre@dimen@initialwidth\relax% | ||
%\advance\gre@dimen@stafflinewidth by -\gre@space@dimen@minimalspaceatlinebeginning | ||
%\gre@dimen@initialwidth=0pt | ||
\hbox to 0pt{% | ||
\vbox{% | ||
\gre@style@normalstafflines% | ||
\vskip\gre@dimen@currentabovelinestextheight\relax% | ||
\vskip\gre@dimen@additionaltopspace\relax% | ||
\ifgre@showlines % | ||
\hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% | ||
\else % | ||
\vskip\gre@dimen@stafflineheight\relax% | ||
\fi % | ||
\gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% | ||
\kern\gre@skip@temp@four % | ||
\ifgre@showlines % | ||
\hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% | ||
\else % | ||
\vskip\gre@dimen@stafflineheight\relax% | ||
\fi % | ||
\ifgre@haslinethree % | ||
\gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% | ||
\kern\gre@skip@temp@four % | ||
\ifgre@showlines % | ||
\hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% | ||
\else % | ||
\vskip\gre@dimen@stafflineheight\relax% | ||
\fi % | ||
\fi % | ||
\ifgre@haslinefour % | ||
\gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% | ||
\kern\gre@skip@temp@four % | ||
\ifgre@showlines % | ||
\hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% | ||
\else % | ||
\vskip\gre@dimen@stafflineheight\relax% | ||
\fi % | ||
\fi % | ||
\ifgre@haslinefive % | ||
\gre@skip@temp@four = \gre@dimen@interstafflinespace\relax% | ||
\kern\gre@skip@temp@four % | ||
\ifgre@showlines % | ||
\hrule height \gre@dimen@stafflineheight width \gre@dimen@stafflinewidth\relax% | ||
\else % | ||
\vskip\gre@dimen@stafflineheight\relax% | ||
\fi % | ||
\fi % | ||
\vskip\gre@space@dimen@spacelinestext\relax% | ||
\vskip\gre@space@dimen@spacebeneathtext\relax% | ||
\vskip\gre@dimen@currenttranslationheight\relax% | ||
\vskip\gre@dimen@additionalbottomspace\relax% | ||
\endgre@style@normalstafflines% | ||
}% | ||
\hss% | ||
}% | ||
\gre@dimen@stafflinewidth=\gre@dimen@linewidth\relax% | ||
\relax% | ||
\gre@trace@end% | ||
}% | ||
|
||
%% box containing the stafflines for other lines than the first | ||
\newbox\gre@box@lines% | ||
|
||
% macro that must be called at each change of linewidth and gre@factor | ||
\def\gre@generatelines{% | ||
\gre@trace{gre@generatelines}% | ||
\setbox\gre@box@lines=\hbox to 0pt{% | ||
\vbox{% | ||
\vbox attr \gre@attrid@stafflines=1 {% | ||
\gre@style@normalstafflines% | ||
\vskip\glueexpr(\gre@dimen@additionaltopspace+\gre@space@skip@spaceabovelines+\gre@dimen@currentabovelinestextheight)\relax% | ||
\ifgre@showlines % | ||
|
@@ -1304,19 +1141,13 @@ | |
\ifdefined\optgabcAtScoreBeginning % | ||
\optgabcAtScoreBeginning % | ||
\fi % | ||
\global\gre@knownline=1\relax % | ||
\global\gre@lastoflinecount=2\relax % | ||
\global\gre@endofscorefalse % | ||
\relax% | ||
}% | ||
|
||
%macro called at the end of a score | ||
\def\GreEndScore{% | ||
\ifnum\gre@biginitial=1\relax% | ||
\ifnum\gre@knownline<3\relax% | ||
\gre@error{Score ended before finding the end\MessageBreak of the second line of a 2-line initial. Make sure\MessageBreak you have at least two manual line breaks in \MessageBreak your gabc}% | ||
\fi% | ||
\fi% | ||
\global\gre@lastoflinecount=0\relax % | ||
\gre@useautoeolcustos% | ||
\GreEndEUOUAE{}% | ||
|
@@ -1338,7 +1169,6 @@ | |
\gre@calculate@additionalspaces{\gre@pitch@dummy}{\gre@pitch@dummy}{0}{0}% | ||
\global\gre@dimen@currentabovelinestextheight=0 sp% | ||
\gre@removetranslationspace % | ||
\gre@normalinitial % | ||
\gre@restorepenalties % | ||
\gre@dimen@temp@one=0pt\relax% | ||
\gre@dimen@temp@two=0pt\relax% | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The \smash is presumably what's changing the appearance of initials with descenders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember why the \smash was there. It seems to make no difference now...