-
Notifications
You must be signed in to change notification settings - Fork 3k
Introduce advanced glyph shapes using smufl cutouts and apply it to accidentals #20966
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
Conversation
src/engraving/dom/engravingitem.cpp
Outdated
| return score()->engravingFont()->bbox(symbols, magS()); | ||
| } | ||
|
|
||
| Shape EngravingItem::symShape(SymId id) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better move this method to IEngravingFont
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when doing that, we might want to cache the Shape calculated by this method, just like we do for the bbox actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think better move this method to
IEngravingFont
Done!
And when doing that, we might want to cache the Shape calculated by this method, just like we do for the bbox actually
I'm not sure I know where or how we would cache that Shape. How would you do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I know where or how we would cache that Shape. How would you do this?
You would add a new shapeWithCutouts field to the EngravingFont::Sym struct. This will probably need to be mutable.
Then, in EngravingFont::shapeWithCutouts, use const Sym& s = sym(id) to obtain the Sym for that symbol. Check if the shapeWithCutouts is empty; if not, just return it; if yes, then calculate it and store it for the next time, and return it.
You might also need to do some stuff with useFallbackFont(id).
To some extent, EngravingFont::bbox is a good example, except that all bboxes are calculated in advance when the font is loaded, instead of just at the moment that they are needed.
src/engraving/dom/engravingitem.cpp
Outdated
| } | ||
|
|
||
| for (RectF& rect : rects) { | ||
| shape.add(rect, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should add method like addAll(const std::vector<RectF>& rects, EngravingItem* item)
then we can do m_elements.reserve to avoid relocated several times
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or we can add method reserve to Shape class :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a new Shape constructor for this case :)
|
You probably realize this already, but just in case: we do already use cutouts in the stacking algorithm for accidentals within a chord: MuseScore/src/engraving/rendering/dev/chordlayout.cpp Lines 2450 to 2468 in cfd3da6
Also for key signatures: MuseScore/src/engraving/rendering/dev/tlayout.cpp Lines 3604 to 3610 in cfd3da6
These are the "dev" versions, but the code has been in place a long time - predates autoplace. Perhaps the new shape system could be used here instead of this special casing. |
536990d to
e40e7cc
Compare
4885d6a to
5527da0
Compare
|
@igorkorsukov @cbjeukendrup I've implemented your suggestions. If you think this is good to go, it would be good to merge it before Igor's work on the Shape class, otherwise we get conflicts :) |
Currently, our layout system (meaning all the collision checks) looks at accidentals like this:

With this PR, we look at accidentals like this:

In score very heavy of accidentals, this may have a small performance cost, because every accidental now is made of more than a single rectangle. However, that cost is basically offset by the gain made with this optimization. Besides, it is exactly in the situation with many accidentals that using cutouts like this can dramatically improve the layout.
This allows smufl cutouts to be used also by any other item that needs them in future.