Skip to content

Commit

Permalink
fix #117191 and fix #82021 attempt to correct font kerning under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioBL committed Sep 28, 2017
1 parent 072c135 commit 669398f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libmscore/fret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FretDiagram::FretDiagram(Score* score)
{
setFlags(ElementFlag::MOVABLE | ElementFlag::ON_STAFF | ElementFlag::SELECTABLE);
font.setFamily("FreeSans");
int size = lrint(4.0 * mag());
int size = lrint(4.0 * mag() * spatium() / SPATIUM20);
font.setPixelSize(size);
}

Expand Down
7 changes: 6 additions & 1 deletion libmscore/mscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ static const int MAX_TAGS = 32;

static constexpr qreal INCH = 25.4;
static constexpr qreal PPI = 72.0; // printer points per inch
#ifdef Q_OS_WIN
static constexpr qreal DPIFACTOR = 10.0;
#else
static constexpr qreal DPIFACTOR = 1.0;
#endif
static constexpr qreal SPATIUM20 = 5.0;
static constexpr qreal DPI = 72.0;
static constexpr qreal DPI = 72.0 * DPIFACTOR;
static constexpr qreal DPMM = DPI / INCH;

static constexpr int MAX_STAVES = 4;
Expand Down
4 changes: 2 additions & 2 deletions libmscore/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ QFont TextFragment::font(const Text* t) const

qreal m = format.fontSize();
if (t->textStyle().sizeIsSpatiumDependent())
m *= t->spatium() / SPATIUM20;
m *= t->spatium() / SPATIUM20 / DPIFACTOR;

font.setUnderline(format.underline() || format.preedit());
if (format.type() == CharFormatType::TEXT) {
Expand All @@ -234,7 +234,7 @@ QFont TextFragment::font(const Text* t) const
if (format.valign() != VerticalAlignment::AlignNormal)
m *= subScriptSize;

font.setPixelSize(lrint(m));
font.setPixelSize(lrint(m * DPIFACTOR));
return font;
}

Expand Down
6 changes: 4 additions & 2 deletions mscore/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2621,11 +2621,13 @@ bool MuseScore::saveSvg(Score* score, const QString& saveName)
qreal w = r.width();
qreal h = r.height();

printer.setSize(QSize(w, h));
printer.setViewBox(QRectF(0, 0, w, h));
printer.setSize(QSize(w / DPIFACTOR, h / DPIFACTOR));
printer.setViewBox(QRectF(0, 0, w / DPIFACTOR, h / DPIFACTOR));
QPainter p(&printer);
p.setRenderHint(QPainter::Antialiasing, true);
p.setRenderHint(QPainter::TextAntialiasing, true);
double mag = 1.0 / DPIFACTOR;
p.scale(mag, mag);
if (trimMargin >= 0)
p.translate(-r.topLeft());
// 1st pass: StaffLines
Expand Down

0 comments on commit 669398f

Please sign in to comment.