lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

issue 5312: Key cancellation glyph position inconsistent (issue 34302004


From: torsten . haemmerle
Subject: issue 5312: Key cancellation glyph position inconsistent (issue 343020043 by address@hidden)
Date: Tue, 24 Apr 2018 10:25:06 -0700

Reviewers: ,

Message:
Please review...

Thanks,
Torsten

PS: no new regression test needed, there are loads of key cancellations
in the existing regression tests.

Description:
issue 5312: Key cancellation glyph position inconsistent

file lily/key-signature-interface.cc

Using two intervals representing the "vertical skylines" of two
adjacent natural glyphs. This makes a better model of the actual
glyph shape than the original single point within an inverval.
Now we can distiguish between all three cases:
(1) no overlap -> no additional kerning needed
(2) just touching (overlap, but intesection length 0) -> kerning 0.15
(3) overlapping -> kerning 0.3

Case (2) is the new one that couldn't be handled before:
Just touching at the corners made the glyphs cling together.

Basically same  interval technique as before, but I
renamed the Slices from
  pos and overlap_pos
to
  ht_right and last_ht_left.
Using quarter stave-spaces as to get a better (integer) resolution.

Please review this at https://codereview.appspot.com/343020043/

Affected files (+20, -8 lines):
  M Documentation/changes.tely
  M lily/key-signature-interface.cc


Index: Documentation/changes.tely
diff --git a/Documentation/changes.tely b/Documentation/changes.tely
index 96748ad84dd8f2d91ae058f6545d1697c793b9c9..defcd4f1daabe11cc5855497e51137290de6297e 100644
--- a/Documentation/changes.tely
+++ b/Documentation/changes.tely
@@ -62,6 +62,16 @@ which scares away people.
 @end ignore

 @item
+Slight padding added between natural glyphs just touching at the corners
+in key cancellations.
address@hidden,quote]
+{
+  \omit Staff.TimeSignature
+  \key ces \major s1 \key c \major s
+}
address@hidden lilypond
+
address@hidden
 Two new ornaments have been added.
 @lilypond[verbatim,quote]
 {
Index: lily/key-signature-interface.cc
diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc index 79e2bd99482d25b8e5eb1fb10e9fb1ce2255cae7..0c4180d194a283799ff62398be04a2dda2893377 100644
--- a/lily/key-signature-interface.cc
+++ b/lily/key-signature-interface.cc
@@ -58,7 +58,7 @@ Key_signature_interface::print (SCM smob)
     the cancellation signature.
   */

-  Slice pos, overlapping_pos;
+ Slice ht_right, last_ht_left; /* ht intervals for natural glyph kerning */
   SCM last_glyph_name = SCM_BOOL_F;
   SCM padding_pairs = me->get_property ("padding-pairs");

@@ -87,14 +87,15 @@ Key_signature_interface::print (SCM smob)
         me->warning (_ ("alteration not found"));
       else
         {
-          pos.set_empty ();
+          ht_right.set_empty ();
           Stencil column;
for (SCM pos_list = Lily::key_signature_interface_alteration_positions
                  (scm_car (s), c0s, smob);
                scm_is_pair (pos_list); pos_list = scm_cdr (pos_list))
             {
               int p = scm_to_int (scm_car (pos_list));
-              pos.add_point (p);
+              ht_right.add_point (2*p - 6);  /* descender */
+              ht_right.add_point (2*p + 3);  /* upper right corner */
               column.add_stencil (acc.translated (Offset (0, p * inter)));
             }
           /*
@@ -108,14 +109,15 @@ Key_signature_interface::print (SCM smob)
                                   padding_pairs);
           if (scm_is_pair (handle))
             padding = robust_scm2double (scm_cdr (handle), 0.0);
-          else if (glyph_name == "accidentals.natural"
-                   && !intersection (overlapping_pos, pos).is_empty ())
-            padding += 0.3;
+          else if (glyph_name == "accidentals.natural")
+            if (!intersection (ht_right, last_ht_left).is_empty ())
+              padding += (intersection (ht_right, last_ht_left).length ()
+                          ? 0.3     /* edges overlap */
+                          : 0.15);  /* just touching at the corners */

           mol.add_at_edge (X_AXIS, LEFT, column, padding);

-          pos.widen (4);
-          overlapping_pos = pos + 2;
+ last_ht_left = ht_right + 3; /* shift up (change to left side) */
           last_glyph_name = glyph_name_scm;
         }
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]