Skip to content
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

fix #40066: accidentals in chord symbols #1483

Merged
merged 1 commit into from
Nov 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions libmscore/harmony.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,22 @@ static int convertRoot(const QString& s, NoteSpellingType spelling, int& idx)
int n = s.size();
QString acc = s.right(n-acci);
if (acc != "") {
if (acc.startsWith("b")) {
if (acc.startsWith("bb")) {
alter = -2;
idx += 2;
}
else if (acc.startsWith("b")) {
alter = -1;
idx += 1;
}
else if (spelling == NoteSpellingType::GERMAN && acc.startsWith("eses")) {
alter = -2;
idx += 4;
}
else if (spelling == NoteSpellingType::GERMAN && (acc.startsWith("ses") || acc.startsWith("sas"))) {
alter = -2;
idx += 3;
}
else if (spelling == NoteSpellingType::GERMAN && acc.startsWith("es")) {
alter = -1;
idx += 2;
Expand All @@ -434,10 +446,22 @@ static int convertRoot(const QString& s, NoteSpellingType spelling, int& idx)
alter = -1;
idx += 1;
}
else if (acc.startsWith("##")) {
alter = 2;
idx += 2;
}
else if (acc.startsWith("x")) {
alter = 2;
idx += 1;
}
else if (acc.startsWith("#")) {
alter = 1;
idx += 1;
}
else if (spelling == NoteSpellingType::GERMAN && acc.startsWith("isis")) {
alter = 2;
idx += 4;
}
else if (spelling == NoteSpellingType::GERMAN && acc.startsWith("is")) {
alter = 1;
idx += 2;
Expand All @@ -454,7 +478,7 @@ static int convertRoot(const QString& s, NoteSpellingType spelling, int& idx)
case 'a': r = 5; break;
case 'h': r = 6; break;
case 'b':
if (alter)
if (alter && alter != -1)
return Tpc::TPC_INVALID;
r = 6;
alter = -1;
Expand Down Expand Up @@ -1164,9 +1188,6 @@ void Harmony::render(const QList<RenderAction>& renderList, qreal& x, qreal& y,
int fontIdx = 0;
qreal _spatium = spatium();
qreal mag = (MScore::DPI / PPI) * (_spatium / (SPATIUM20 * MScore::DPI));
// German spelling - render TPC_B_B as Bb, not B (even though B is used for input)
if (tpc == Tpc::TPC_B_B && spelling == NoteSpellingType::GERMAN)
spelling = NoteSpellingType::STANDARD;

foreach(const RenderAction& a, renderList) {
if (a.type == RenderAction::RenderActionType::SET) {
Expand Down Expand Up @@ -1217,10 +1238,17 @@ void Harmony::render(const QList<RenderAction>& renderList, qreal& x, qreal& y,
else if (a.type == RenderAction::RenderActionType::ACCIDENTAL) {
QString c;
QString acc;
QString context = "accidental";
tpc2name(tpc, spelling, lowerCase, c, acc);
// German spelling - use special symbol for accidental in TPC_B_B
// to allow it to be rendered as either Bb or B
if (tpc == Tpc::TPC_B_B && spelling == NoteSpellingType::GERMAN) {
acc = "b";
context = "german_B";
}
if (acc != "") {
TextSegment* ts = new TextSegment(fontList[fontIdx], x, y);
QString lookup = "accidental" + acc;
QString lookup = context + acc;
ChordSymbol cs = chordList->symbol(lookup);
if (!cs.isValid())
cs = chordList->symbol(acc);
Expand Down
17 changes: 12 additions & 5 deletions share/styles/chords_jazz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@
<sym code="0x266e" name="natural"/>
<sym code="0x266f" name="#"/>

<!-- add "code" attributes to these, matching those for "b" and "#" above
(0x266d / 0x266f) to get German chords to render with flat and sharp -->
<sym class="accidental" name="es"/>
<sym class="accidental" name="is"/>
<!-- remove "code" attributes from these to get "es" and "is" to render as literals rather than as flat and sharp signs -->
<sym class="accidental" code="0x266d" name="es"/>
<sym class="accidental" code="0x266f" name="is"/>
<!-- this is to render the "s" in "As" and "Es" in German -->
<sym class="accidental" name="s"/>
<sym class="accidental" code="0x266d" name="s"/>
<!-- change value of "code" attribute to "0x200b" (zero width space) to render Bb as B in German -->
<sym class="german_B" code="0x266d" name="b"/>

<!-- these enable "b" and "mi" to render as literals when encountered as note names -->
<sym class="note" name="b"/>
Expand Down Expand Up @@ -147,6 +148,12 @@

</font>

<font family="MScoreText">
<mag>1.4</mag>
<sym code="0xe263" name="##"/>
<sym code="0xe264" name="bb"/>
</font>

<!--
Part II: token list
define how the various tokens within a chord symbol should be rendered
Expand Down
21 changes: 15 additions & 6 deletions share/styles/chords_std.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
<sym code="0x0394" name="triangle"/>
<sym code="0x03bf" name="circle"/>
<sym code="0x00f8" name="oslash"/>
<sym code="0x266f" name="#"/>

<sym code="0x266d" name="b"/>
<sym code="0x266e" name="natural"/>
<sym code="0x266f" name="#"/>

<!-- this allows "b" to render as a literal when when encountered as a note name -->
<sym value="b" class="note" name="b"/>
Expand All @@ -50,13 +52,20 @@
<sym value="Re" class="note" name="Re"/>
<sym value="re" class="note" name="re"/>

<!-- add "code" attributes to these, matching those for "b" and "#" above
(0x266d / 0x266f) to get German chords to render with flat and sharp -->
<sym class="accidental" name="es"/>
<sym class="accidental" name="is"/>
<!-- remove "code" attributes from these to get "es" and "is" to render as literals rather than as flat and sharp signs -->
<sym class="accidental" code="0x266d" name="es"/>
<sym class="accidental" code="0x266f" name="is"/>
<!-- this is to render the "s" in "As" and "Es" in German -->
<sym class="accidental" name="s"/>
<sym class="accidental" code="0x266d" name="s"/>
<!-- change value of "code" attribute to "0x200b" (zero width space) to render Bb as B in German -->
<sym class="german_B" code="0x266d" name="b"/>

</font>

<font family="MScoreText">
<mag>1.4</mag>
<sym code="0xe263" name="##"/>
<sym code="0xe264" name="bb"/>
</font>

<!--
Expand Down
10 changes: 8 additions & 2 deletions vtest/gen
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if [ -n "$VTEST_MSCORE" ]; then
MSCORE="$VTEST_MSCORE"
fi

case "$MSCORE" in
/*) ;;
~*) ;;
*) MSCORE="../$MSCORE" ;;
esac

if [ -n "$VTEST_BROWSER" ]; then
BROWSER="$VTEST_BROWSER"
fi
Expand All @@ -38,7 +44,7 @@ else
chord-layout-11 chord-layout-12 chord-layout-13 chord-layout-14 cross-1\
accidental-1 accidental-2 accidental-3 accidental-4 accidental-5\
accidental-6 accidental-7 accidental-8 accidental-9\
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 harmony-4\
tie-1 tie-2 tie-3 grace-1 grace-2 grace-3 harmony-1 harmony-2 harmony-3 harmony-4 harmony-5\
beams-1 beams-2 beams-3 beams-4 beams-5 beams-6 beams-7\
user-offset-1 user-offset-2 chord-space-1 tablature-1 image-1\
lyrics-1 lyrics-2 lyrics-3 voice-1 slash-1 slash-2"
Expand All @@ -54,7 +60,7 @@ cd html
for src in $SRC; do
echo process ../$src
cp ../$src-ref.png .
../$MSCORE ../$src.mscz -r $DPI -o $src.png > /dev/null 2>&1
$MSCORE ../$src.mscz -r $DPI -o $src.png > /dev/null 2>&1
compare $src-1.png $src-ref.png $src-diff.png
done

Expand Down
10 changes: 5 additions & 5 deletions vtest/gen.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ set SRC=mmrest-1,bravura-mmrest,gonville-mmrest,mmrest-2,mmrest-4,mmrest-5,mmres
noteheadposition-1,valign-1,valign-2,valign-3,emmentaler-1,bravura-1,gonville-1,emmentaler-2,bravura-2,gonville-2, ^
emmentaler-3,bravura-3,gonville-3,emmentaler-4,bravura-4,gonville-4,emmentaler-5,bravura-5,gonville-5, ^
emmentaler-6,bravura-6,gonville-6,emmentaler-7,bravura-7,gonville-7, ^
emmentaler-8,bravura-8,gonville-8,emmentaler-9,bravura-9,gonville-9,i ^
emmentaler-8,bravura-8,gonville-8,emmentaler-9,bravura-9,gonville-9, ^
emmentaler-10,bravura-10,gonville-10,emmentaler-11,bravura-11,gonville-11, ^
emmentaler-text-1,bravura-test-1,gonville-test-1,musejazz-text-1, ^
emmentaler-text-2,bravura-test-2,gonville-test-2,musejazz-text-2, ^
emmentaler-text-3,bravura-test-3,gonville-test-3,musejazz-text-3, ^
emmentaler-text-1,gonville-text-1,bravura-text-1,musejazz-text-1, ^
emmentaler-text-2,gonville-text-2,bravura-text-2,musejazz-text-2, ^
emmentaler-text-3,gonville-text-3,bravura-text-3,musejazz-text-3, ^
frametext,ottava,slurs-1,slurs-2,hairpins-1,pedal-1,line-1,line-2,line-3,line-4,gliss-1,gliss-2, ^
chord-layout-1,chord-layout-2,chord-layout-3,chord-layout-4,chord-layout-5, ^
chord-layout-6,chord-layout-7,chord-layout-8,chord-layout-9,chord-layout-10, ^
chord-layout-11,chord-layout-12,chord-layout-13,chord-layout-14,cross-1, ^
accidental-1,accidental-2,accidental-3,accidental-4,accidental-5, ^
accidental-6,accidental-7,accidental-8,accidental-9, ^
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,harmony-4, ^
tie-1,tie-2,tie-3,grace-1,grace-2,grace-3,harmony-1,harmony-2,harmony-3,harmony-4,harmony-5, ^
beams-1,beams-2,beams-3,beams-4,beams-5,beams-6,beams-7, ^
user-offset-1,user-offset-2,chord-space-1,tablature-1,image-1, ^
lyrics-1,lyrics-2,lyrics-3,voice-1,slash-1,slash-2
Expand Down
Binary file added vtest/harmony-5-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vtest/harmony-5.mscz
Binary file not shown.