MuseScore
MuseScore copied to clipboard
[MU4 Issue] Creating score from custom templates ignores page settings
Describe the bug When creating a score from a custom template, the page settings are not reflected and default settings are used.
To Reproduce Steps to reproduce the behavior:
- Create a custom template.
- Modify the template's margins or scaling in Page Settings
- Save the template.
- Create a new score from the template.
- Go to Page Settings.
- See settings are set to default.
Expected behavior The created score should use the same page settings as the template.
Platform information
- OS: Windows 11
Additional context This occurs when the page size setting of the template is set to default (A4).
Can you attach the template with the problem (ZIP it first so GitHub will accept it), or describe exactly what page settings you are making?
What should happen is that custom sizes are honored for sizes other than A4 or Letter. But those two sizes in particular are meant to be ignored in favor of whatever the default is on your system. That way the standard templates produce the right results everywhere in the world.
Scaling should always be respected however.
Both of these are working as expected for me.
What OS are you on, what is the default page size on your system, and do you have a custom style file defined in Edit / Preferences / Score?
The template file is below. template test.zip
I touched only the settings marked in red.
I'm on Windows 11, default page size is A4, and no style file defined there.
I found the cause of the problem. The behavior of resetting page style was introduced in commit https://github.com/musescore/MuseScore/pull/14561/commits/ff20b08c1c0a29fb7fcc232acf5478725902d84b.
@MarcSabatella Is it intended behavior to reset all page settings when the score size is the default? I think only the page size should be reset here. Otherwise, the custom template will not be able to override only other page settings than page size.
Good question! As I say in the comments, it's kind of debatable what should be preserved and what should not. Page size is not independent from margins, or from the double-sided setting, etc. If you've set a custom page size, there's a good chance you've also set custom margins etc, and you'll want them all to "win". Sorry for not realizing earlier that this must be what you were seeing.
So, we want the apply the defaultStyle in cases where the template is at the actual default (baseStyle). What if, in the loop through these styles where we set each to the defaultStyle, we first check to see if the template has actually changed this from the baseStyle style, and only override it if not? That is, instead of just checking the page size against the base style before the loop, then resetting all the page style, we check each of the page style settings one at a time?
The need to do the "fuzzy math" is a little annoying but presumably can be dealt with in the loop.
I think I actually considered doing this but didn't see the need. But if it results in a template not being able to set a custom margin, that's a need.
@MarcSabatella, I discovered this open issue and wonder why you decide your PR was no longer required. As this is still a problem in MS4. Here is a process I would like to get working:
- Create a new score, using the default option to select instruments
- Add 4 instruments
- Set the desired Page settings (margin and scale) so that by default I get 4 systems on a page, in this example I set the scale factor to 1.65mm and top/bottom margins to 10mm.
- Save the score in my templates folder
- Create a new score based on my new custom template
As I am now creating a new score using a custom template, there is no automatic scale factor applied. The result is that, even though I did create my desired template, the scale factor is set to the default of 1.75mm and the page margins are set to 15mm.
It is really annoying that I can't make proper use of the template anymore and now need to revert back to manually duplicating files and then remember I have to update/amend all previous recorded data in the file (like project tags, etc.). Custom templates used to be a great feature of MS, for me it became a lot more limited.
I closed the PR because it was no longer needed to fix the main problem it was trying to address, and it would now be the wrong approach to solve the secondary problem mention here. But as I said above, sure, it does seem here could be some special casing added so that margins could somehow still be respected. And respecting staff space seems like it would be straightforward enough.