smufl icon indicating copy to clipboard operation
smufl copied to clipboard

Add anchor for tremolos inside flags

Open Nick-Mazuk opened this issue 3 years ago • 3 comments

Goal

It's very common in music for tremolos to fit inside flags.

Screen Shot 2021-11-09 at 11 51 33 AM

Obviously, to make this work, the bounding boxes of tremolos and flags must overlap. So there should be some way of defining exactly how much they should be able to overlap.

Issue

Because the exact shape of the flag is font-specific, there's no universal magic number you can use to determine the acceptable amount of overlap. Even if the height and spacing of flags where they attach to the stem are consistent, the shape of the flag (specifically how much it slants) plays a major role in determining how much the bounding boxes can overlap without producing a collision.

For instance, take a look at these examples. The fonts are Bravura, Leland, and Gonville. They each use the same amount of overlap, yet the whitespace between the tremolos and flags vary wildly.

Bravura Leland Gonville
Screen Shot 2021-11-09 at 11 58 41 AM Screen Shot 2021-11-09 at 11 59 13 AM Screen Shot 2021-11-09 at 11 59 36 AM

Alternative: cutouts

It currently is possible to use cutouts to achieve the desired results. However, I don't think that's the appropriate solution for a few reasons.

A cutout is difficult to define

Because a flag is mainly a curve, the "correct" cutout placement can vary quite a bit.

Thin cutout Thick cutout
Screen Shot 2021-11-09 at 12 15 18 PM Screen Shot 2021-11-09 at 12 15 45 PM

This is problematic—the cutout for one font isn't guaranteed to be in the same position for another font. So if just a few font creators don't purposefully place the cutout such that the y value is in the correct position for tremolos, software developers cannot trust that the cutout can be used to position tremolos.

Cutouts are not meant for determining white space

The end goal here is to add enough whitespace on top of the tremolo and the flag such that it does not collide with the flag. Cutouts are simply designed to show a more granular view of the bounding box.

To get the correct "y" placement for the tremolo is not along the bounding box of the cutout. So if we define a cutout for this solution, its entire purpose is directly contradictory to the purpose of cutouts—the cutout won't be used to determine the boundary of the glyph.

Using a cutout is contrary to their purpose

From my understanding, the purpose of cutouts are to help eliminate collisions in music by providing a more granular contour of the glyph than just the bounding box.

To do that, a cutout implies that a) all areas cutout are empty, and b) all areas not cutout should not be used. However, in the case of flags, at least one of these two assumptions must break down because it's not uncommon for the tips of flags to collide with a tremolo (see below, using Gonville).

Screen Shot 2021-11-09 at 12 03 45 PM

Either the cutout is thin to satisfy implication "a", but then the tremolos must extend into the flag's new bounding box (failing "b"), or the cutout is thick to satisfy implication "b", but the tip of the tail extends into the cutout area failing "a".

Conclusion

While cutouts can be used to define how tremolos should fit inside flags, they are not the right solution and to my knowledge no SMuFL compliant font uses cutouts to resolve this issue anyways.

Some new anchor point would be far more appropriate, similar to how text fonts use kerning to create the optimal spacing between characters.

At the very least, if cutouts should be used, it should become standard that they're placed on flags to show where tremolos should overlap with the flags' bounding boxes.

And because the shape and design of the flags vary quite a bit from font-to-font, this issue should be solved at the font level, not the software level.

Nick-Mazuk avatar Nov 09 '21 20:11 Nick-Mazuk

It's an interesting idea, certainly, and one that merits consideration. The fact that the angle of the tremolo stroke can also realistically vary from font to font is a further variable.

dspreadbury avatar Mar 14 '22 09:03 dspreadbury

I've been thinking about this some more, and I wonder what kind of anchor point we could actually use here to solve this problem?

It seems logical to define the point inside each up- and down-stem flag glyph that represents the closest point that a tremolo stroke can appear.

Using the bounding rect of the tremolo stroke you could then implement a rule that specifies that, for an up-stem note, the top right corner of the tremolo's (combined) bounding rect does not protrude beyond the up-stem flag glyph's anchor point, and for a down-stem note that the bottom right corner of the tremolo's bounding rect does not protrudce beyond the down-stem flag glyph's anchor point.

Presumably the application would then extend the stem of the note in the appropriate direction until the anchor point no longer overlaps with the bounding rect of the tremolo.

Because both of these items have fixed positions relative to the stem and can therefore only move vertically, we could specify that the X position of the anchor point can be disregarded, and thus should always be defined as 0. (Or we could define a new anchor type that expresses only one dimension rather than both X and Y, but that seems like overkill.)

Is this sufficient?

dspreadbury avatar Sep 14 '22 10:09 dspreadbury

That should be sufficient.

Nick-Mazuk avatar Oct 29 '22 17:10 Nick-Mazuk