From d381e83531820e71a4ab5ad8361da7ffbcb8ae32 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 25 Sep 2013 15:07:22 -0700 Subject: [PATCH] Take advantage of pango markup to draw superscripted chord names. Now instead of things like "C Major triad" we have shorter names like "CM". Instead of "Augmented" we have a superscripted degree symbol, etc. --- scherzo.c | 67 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/scherzo.c b/scherzo.c index a7bd785..ed62f76 100644 --- a/scherzo.c +++ b/scherzo.c @@ -639,40 +639,53 @@ scherzo_analyze_chord (scherzo_t *scherzo) num_notes = note_group->num_notes; struct { modified_degree_t degrees[1]; const char *name; } octaves[] = { - { {{1, 0}}, "Octave"} + { {{1, 0}}, " Octave"} }; struct { modified_degree_t degrees[2]; const char *name; } intervals[] = { - { {{1, 0}, {2, -1}}, "Minor 2nd"}, - { {{1, 0}, {2, 0}}, "Major 2nd"}, - { {{1, 0}, {3, -1}}, "Minor 3rd"}, - { {{1, 0}, {3, 0}}, "Major 3rd"}, - { {{1, 0}, {4, 0}}, "Perfect 4th"}, - { {{1, 0}, {5, -1}}, "Diminished 5th"}, - { {{1, 0}, {5, 0}}, "Perfect 5th"}, - { {{1, 0}, {6, -1}}, "Minor 6th"}, - { {{1, 0}, {6, 0}}, "Major 6th"}, - { {{1, 0}, {7, -1}}, "Minor 7th"}, - { {{1, 0}, {7, 0}}, "Major 7th"} + { {{1, 0}, {2, -1}}, " Minor 2nd"}, + { {{1, 0}, {2, 0}}, " Major 2nd"}, + { {{1, 0}, {3, -1}}, " Minor 3rd"}, + { {{1, 0}, {3, 0}}, " Major 3rd"}, + { {{1, 0}, {4, 0}}, " Perfect 4th"}, + { {{1, 0}, {5, -1}}, " Diminished 5th"}, + { {{1, 0}, {5, 0}}, " Perfect 5th"}, + { {{1, 0}, {6, -1}}, " Minor 6th"}, + { {{1, 0}, {6, 0}}, " Major 6th"}, + { {{1, 0}, {7, -1}}, " Minor 7th"}, + { {{1, 0}, {7, 0}}, " Major 7th"} }; +/* XXX: The superscript rise value should be relative to the current + * font size. Best would be for pango to support this. See: + * + * https://bugzilla.gnome.org/show_bug.cgi?id=708780 + * + * For now, these are emipirically-derived values that look reasonable + * at the default size that score.c is using to draw the staff. If the + * user scales the staff up or down then these will look wrong. + */ + +#define SUP "" +#define PUS "" + struct { modified_degree_t degrees[3]; const char *name; } triads[] = { - { {{1, 0}, {3, 0}, {5, +1}}, "Augmented triad" }, - { {{1, 0}, {3, 0}, {5, 0}}, "Major triad" }, - { {{1, 0}, {3, -1}, {5, 0}}, "Minor triad" }, - { {{1, 0}, {3, -1}, {5, -1}}, "Diminished triad" } + { {{1, 0}, {3, 0}, {5, +1}}, SUP "+" PUS }, + { {{1, 0}, {3, 0}, {5, 0}}, "M" }, + { {{1, 0}, {3, -1}, {5, 0}}, "m" }, + { {{1, 0}, {3, -1}, {5, -1}}, "°" } }; struct { modified_degree_t degrees[4]; const char *name; } sevenths[] = { - { {{1, 0}, {3, 0}, {5, +1}, {7, 0}}, "Augmented/major 7" }, - { {{1, 0}, {3, 0}, {5, +1}, {7, -1}}, "Augmented 7" }, - { {{1, 0}, {3, 0}, {5, 0}, {7, 0}}, "Major 7" }, - { {{1, 0}, {3, 0}, {5, 0}, {7, -1}}, "Dominant 7" }, - { {{1, 0}, {3, -1}, {5, 0}, {7, 0}}, "Minor/major 7" }, - { {{1, 0}, {3, -1}, {5, 0}, {7, -1}}, "Minor 7" }, - { {{1, 0}, {3, -1}, {5, -1}, {7, 0}}, "Diminished/major 7" }, - { {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "Half-diminished 7" }, - { {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "Diminished 7" } + { {{1, 0}, {3, 0}, {5, +1}, {7, 0}}, SUP "+M7" PUS }, + { {{1, 0}, {3, 0}, {5, +1}, {7, -1}}, SUP "+7" PUS }, + { {{1, 0}, {3, 0}, {5, 0}, {7, 0}}, "M7" }, + { {{1, 0}, {3, 0}, {5, 0}, {7, -1}}, "7" }, + { {{1, 0}, {3, -1}, {5, 0}, {7, 0}}, "m" SUP "M7" PUS }, + { {{1, 0}, {3, -1}, {5, 0}, {7, -1}}, "m7" }, + { {{1, 0}, {3, -1}, {5, -1}, {7, 0}}, "°" SUP "M7" PUS }, + { {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS }, + { {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "7" PUS } }; if (scherzo->chord) { @@ -802,11 +815,11 @@ scherzo_analyze_chord (scherzo_t *scherzo) inversion); exit(1); } - chord_name = talloc_asprintf (local, "%s %s %s", + chord_name = talloc_asprintf (local, "%s%s %s", _pitch_str (root), chord_name, inversion_str); } else { - chord_name = talloc_asprintf (local, "%s %s", + chord_name = talloc_asprintf (local, "%s%s", _pitch_str (root), chord_name); } -- 2.43.0