summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase.cpp15
-rw-r--r--src/gui/text/qplatformfontdatabase.cpp104
-rw-r--r--src/gui/text/qtextengine.cpp4
-rw-r--r--src/gui/text/qtextlayout.cpp2
4 files changed, 66 insertions, 59 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 86a0bf1066..c3be9da2f7 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -822,6 +822,13 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
+ // If the font data's native stretch matches the requested stretch we need to set stretch to 100
+ // to avoid the fontengine synthesizing stretch. If they didn't match exactly we need to calculate
+ // the new stretch factor. This only done if not matched by styleName.
+ bool styleNameMatch = !request.styleName.isEmpty() && request.styleName == style->styleName;
+ if (!styleNameMatch && style->key.stretch != 0 && request.stretch != 0)
+ def.stretch = (request.stretch * 100 + 50) / style->key.stretch;
+
engine = pfdb->fontEngine(def, size->handle);
if (engine) {
Q_ASSERT(engine->type() != QFontEngine::Multi);
@@ -931,7 +938,7 @@ static
unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
const QtFontFamily *family, const QString &foundry_name,
QtFontStyle::Key styleKey, int pixelSize, char pitch,
- QtFontDesc *desc, int force_encoding_id)
+ QtFontDesc *desc, int force_encoding_id, QString styleName = QString())
{
Q_UNUSED(force_encoding_id);
Q_UNUSED(script);
@@ -953,7 +960,7 @@ unsigned int bestFoundry(int script, unsigned int score, int styleStrategy,
FM_DEBUG(" looking for matching style in foundry '%s' %d",
foundry->name.isEmpty() ? "-- none --" : foundry->name.toLatin1().constData(), foundry->count);
- QtFontStyle *style = bestStyle(foundry, styleKey);
+ QtFontStyle *style = bestStyle(foundry, styleKey, styleName);
if (!style->smoothScalable && (styleStrategy & QFont::ForceOutline)) {
FM_DEBUG(" ForceOutline set, but not smoothly scalable");
@@ -1140,13 +1147,13 @@ static int match(int script, const QFontDef &request,
unsigned int newscore =
bestFoundry(script, score, request.styleStrategy,
test.family, foundry_name, styleKey, request.pixelSize, pitch,
- &test, force_encoding_id);
+ &test, force_encoding_id, request.styleName);
if (test.foundry == 0) {
// the specific foundry was not found, so look for
// any foundry matching our requirements
newscore = bestFoundry(script, score, request.styleStrategy, test.family,
QString(), styleKey, request.pixelSize,
- pitch, &test, force_encoding_id);
+ pitch, &test, force_encoding_id, request.styleName);
}
if (newscore < score) {
diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp
index 5dc81d241d..e1d58a0d05 100644
--- a/src/gui/text/qplatformfontdatabase.cpp
+++ b/src/gui/text/qplatformfontdatabase.cpp
@@ -550,60 +550,58 @@ QSupportedWritingSystems QPlatformFontDatabase::writingSystemsFromTrueTypeBits(q
}
}
}
- if (!hasScript) {
- if (codePageRange[0] & ((1 << Latin1CsbBit) | (1 << CentralEuropeCsbBit) | (1 << TurkishCsbBit) | (1 << BalticCsbBit))) {
- writingSystems.setSupported(QFontDatabase::Latin);
- hasScript = true;
- //qDebug("font %s supports Latin", familyName.latin1());
- }
- if (codePageRange[0] & (1 << CyrillicCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Cyrillic);
- hasScript = true;
- //qDebug("font %s supports Cyrillic", familyName.latin1());
- }
- if (codePageRange[0] & (1 << GreekCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Greek);
- hasScript = true;
- //qDebug("font %s supports Greek", familyName.latin1());
- }
- if (codePageRange[0] & (1 << HebrewCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Hebrew);
- hasScript = true;
- //qDebug("font %s supports Hebrew", familyName.latin1());
- }
- if (codePageRange[0] & (1 << ArabicCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Arabic);
- hasScript = true;
- //qDebug("font %s supports Arabic", familyName.latin1());
- }
- if (codePageRange[0] & (1 << VietnameseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Vietnamese);
- hasScript = true;
- //qDebug("font %s supports Vietnamese", familyName.latin1());
- }
- if (codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::SimplifiedChinese);
- hasScript = true;
- //qDebug("font %s supports Simplified Chinese", familyName.latin1());
- }
- if (codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::TraditionalChinese);
- hasScript = true;
- //qDebug("font %s supports Traditional Chinese", familyName.latin1());
- }
- if (codePageRange[0] & (1 << JapaneseCsbBit)) {
- writingSystems.setSupported(QFontDatabase::Japanese);
- hasScript = true;
- //qDebug("font %s supports Japanese", familyName.latin1());
- }
- if (codePageRange[0] & ((1 << KoreanCsbBit) | (1 << KoreanJohabCsbBit))) {
- writingSystems.setSupported(QFontDatabase::Korean);
- hasScript = true;
- //qDebug("font %s supports Korean", familyName.latin1());
- }
- if (!hasScript)
- writingSystems.setSupported(QFontDatabase::Symbol);
+ if (codePageRange[0] & ((1 << Latin1CsbBit) | (1 << CentralEuropeCsbBit) | (1 << TurkishCsbBit) | (1 << BalticCsbBit))) {
+ writingSystems.setSupported(QFontDatabase::Latin);
+ hasScript = true;
+ //qDebug("font %s supports Latin", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << CyrillicCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Cyrillic);
+ hasScript = true;
+ //qDebug("font %s supports Cyrillic", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << GreekCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Greek);
+ hasScript = true;
+ //qDebug("font %s supports Greek", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << HebrewCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Hebrew);
+ hasScript = true;
+ //qDebug("font %s supports Hebrew", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << ArabicCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Arabic);
+ hasScript = true;
+ //qDebug("font %s supports Arabic", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << VietnameseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Vietnamese);
+ hasScript = true;
+ //qDebug("font %s supports Vietnamese", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << SimplifiedChineseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::SimplifiedChinese);
+ hasScript = true;
+ //qDebug("font %s supports Simplified Chinese", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << TraditionalChineseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::TraditionalChinese);
+ hasScript = true;
+ //qDebug("font %s supports Traditional Chinese", familyName.latin1());
+ }
+ if (codePageRange[0] & (1 << JapaneseCsbBit)) {
+ writingSystems.setSupported(QFontDatabase::Japanese);
+ hasScript = true;
+ //qDebug("font %s supports Japanese", familyName.latin1());
+ }
+ if (codePageRange[0] & ((1 << KoreanCsbBit) | (1 << KoreanJohabCsbBit))) {
+ writingSystems.setSupported(QFontDatabase::Korean);
+ hasScript = true;
+ //qDebug("font %s supports Korean", familyName.latin1());
}
+ if (!hasScript)
+ writingSystems.setSupported(QFontDatabase::Symbol);
return writingSystems;
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 452b263670..b192460f07 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -118,7 +118,9 @@ private:
return;
const int end = start + length;
for (int i = start + 1; i < end; ++i) {
- if (m_analysis[i] == m_analysis[start]
+ if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
+ && m_analysis[i].flags == m_analysis[start].flags
+ && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index ad00396553..5056319b9d 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -2501,7 +2501,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const
}
int lineEnd = line.from + line.length + line.trailingSpaces;
- int pos = *cursorPos;
+ int pos = qBound(0, *cursorPos, lineEnd);
int itm;
const QCharAttributes *attributes = eng->attributes();
if (!attributes) {