fix #281831 text cursor init w/special symbols #4588
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously double-clicking text cursor next to a special text such as piano or forte dynamics or the notehead of tempo text would cause musescore to set the cursor to use a special font family ScoreText. This caused problems when typing more text because this special ScoreText font doesn't actually exist in the list of fonts, and so musescore would default to an undesired one (on my arch linux computer would be Bitstream Vera Sans) instead of the text element style's default. This is fixed by having TextCursor::updateCursorFormat() initialize the cursor (to use the default) if the fontFamily was the special 'ScoreText'.
Another problem occured when setting the cursor to be before the initial character when text started with one of these special characters, whereby the fontFamily would be an empty string. This was because TextCursor::set() wouldn't call updateCursorFormat() if the cursor was first placed at row and column 0, due to what looks like a problematic attempt at an optimization. Seems like the optimization was to not perform updates if the text cursor and row indexes (edit: didn't) change from last click...but this optimization failed to consider the case that the TextCursor has row and column initilized to 0, so the updateCursorFormat() wouldn't happen. This is fixed by moving updateCursorFormat() line to be after the if (oldRow != _row || oldColumn != _column) block, so that it always gets called even when first double-clicking the initial character of a text element.