fix text layout regressions
This commit is contained in:
parent
7f85859706
commit
9f57c06f51
16 changed files with 42 additions and 59 deletions
|
@ -74,8 +74,8 @@ void Bend::layout()
|
|||
QRectF bb;
|
||||
|
||||
const TextStyle* st = &score()->textStyle(TextStyleType::BENCH);
|
||||
QFont f = st->fontPx(_spatium);
|
||||
QFontMetricsF fm(f);
|
||||
// QFont f = st->fontPx(_spatium);
|
||||
QFontMetricsF fm(st->fontMetrics(_spatium));
|
||||
|
||||
int n = _points.size();
|
||||
qreal x = noteWidth;
|
||||
|
@ -167,7 +167,7 @@ void Bend::draw(QPainter* painter) const
|
|||
|
||||
qreal _spatium = spatium();
|
||||
const TextStyle* st = &score()->textStyle(TextStyleType::BENCH);
|
||||
QFont f = st->fontPx(_spatium);
|
||||
QFont f = st->font(_spatium);
|
||||
painter->setFont(f);
|
||||
|
||||
int n = _points.size();
|
||||
|
|
|
@ -100,13 +100,14 @@ void GlissandoSegment::draw(QPainter* painter) const
|
|||
}
|
||||
if (glissando()->showText()) {
|
||||
const TextStyle& st = score()->textStyle(TextStyleType::GLISSANDO);
|
||||
QFont f = st.fontPx(_spatium);
|
||||
QRectF r = QFontMetricsF(f, MScore::paintDevice()).boundingRect(glissando()->text());
|
||||
QRectF r = st.fontMetrics(_spatium).boundingRect(glissando()->text());
|
||||
// if text longer than available space, skip it
|
||||
if (r.width() < l) {
|
||||
qreal yOffset = r.height() + r.y(); // find text descender height
|
||||
// raise text slightly above line and slightly more with WAVY than with STRAIGHT
|
||||
yOffset += _spatium * (glissando()->glissandoType() == Glissando::Type::WAVY ? 0.4 : 0.1);
|
||||
QFont f = st.font(_spatium);
|
||||
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
|
||||
painter->setFont(f);
|
||||
qreal x = (l - r.width()) * 0.5;
|
||||
painter->drawText(QPointF(x, -yOffset), glissando()->text());
|
||||
|
|
|
@ -1172,7 +1172,9 @@ void Harmony::draw(QPainter* painter) const
|
|||
QColor color = textColor();
|
||||
painter->setPen(color);
|
||||
foreach(const TextSegment* ts, textList) {
|
||||
painter->setFont(ts->font);
|
||||
QFont f(ts->font);
|
||||
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
|
||||
painter->setFont(f);
|
||||
painter->drawText(QPointF(ts->x, ts->y), ts->text);
|
||||
}
|
||||
}
|
||||
|
@ -1193,7 +1195,7 @@ TextSegment::TextSegment(const QString& s, const QFont& f, qreal x, qreal y)
|
|||
|
||||
qreal TextSegment::width() const
|
||||
{
|
||||
QFontMetricsF fm(font);
|
||||
QFontMetricsF fm(font, MScore::paintDevice());
|
||||
#if 1
|
||||
return fm.width(text);
|
||||
#else
|
||||
|
@ -1214,7 +1216,7 @@ qreal TextSegment::width() const
|
|||
|
||||
QRectF TextSegment::boundingRect() const
|
||||
{
|
||||
QFontMetricsF fm(font);
|
||||
QFontMetricsF fm(font, MScore::paintDevice());
|
||||
return fm.boundingRect(text);
|
||||
}
|
||||
|
||||
|
@ -1224,7 +1226,7 @@ QRectF TextSegment::boundingRect() const
|
|||
|
||||
QRectF TextSegment::tightBoundingRect() const
|
||||
{
|
||||
QFontMetricsF fm(font);
|
||||
QFontMetricsF fm(font, MScore::paintDevice());
|
||||
return fm.tightBoundingRect(text);
|
||||
}
|
||||
|
||||
|
@ -1358,15 +1360,15 @@ void Harmony::render(const TextStyle* st)
|
|||
fontList.clear();
|
||||
foreach(ChordFont cf, chordList->fonts) {
|
||||
if (cf.family.isEmpty() || cf.family == "default")
|
||||
fontList.append(st->fontPx(spatium() * cf.mag));
|
||||
fontList.append(st->font(spatium() * cf.mag));
|
||||
else {
|
||||
QFont ff(st->fontPx(spatium() * cf.mag));
|
||||
QFont ff(st->font(spatium() * cf.mag));
|
||||
ff.setFamily(cf.family);
|
||||
fontList.append(ff);
|
||||
}
|
||||
}
|
||||
if (fontList.empty())
|
||||
fontList.append(st->fontPx(spatium()));
|
||||
fontList.append(st->font(spatium()));
|
||||
|
||||
foreach(const TextSegment* s, textList)
|
||||
delete s;
|
||||
|
|
|
@ -790,7 +790,6 @@ SpannerSegment* SLine::layoutSystem(System* system)
|
|||
break;
|
||||
}
|
||||
}
|
||||
printf("===%p line segment %s segments %p %d\n", this, name(), lineSegm, segments.size());
|
||||
if (!lineSegm) {
|
||||
lineSegm = createLineSegment();
|
||||
add(lineSegm);
|
||||
|
|
|
@ -261,8 +261,6 @@ void Lyrics::layout()
|
|||
|
||||
void Lyrics::layout1()
|
||||
{
|
||||
// setPos(textStyle().offset(spatium())); text offset ignored, replaced by element style options
|
||||
|
||||
setPos(QPointF());
|
||||
Text::layout1();
|
||||
if (!parent()) // palette & clone trick
|
||||
|
|
|
@ -5780,7 +5780,7 @@ void ScoreFont::computeMetrics(Sym* sym, int code)
|
|||
sym->setIndex(index);
|
||||
sym->setCode(code);
|
||||
sym->setBbox(bbox);
|
||||
sym->setAdvance(face->glyph->linearHoriAdvance / 655360.0);
|
||||
sym->setAdvance(face->glyph->linearHoriAdvance * DPI_F/ 655360.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ void TextBlock::layout(Text* t)
|
|||
}
|
||||
}
|
||||
if (_text.empty()) {
|
||||
QFontMetricsF fm(t->textStyle().fontPx(t->spatium()), MScore::paintDevice());
|
||||
QFontMetricsF fm = t->textStyle().fontMetrics(t->spatium());
|
||||
_bbox.setRect(0.0, -fm.ascent(), 1.0, fm.descent());
|
||||
_lineSpacing = fm.lineSpacing();
|
||||
}
|
||||
|
@ -988,10 +988,10 @@ QRectF Text::cursorRect() const
|
|||
if (fragment) {
|
||||
font = fragment->font(this);
|
||||
//TODOxxxx if (font.family() == score()->scoreFont()->font().family())
|
||||
// font = _textStyle.fontPx(spatium());
|
||||
// font = _textStyle.font(spatium());
|
||||
}
|
||||
else
|
||||
font = _textStyle.fontPx(spatium());
|
||||
font = _textStyle.font(spatium());
|
||||
|
||||
qreal ascent = QFontMetricsF(font, MScore::paintDevice()).ascent() * .7;
|
||||
qreal h = ascent; // lineSpacing();
|
||||
|
@ -1328,7 +1328,7 @@ void Text::layoutFrame()
|
|||
|
||||
qreal Text::lineSpacing() const
|
||||
{
|
||||
return QFontMetricsF(textStyle().fontPx(spatium()), MScore::paintDevice()).lineSpacing();
|
||||
return textStyle().fontMetrics(spatium()).lineSpacing();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1337,7 +1337,7 @@ qreal Text::lineSpacing() const
|
|||
|
||||
qreal Text::lineHeight() const
|
||||
{
|
||||
return QFontMetricsF(textStyle().fontPx(spatium()), MScore::paintDevice()).height();
|
||||
return textStyle().fontMetrics(spatium()).height();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1346,7 +1346,7 @@ qreal Text::lineHeight() const
|
|||
|
||||
qreal Text::baseLine() const
|
||||
{
|
||||
return QFontMetricsF(textStyle().fontPx(spatium()), MScore::paintDevice()).ascent();
|
||||
return textStyle().fontMetrics(spatium()).ascent();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
|
|
@ -163,29 +163,7 @@ QFont TextStyleData::font(qreal _spatium) const
|
|||
if (sizeIsSpatiumDependent)
|
||||
m *= _spatium / SPATIUM20;
|
||||
|
||||
f.setPointSizeF(m * MScore::pixelRatio);
|
||||
return f;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// font
|
||||
//---------------------------------------------------------
|
||||
|
||||
QFont TextStyleData::fontPx(qreal _spatium) const
|
||||
{
|
||||
qreal m = size;
|
||||
|
||||
QFont f(family);
|
||||
f.setBold(bold);
|
||||
f.setItalic(italic);
|
||||
f.setUnderline(underline);
|
||||
#ifdef USE_GLYPHS
|
||||
f.setHintingPreference(QFont::PreferVerticalHinting);
|
||||
#endif
|
||||
if (sizeIsSpatiumDependent)
|
||||
m *= _spatium / SPATIUM20;
|
||||
|
||||
f.setPointSize(m * MScore::pixelRatio);
|
||||
// f.setPointSizeF(m * MScore::pixelRatio);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
@ -456,7 +434,6 @@ void TextStyle::setBackgroundColor(const QColor& v) { d->backgroundColor =
|
|||
void TextStyle::write(Xml& xml) const { d->write(xml); }
|
||||
void TextStyle::read(XmlReader& v) { d->read(v); }
|
||||
QFont TextStyle::font(qreal space) const { return d->font(space); }
|
||||
QFont TextStyle::fontPx(qreal spatium) const { return d->fontPx(spatium); }
|
||||
QRectF TextStyle::bbox(qreal sp, const QString& s) const { return d->bbox(sp, s); }
|
||||
QFontMetricsF TextStyle::fontMetrics(qreal space) const { return d->fontMetrics(space); }
|
||||
bool TextStyle::operator!=(const TextStyle& s) const { return d->operator!=(*s.d); }
|
||||
|
|
|
@ -129,7 +129,6 @@ class TextStyle {
|
|||
void read(XmlReader& v);
|
||||
bool readProperties(XmlReader& v);
|
||||
QFont font(qreal spatium) const;
|
||||
QFont fontPx(qreal spatium) const;
|
||||
QRectF bbox(qreal spatium, const QString& s) const;
|
||||
QFontMetricsF fontMetrics(qreal spatium) const;
|
||||
bool operator!=(const TextStyle& s) const;
|
||||
|
|
|
@ -70,7 +70,6 @@ class TextStyleData : public QSharedData, public ElementLayout {
|
|||
bool readProperties(XmlReader& v);
|
||||
|
||||
QFont font(qreal space) const;
|
||||
QFont fontPx(qreal spatium) const;
|
||||
QRectF bbox(qreal space, const QString& s) const { return fontMetrics(space).boundingRect(s); }
|
||||
QFontMetricsF fontMetrics(qreal space) const { return QFontMetricsF(font(space), MScore::paintDevice()); }
|
||||
bool operator!=(const TextStyleData& s) const;
|
||||
|
|
|
@ -88,9 +88,10 @@ void TremoloBar::draw(QPainter* painter) const
|
|||
|
||||
qreal _spatium = spatium();
|
||||
const TextStyle* st = &score()->textStyle(TextStyleType::BENCH);
|
||||
QFont f = st->fontPx(_spatium);
|
||||
painter->setFont(f);
|
||||
QFont f = st->font(_spatium);
|
||||
f.setPointSizeF(f.pointSizeF() * MScore::pixelRatio);
|
||||
|
||||
painter->setFont(f);
|
||||
int n = _points.size();
|
||||
|
||||
int previousTime = _points[0].time;
|
||||
|
|
|
@ -126,7 +126,7 @@ void TrillSegment::layout()
|
|||
rypos() += score()->styleS(StyleIdx::trillY).val() * spatium();
|
||||
if (staff())
|
||||
setMag(staff()->mag());
|
||||
if (spannerSegmentType() == SpannerSegmentType::SINGLE || spannerSegmentType() == SpannerSegmentType::BEGIN) {
|
||||
if (isSingleType() || isBeginType()) {
|
||||
Accidental* a = trill()->accidental();
|
||||
if (a) {
|
||||
a->layout();
|
||||
|
@ -134,6 +134,7 @@ void TrillSegment::layout()
|
|||
qreal _spatium = spatium();
|
||||
a->setPos(_spatium * 1.3, -2.2 * _spatium);
|
||||
a->adjustReadPos();
|
||||
a->setParent(this);
|
||||
}
|
||||
switch (trill()->trillType()) {
|
||||
case Trill::Type::TRILL_LINE:
|
||||
|
|
|
@ -2343,6 +2343,7 @@ bool MuseScore::savePng(Score* score, const QString& name, bool screenshot, bool
|
|||
{
|
||||
bool rv = true;
|
||||
score->setPrinting(!screenshot); // dont print page break symbols etc.
|
||||
double pr = MScore::pixelRatio;
|
||||
|
||||
QImage::Format f;
|
||||
if (format != QImage::Format_Indexed8)
|
||||
|
@ -2373,6 +2374,8 @@ bool MuseScore::savePng(Score* score, const QString& name, bool screenshot, bool
|
|||
printer.setDotsPerMeterX(lrint((convDpi * 1000) / INCH));
|
||||
printer.setDotsPerMeterY(lrint((convDpi * 1000) / INCH));
|
||||
|
||||
MScore::pixelRatio = DPI / printer.logicalDpiX();
|
||||
|
||||
printer.fill(transparent ? 0 : 0xffffffff);
|
||||
|
||||
double mag = convDpi / DPI;
|
||||
|
@ -2435,6 +2438,7 @@ bool MuseScore::savePng(Score* score, const QString& name, bool screenshot, bool
|
|||
break;
|
||||
}
|
||||
score->setPrinting(false);
|
||||
MScore::pixelRatio = pr;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ void HarmonyCanvas::paintEvent(QPaintEvent* event)
|
|||
|
||||
double _spatium = 2.0 * PALETTE_SPATIUM / extraMag;
|
||||
const TextStyle* st = &gscore->textStyle(TextStyleType::HARMONY);
|
||||
QFont ff(st->fontPx(_spatium));
|
||||
QFont ff(st->font(_spatium * MScore::pixelRatio));
|
||||
ff.setFamily(sb->font().family());
|
||||
|
||||
QString s;
|
||||
|
@ -314,15 +314,15 @@ void HarmonyCanvas::render(const QList<RenderAction>& renderList, double& x, dou
|
|||
|
||||
foreach(ChordFont cf, chordList->fonts) {
|
||||
if (cf.family.isEmpty() || cf.family == "default")
|
||||
fontList.append(st->fontPx(_spatium * cf.mag));
|
||||
fontList.append(st->font(_spatium * cf.mag * MScore::pixelRatio));
|
||||
else {
|
||||
QFont ff(st->fontPx(_spatium * cf.mag));
|
||||
QFont ff(st->font(_spatium * cf.mag * MScore::pixelRatio));
|
||||
ff.setFamily(cf.family);
|
||||
fontList.append(ff);
|
||||
}
|
||||
}
|
||||
if (fontList.isEmpty())
|
||||
fontList.append(st->fontPx(_spatium));
|
||||
fontList.append(st->font(_spatium * MScore::pixelRatio));
|
||||
|
||||
foreach(const RenderAction& a, renderList) {
|
||||
if (a.type == RenderAction::RenderActionType::SET) {
|
||||
|
@ -471,7 +471,7 @@ void HarmonyCanvas::dropEvent(QDropEvent* event)
|
|||
|
||||
double _spatium = 2.0 * PALETTE_SPATIUM / extraMag;
|
||||
const TextStyle* st = &gscore->textStyle(TextStyleType::HARMONY);
|
||||
QFont ff(st->fontPx(_spatium));
|
||||
QFont ff(st->font(_spatium * MScore::pixelRatio));
|
||||
ff.setFamily(sb->font().family());
|
||||
|
||||
// qDebug("drop %s", dragElement->name());
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
</System>
|
||||
<System>
|
||||
</System>
|
||||
<System>
|
||||
</System>
|
||||
</Page>
|
||||
</PageList>
|
||||
<Part>
|
||||
|
|
Loading…
Reference in a new issue