Skip to content

19571 empty lines in text frames #29018

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/engraving/dom/textbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,11 @@ void TextBlock::changeFormat(FormatId id, const FormatValue& data, int start, in
for (auto i = m_fragments.begin(); i != m_fragments.end(); ++i) {
int columns = i->columns();
if (start + n <= col) {
if (columns == 0) {
// still apply the format change. Otherwise we have deviating formats for e. g. empty lines
// otherwise we have Issue #19571
i->changeFormat(id, data);
}
break;
}
if (start >= col + columns) {
Expand Down
29 changes: 29 additions & 0 deletions src/engraving/tests/textbase_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,35 @@ TEST_F(Engraving_TextBaseTests, undoChangeFontStyleProperty)
EXPECT_EQ(staffText->xmlText(), u"normal bold underline italic");
}

TEST_F(Engraving_TextBaseTests, undoChangeFontSizeEmptyLines) // Testcase for Issue #19571
{
MasterScore* score = ScoreRW::readScore(u"test.mscx");
StaffText* staffText = addStaffText(score);

String originalText = u"<font size=\"25\"/>Line 1\nLine 2\n\n\nLine 5"; // Two lines of text, two empty lines, one line of text.
String expectedText = u"<font size=\"30\"/>Line 1\nLine 2\n\n\nLine 5"; // The font size should change for all lines, including the empty ones.

staffText->setXmlText(originalText);
LOGD("Text is initially: %s", muPrintable(staffText->xmlText().replace(u"\n", u"\\n")));
score->renderer()->layoutItem(staffText);

score->startCmd(TranslatableString::untranslatable("Engraving text base tests"));
staffText->undoChangeProperty(Pid::FONT_SIZE, PropertyValue::fromValue(30.0), PropertyFlags::UNSTYLED); // Change font size from 25 to 30
score->endCmd();

LOGD(" 1.: Text is now : %s", muPrintable(staffText->xmlText().replace(u"\n", u"\\n")));
EXPECT_EQ(staffText->xmlText(), expectedText); // The font size should change for all lines, including the empty ones.

EditData ed;
score->undoStack()->undo(&ed);
LOGD(" 2.: Text is now : %s", muPrintable(staffText->xmlText().replace(u"\n", u"\\n")));
EXPECT_EQ(staffText->xmlText(), originalText);

score->undoStack()->redo(&ed);
LOGD(" 3.: Text is now : %s", muPrintable(staffText->xmlText().replace(u"\n", u"\\n")));
EXPECT_EQ(staffText->xmlText(), expectedText);
}

TEST_F(Engraving_TextBaseTests, musicalSymbolsNotBold)
{
MasterScore* score = ScoreRW::readScore(u"test.mscx");
Expand Down
Loading