Skip to content

Commit

Permalink
Allowed styles to span syllables.
Browse files Browse the repository at this point in the history
  • Loading branch information
henryso committed May 28, 2016
1 parent b89c956 commit 7e9254f
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 177 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
- Different glyphs are now used for puncta inclinata in an ascent versus in a descent. A heuristic algorithm is used to ensure that the glyphs match when grouped together. If the algorithm chooses the wrong shape, use `0` (for descending) or `1` (for ascending) to force an orientation. See [UPGRADE.md](UPGRADE.md) and [#856](https://github.com/gregorio-project/gregorio/issues/856) for details.
- The shape of the fused oriscus at ambitus one in the greciliae font has been tweaked to form a nicer connection (see [#1079](https://github.com/gregorio-project/gregorio/issues/1079)).
- Syllables are now rewritten to improve ligature rendering. This may be disabled by issuing `\gresetsyllablerewriting{off}`. See GregorioRef for details (for the change request, see [#1098](https://github.com/gregorio-project/gregorio/issues/1098)).
- Italic, bold, underlined, small capital, teletype, and colored styles now span multiple syllables. Gregorio will also more consistently raise errors when styles are improperly started or ended. See [UPGRADE.md](UPGRADE.md) and [#1121](https://github.com/gregorio-project/gregorio/issues/1121) for details.


## [4.2.0-beta1] - 2016-04-27
Expand Down
18 changes: 12 additions & 6 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ Additionally, if you were redefining `\greemergencystretch`, you should now be c

If the note following a custos has an alteration (flat, natural, or sharp), the custos will now also have that alteration typeset before it. If you prefer the old behavior, use `\gresetcustosalteration{invisible}`. This setting may be switched to `visible` and `invisible` between scores.

### Punctum inclinatum orientation

As of version 4.2, a different glyph is used for puncta inclinata in an ascent versus puncta inclinata in a descent. However, because the two shapes clash with each other, Gregorio will attempt to use the same shape for all notes within a string of puncta inclinata. This is accomplished by a heuristic algorithm that determines the glyph to use, but tastes differ, so you may override the shape by appending `0` (to force descending) or `1` (to force ascending) after the letter used for the punctum inclinatum.

Two additional distances have been added to handle strings of puncta inclinata which both ascend and descend. `descendingpunctuminclinatumascendingshift` will be used between two descending punctum inclinatum glyphs which ascend in pitch, and `ascendingpunctuminclinatumdescendingshift` will be used between two ascending punctum inclinatum glyphs which descend in pitch.

### Styles spanning syllables

From version 4.2, gabc styles persist through syllables so you can now, for instance, style an entire verse differently from the rest of the piece by starting the style at the beginning of the verse and ending it at the end of the verse. This covers italics (`<i>`), bold (`<b>`), small capitals (`<sc>`), underlined text (`<ul>`), colored text (`<c>`), and "teletype" text (`<tt>`).

Prior to version 4.2, Gregorio inconsistenly indicated style errors. Now, errors like ending a style that is not started and starting a style that is already started will be caught more consistently. If you are getting errors to this effect, double-check the styles in your score to make sure that styles are started and ended properly.


## 4.1.2

Expand All @@ -59,12 +71,6 @@ As always, please file a bug report if you have any problems with the update pro

To avoid conflicts with the LilyPond Parmesan font, the Gregorio Parmesan font is now called Grana Padano. If you were using `\gresetgregoriofont{parmesan}`, you should now use `\gresetgregoriofont{granapadano}`.

### Punctum inclinatum orientation

As of version 4.2, a different glyph is used for puncta inclinata in an ascent versus puncta inclinata in a descent. However, because the two shapes clash with each other, Gregorio will attempt to use the same shape for all notes within a string of puncta inclinata. This is accomplished by a heuristic algorithm that determines the glyph to use, but tastes differ, so you may override the shape by appending `0` (to force descending) or `1` (to force ascending) after the letter used for the punctum inclinatum.

Two additional distances have been added to handle strings of puncta inclinata which both ascend and descend. `descendingpunctuminclinatumascendingshift` will be used between two descending punctum inclinatum glyphs which ascend in pitch, and `ascendingpunctuminclinatumdescendingshift` will be used between two ascending punctum inclinatum glyphs which descend in pitch.


## 4.1.1

Expand Down
16 changes: 14 additions & 2 deletions src/gabc/gabc-score-determination.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
#include "struct.h"
#include "gabc.h"

/* The bits in this enum are named to correspond with the _BEGIN/_END tokens */
typedef enum {
SB_I = 0x01,
SB_B = 0x02,
SB_TT = 0x04,
SB_SC = 0x08,
SB_UL = 0x10,
SB_C = 0x20,
SB_ELISION = 0x40
} gabc_style_bits;

typedef union gabc_score_determination_lval_t {
char *text;
char character;
Expand All @@ -36,8 +47,9 @@ typedef union gabc_score_determination_lval_t {
#define YYSTYPE gabc_score_determination_lval_t
#define YYSTYPE_IS_DECLARED 1

int gabc_score_determination_lex(void);
#define YY_DECL int gabc_score_determination_lex(void)
#define YY_DECL \
int gabc_score_determination_lex(gabc_style_bits *const styles)
YY_DECL;

#define YYLTYPE gregorio_scanner_location

Expand Down
193 changes: 77 additions & 116 deletions src/gabc/gabc-score-determination.l
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,35 @@
#include "gabc-score-determination.h"
#include "gabc-score-determination-y.h"

static unsigned char style_stack = 0;
static bool eof_found = false;

#define START_STYLE(STYLE) \
if (*styles & SB_ ## STYLE) { \
gregorio_messagef("gabc_score_determination_lex", VERBOSITY_ERROR, 0, \
_("style already started: %s"), gabc_score_determination_text); \
} else { \
*styles ^= SB_ ## STYLE; \
return STYLE ## _BEGIN; \
}

#define END_STYLE(STYLE) \
if (*styles & SB_ ## STYLE) { \
*styles ^= SB_ ## STYLE; \
return STYLE ## _END; \
} else { \
gregorio_messagef("gabc_score_determination_lex", VERBOSITY_ERROR, 0, \
_("style not started: %s"), gabc_score_determination_text); \
}

#define RETURN_CHARACTERS \
gabc_score_determination_lval.text = \
gregorio_strdup(gabc_score_determination_text); \
return CHARACTERS

#define RETURN_SPACE \
gabc_score_determination_lval.text = gregorio_strdup(" "); \
return CHARACTERS

#define YY_NO_INPUT

#define YY_INPUT(buf,result,max_size) \
Expand Down Expand Up @@ -78,7 +104,7 @@ static bool eof_found = false;
%x attribute
%x score
%x notes
%x style
%x sp
%x verb
%x comments
%x inicomments
Expand Down Expand Up @@ -217,127 +243,75 @@ semicolon. */
gabc_score_determination_text[0]);
}
<score>[\n\r][\n\r \t]* {
gabc_score_determination_lval.text = gregorio_strdup(" ");
return CHARACTERS;
RETURN_SPACE;
}
<score>[^-\{\}\(\[\]<%\n\r]+ {
gabc_score_determination_lval.text =
gregorio_strdup(gabc_score_determination_text);
return CHARACTERS;
<score,sp>[^-\{\}\(\[\]<%\n\r]+ {
RETURN_CHARACTERS;
}
<score>- {
return HYPHEN;
}
<score,style><nlba> {
<score><nlba> {
return NLBA_B;
}
<score,style><\/nlba> {
<score><\/nlba> {
return NLBA_E;
}
<score,style><i> {
BEGIN(style);
style_stack ++;
return I_BEGIN;
<score><i> {
START_STYLE(I);
}
<style><\/i> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return I_END;
<score><\/i> {
END_STYLE(I);
}
<score,style><tt> {
BEGIN(style);
style_stack ++;
return TT_BEGIN;
<score><tt> {
START_STYLE(TT);
}
<style><\/tt> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return TT_END;
<score><\/tt> {
END_STYLE(TT);
}
<score,style><ul> {
BEGIN(style);
style_stack ++;
return UL_BEGIN;
<score><ul> {
START_STYLE(UL);
}
<style><\/ul> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return UL_END;
<score><\/ul> {
END_STYLE(UL);
}
<score,style><c> {
BEGIN(style);
style_stack ++;
return C_BEGIN;
<score><c> {
START_STYLE(C);
}
<style><\/c> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return C_END;
<score><\/c> {
END_STYLE(C);
}
<score,style><b> {
BEGIN(style);
style_stack ++;
return B_BEGIN;
<score><b> {
START_STYLE(B);
}
<style><\/b> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return B_END;
<score><\/b> {
END_STYLE(B);
}
<score,style><sc> {
BEGIN(style);
style_stack ++;
return SC_BEGIN;
<score><sc> {
START_STYLE(SC);
}
<style><\/sc> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return SC_END;
<score><\/sc> {
END_STYLE(SC);
}
<score,style><e> {
BEGIN(style);
style_stack ++;
return ELISION_BEGIN;
<score><e> {
START_STYLE(ELISION);
}
<style><\/e> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
return ELISION_END;
<score><\/e> {
END_STYLE(ELISION);
}
<score,style><sp> {
BEGIN(style);
style_stack ++;
<score><sp> {
BEGIN(sp);
return SP_BEGIN;
}
<style><\/sp> {
style_stack --;
if (style_stack == 0) {
BEGIN(score);
}
<sp><\/sp> {
BEGIN(score);
return SP_END;
}
<style>[\n\r][\n\r \t]* {
gabc_score_determination_lval.text = gregorio_strdup(" ");
return CHARACTERS;
<sp>[\n\r][\n\r \t]* {
RETURN_SPACE;
}
<style>[^<\{\}\n\r]+ {
gabc_score_determination_lval.text =
gregorio_strdup(gabc_score_determination_text);
return CHARACTERS;
<sp>[^<\{\}\n\r]+ {
RETURN_CHARACTERS;
}
<score>\% {
BEGIN(comments);
Expand All @@ -348,43 +322,30 @@ semicolon. */
<comments>[^\n\r]+ {
/* ignored */
}
<style,score><v> {
<score><v> {
BEGIN(verb);
return VERB_BEGIN;
}
<verb><\/v> {
if (style_stack == 0) {
BEGIN(score);
} else {
BEGIN(style);
}
BEGIN(score);
return VERB_END;
}
<verb>[^<]+ {
gabc_score_determination_lval.text =
gregorio_strdup(gabc_score_determination_text);
return CHARACTERS;
<verb,alt>[^<]+ {
RETURN_CHARACTERS;
}
<verb,style,score,alt>< {
gabc_score_determination_lval.text =
gregorio_strdup(gabc_score_determination_text);
return CHARACTERS;
<verb,sp,score,alt>< {
RETURN_CHARACTERS;
}
<score,style>\{ {
<score>\{ {
return CENTER_BEGIN;
}
<score,style>\} {
<score>\} {
return CENTER_END;
}
<score><alt> {
BEGIN(alt);
return ALT_BEGIN;
}
<alt>[^<]+ {
gabc_score_determination_lval.text =
gregorio_strdup(gabc_score_determination_text);
return CHARACTERS;
}
<alt><\/alt> {
BEGIN(score);
return ALT_END;
Expand Down
Loading

0 comments on commit 7e9254f

Please sign in to comment.