forked from qt-creator/qt-creator
Fonts: Add Medium SourceCodePro font variants
Add the Medium font families. The Medium variants make sure that on a MacBook Pro with Retina display the font doesn't look out of place being too thin. Taken from https://github.com/adobe-fonts/source-code-pro/releases/tag/ 2.030R-ro%2F1.050R-it We need to stay with version 2.0.30 due to hinting on Windows, and to force QFont::Medium on macOS due to the fact that the medium font is not picked up. Newer versions like 2.0.42 do not have this issue. Task-number: QTCREATORBUG-29964 Change-Id: I4c0fba5730c4a6b869d900642b675698c29c6ae8 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -647,9 +647,12 @@ SQLite (https://www.sqlite.org) is in the Public Domain.
|
|||||||
|
|
||||||
Qt Creator ships with the following fonts licensed under OFL-1.1:
|
Qt Creator ships with the following fonts licensed under OFL-1.1:
|
||||||
|
|
||||||
* SourceCodePro-Regular.ttf
|
|
||||||
* SourceCodePro-It.ttf
|
|
||||||
* SourceCodePro-Bold.ttf
|
* SourceCodePro-Bold.ttf
|
||||||
|
* SourceCodePro-BoldIt.ttf
|
||||||
|
* SourceCodePro-It.ttf
|
||||||
|
* SourceCodePro-Medium.ttf
|
||||||
|
* SourceCodePro-MediumIt.ttf
|
||||||
|
* SourceCodePro-Regular.ttf
|
||||||
|
|
||||||
SIL OPEN FONT LICENSE
|
SIL OPEN FONT LICENSE
|
||||||
|
|
||||||
|
@@ -686,9 +686,12 @@
|
|||||||
\QC ships with the following fonts licensed under OFL-1.1:
|
\QC ships with the following fonts licensed under OFL-1.1:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li SourceCodePro-Regular.ttf
|
|
||||||
\li SourceCodePro-It.ttf
|
|
||||||
\li SourceCodePro-Bold.ttf
|
\li SourceCodePro-Bold.ttf
|
||||||
|
\li SourceCodePro-BoldIt.ttf
|
||||||
|
\li SourceCodePro-It.ttf
|
||||||
|
\li SourceCodePro-Medium.ttf
|
||||||
|
\li SourceCodePro-MediumIt.ttf
|
||||||
|
\li SourceCodePro-Regular.ttf
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
|
@@ -32,6 +32,8 @@ const char schemeFileNamesKey[] = "ColorSchemes";
|
|||||||
|
|
||||||
const bool DEFAULT_ANTIALIAS = true;
|
const bool DEFAULT_ANTIALIAS = true;
|
||||||
|
|
||||||
|
const char g_sourceCodePro[] = "Source Code Pro";
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
// -- FontSettings
|
// -- FontSettings
|
||||||
@@ -172,7 +174,7 @@ QTextCharFormat FontSettings::toTextCharFormat(TextStyle category) const
|
|||||||
tf.setBackground(QColor());
|
tf.setBackground(QColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
tf.setFontWeight(f.bold() ? QFont::Bold : QFont::Normal);
|
tf.setFontWeight(f.bold() ? QFont::Bold : fontNormalWeight());
|
||||||
tf.setFontItalic(f.italic());
|
tf.setFontItalic(f.italic());
|
||||||
|
|
||||||
tf.setUnderlineColor(f.underlineColor());
|
tf.setUnderlineColor(f.underlineColor());
|
||||||
@@ -218,6 +220,7 @@ QBrush mixBrush(const QBrush &original, double relativeSaturation, double relati
|
|||||||
void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
||||||
const MixinTextStyles &mixinStyles) const
|
const MixinTextStyles &mixinStyles) const
|
||||||
{
|
{
|
||||||
|
const int normalWeight = fontNormalWeight();
|
||||||
for (TextStyle mixinStyle : mixinStyles) {
|
for (TextStyle mixinStyle : mixinStyles) {
|
||||||
const Format &format = m_scheme.formatFor(mixinStyle);
|
const Format &format = m_scheme.formatFor(mixinStyle);
|
||||||
|
|
||||||
@@ -242,8 +245,8 @@ void FontSettings::addMixinStyle(QTextCharFormat &textCharFormat,
|
|||||||
if (!textCharFormat.fontItalic())
|
if (!textCharFormat.fontItalic())
|
||||||
textCharFormat.setFontItalic(format.italic());
|
textCharFormat.setFontItalic(format.italic());
|
||||||
|
|
||||||
if (textCharFormat.fontWeight() == QFont::Normal)
|
if (textCharFormat.fontWeight() == normalWeight)
|
||||||
textCharFormat.setFontWeight(format.bold() ? QFont::Bold : QFont::Normal);
|
textCharFormat.setFontWeight(format.bold() ? QFont::Bold : normalWeight);
|
||||||
|
|
||||||
if (textCharFormat.underlineStyle() == QTextCharFormat::NoUnderline) {
|
if (textCharFormat.underlineStyle() == QTextCharFormat::NoUnderline) {
|
||||||
textCharFormat.setUnderlineStyle(format.underlineStyle());
|
textCharFormat.setUnderlineStyle(format.underlineStyle());
|
||||||
@@ -356,6 +359,15 @@ QFont FontSettings::font() const
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FontSettings::fontNormalWeight() const
|
||||||
|
{
|
||||||
|
// TODO: Fix this when we upgrade "Source Code Pro" to a version greater than 2.0.30
|
||||||
|
int weight = QFont::Normal;
|
||||||
|
if (Utils::HostOsInfo::isMacHost() && m_family == g_sourceCodePro)
|
||||||
|
weight = QFont::Medium;
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configured antialiasing behavior.
|
* Returns the configured antialiasing behavior.
|
||||||
*/
|
*/
|
||||||
@@ -477,7 +489,7 @@ static QString defaultFontFamily()
|
|||||||
if (Utils::HostOsInfo::isMacHost())
|
if (Utils::HostOsInfo::isMacHost())
|
||||||
return QLatin1String("Monaco");
|
return QLatin1String("Monaco");
|
||||||
|
|
||||||
const QString sourceCodePro("Source Code Pro");
|
const QString sourceCodePro(g_sourceCodePro);
|
||||||
const QFontDatabase dataBase;
|
const QFontDatabase dataBase;
|
||||||
if (dataBase.hasFamily(sourceCodePro))
|
if (dataBase.hasFamily(sourceCodePro))
|
||||||
return sourceCodePro;
|
return sourceCodePro;
|
||||||
|
@@ -61,6 +61,7 @@ public:
|
|||||||
void setRelativeLineSpacing(int relativeLineSpacing);
|
void setRelativeLineSpacing(int relativeLineSpacing);
|
||||||
|
|
||||||
QFont font() const;
|
QFont font() const;
|
||||||
|
int fontNormalWeight() const;
|
||||||
|
|
||||||
bool antialias() const;
|
bool antialias() const;
|
||||||
void setAntialias(bool antialias);
|
void setAntialias(bool antialias);
|
||||||
|
BIN
src/share/3rdparty/fonts/SourceCodePro-Medium.ttf
vendored
Normal file
BIN
src/share/3rdparty/fonts/SourceCodePro-Medium.ttf
vendored
Normal file
Binary file not shown.
BIN
src/share/3rdparty/fonts/SourceCodePro-MediumIt.ttf
vendored
Normal file
BIN
src/share/3rdparty/fonts/SourceCodePro-MediumIt.ttf
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user