Skip to content

Commit

Permalink
Properly deal with </font>
Browse files Browse the repository at this point in the history
instead of ignoring it altogether, reset font face and -size back to what it was before `<font ...>`
  • Loading branch information
Jojo-Schmitz committed Mar 18, 2024
1 parent 326b06c commit a3e4503
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/engraving/dom/textbase.cpp
Expand Up @@ -1893,6 +1893,9 @@ void TextBase::createBlocks(LayoutData* ldata) const
//---------------------------------------------------------
bool TextBase::prepareFormat(const String& token, CharFormat& format)
{
static String prevFontFace;
static double prevFontSize = 0;

if (token == "b") {
format.setBold(true);
return true;
Expand Down Expand Up @@ -1924,16 +1927,28 @@ bool TextBase::prepareFormat(const String& token, CharFormat& format)
} else if (token.startsWith(u"font ")) {
String remainder = token.mid(5);
if (remainder.startsWith(u"size=\"")) {
prevFontSize = format.fontSize();
format.setFontSize(parseNumProperty(remainder.mid(6)));
return true;
} else if (remainder.startsWith(u"face=\"")) {
String face = parseStringProperty(remainder.mid(6));
face = unEscape(face);
prevFontFace = format.fontFamily();
format.setFontFamily(face);
return true;
} else {
LOGD("cannot parse html property <%s> in text <%s>", muPrintable(token), muPrintable(m_text));
}
} else if (token == u"/font") {
if (prevFontSize) {
format.setFontSize(prevFontSize);
prevFontSize = 0;
}
if (!prevFontFace.isEmpty()) {
format.setFontFamily(prevFontFace);
prevFontFace = u"";
}
return true;
}
return false;
}
Expand Down

0 comments on commit a3e4503

Please sign in to comment.