summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@nokia.com>2011-08-31 11:54:04 (GMT)
committerSergio Ahumada <sergio.ahumada@nokia.com>2011-08-31 11:54:04 (GMT)
commit9f51c31a0f492c20e6d882b2ae1e036b29c2755c (patch)
treecbb3beed71735514632b4f2788b63e72667cfc04 /src/gui/text
parent0e10b8dbb7d84694cbdeb57bf42df52b12d79f47 (diff)
parent4f933036a0ecbc6e6174b312ec2fd6078cea5b70 (diff)
downloadQt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.zip
Qt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.tar.gz
Qt-9f51c31a0f492c20e6d882b2ae1e036b29c2755c.tar.bz2
Merge remote-tracking branch 'upstream/4.8' into qt-4.8-from-4.7
Conflicts: src/network/ssl/qsslcertificate.cpp
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfont.cpp5
-rw-r--r--src/gui/text/qfontdatabase.cpp10
-rw-r--r--src/gui/text/qfontengine_coretext.mm12
-rw-r--r--src/gui/text/qfontengine_coretext_p.h6
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/text/qfontmetrics.cpp3
-rw-r--r--src/gui/text/qglyphrun.cpp3
-rw-r--r--src/gui/text/qplatformfontdatabase_qpa.cpp28
-rw-r--r--src/gui/text/qrawfont.cpp3
-rw-r--r--src/gui/text/qrawfont_ft.cpp2
-rw-r--r--src/gui/text/qtextengine.cpp47
-rw-r--r--src/gui/text/qtextlayout.cpp6
-rw-r--r--src/gui/text/text.pri9
13 files changed, 94 insertions, 43 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 2d6af3b..2df88e2 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -919,8 +919,9 @@ QString QFont::styleName() const
/*!
\since 4.8
- Sets the style name of the font. When set, other style properties
- like \a style() and \a weight() will be ignored for font matching.
+ Sets the style name of the font to the given \a styleName.
+ When set, other style properties like style() and weight() will be ignored
+ for font matching.
\sa styleName()
*/
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 79503f9..1d463c4 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -1943,8 +1943,9 @@ bool QFontDatabase::isScalable(const QString &family,
/*!
- Returns a list of the point sizes available for the font that has
- family \a family and style \a style. The list may be empty.
+ \fn QList<int> QFontDatabase::pointSizes(const QString &family, const QString &style)
+ Returns a list of the point sizes available for the font with the
+ given \a family and \a style. The list may be empty.
\sa smoothSizes(), standardSizes()
*/
@@ -2052,8 +2053,9 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
/*!
- Returns the point sizes of a font that has family \a family and
- style \a style that will look attractive. The list may be empty.
+ \fn QList<int> QFontDatabase::smoothSizes(const QString &family, const QString &style)
+ Returns the point sizes of a font with the given \a family and \a style
+ that will look attractive. The list may be empty.
For non-scalable fonts and bitmap scalable fonts, this function
is equivalent to pointSizes().
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index 64d4a24..153451e 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -135,7 +135,7 @@ void QCoreTextFontEngineMulti::init(bool kerning)
attributeDict = CFDictionaryCreateMutable(0, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont);
+ CFDictionaryAddValue(attributeDict, kCTFontAttributeName, ctfont);
if (!kerning) {
float zero = 0.0;
QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
@@ -257,7 +257,7 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
//NSLog(@"Dictionary %@", runAttribs);
if (!runAttribs)
runAttribs = attributeDict;
- CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, NSFontAttributeName));
+ CTFontRef runFont = static_cast<CTFontRef>(CFDictionaryGetValue(runAttribs, kCTFontAttributeName));
uint fontIndex = fontIndexForFont(runFont);
const QFontEngine *engine = engineAt(fontIndex);
fontIndex <<= 24;
@@ -547,7 +547,6 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
ret.xoff = ret.xoff.round();
ret.yoff = ret.yoff.round();
}
-
return ret;
}
@@ -723,7 +722,12 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
QImage im(qRound(br.width) + 2, qRound(br.height) + 2, QImage::Format_RGB32);
im.fill(0);
- CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+ CGColorSpaceRef colorspace =
+#ifdef Q_WS_MAC
+ CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
+#else
+ CGColorSpaceCreateDeviceRGB();
+#endif
uint cgflags = kCGImageAlphaNoneSkipFirst;
#ifdef kCGBitmapByteOrder32Host //only needed because CGImage.h added symbols in the minor version
cgflags |= kCGBitmapByteOrder32Host;
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/gui/text/qfontengine_coretext_p.h
index efe8295..0a2ae1f 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/gui/text/qfontengine_coretext_p.h
@@ -44,6 +44,12 @@
#include <private/qfontengine_p.h>
+#ifdef QT_NO_CORESERVICES
+#include <CoreText/CoreText.h>
+#include <CoreGraphics/CoreGraphics.h>
+#include <private/qcore_mac_p.h>
+#endif
+
#if !defined(Q_WS_MAC) || (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
class QRawFontPrivate;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index a70aec1..8d81acb 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -155,6 +155,7 @@ public:
struct FaceId {
FaceId() : index(0), encoding(0) {}
QByteArray filename;
+ QByteArray uuid;
int index;
int encoding;
};
@@ -295,7 +296,7 @@ inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId
inline uint qHash(const QFontEngine::FaceId &f)
{
- return qHash((f.index << 16) + f.encoding) + qHash(f.filename);
+ return qHash((f.index << 16) + f.encoding) + qHash(f.filename + f.uuid);
}
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index f3d4107..1d93d54 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -442,9 +442,10 @@ bool QFontMetrics::inFont(QChar ch) const
}
/*!
+ \fn bool QFontMetrics::inFontUcs4(uint character) const
\since 4.8
- Returns true if the character encoded in UCS-4/UTF-32 is a valid
+ Returns true if the given \a character encoded in UCS-4/UTF-32 is a valid
character in the font; otherwise returns false.
*/
bool QFontMetrics::inFontUcs4(uint ucs4) const
diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp
index 2865d91..442f7cc 100644
--- a/src/gui/text/qglyphrun.cpp
+++ b/src/gui/text/qglyphrun.cpp
@@ -175,7 +175,8 @@ QRawFont QGlyphRun::rawFont() const
}
/*!
- Sets the font in which to look up the glyph indexes to \a font.
+ Sets the font specified by \a rawFont to be the font used to look up the
+ glyph indexes.
\sa rawFont(), setGlyphIndexes()
*/
diff --git a/src/gui/text/qplatformfontdatabase_qpa.cpp b/src/gui/text/qplatformfontdatabase_qpa.cpp
index d1d1f94..e3eeca5 100644
--- a/src/gui/text/qplatformfontdatabase_qpa.cpp
+++ b/src/gui/text/qplatformfontdatabase_qpa.cpp
@@ -160,6 +160,9 @@ QSupportedWritingSystems::QSupportedWritingSystems(const QSupportedWritingSystem
d->ref.ref();
}
+/*!
+ Assigns the \a other supported writing systems object to this object.
+*/
QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWritingSystems &other)
{
if (d != other.d) {
@@ -171,6 +174,9 @@ QSupportedWritingSystems &QSupportedWritingSystems::operator=(const QSupportedWr
return *this;
}
+/*!
+ Destroys the object.
+*/
QSupportedWritingSystems::~QSupportedWritingSystems()
{
if (!d->ref.deref())
@@ -187,12 +193,26 @@ void QSupportedWritingSystems::detach()
}
}
+/*!
+ Sets the supported state of the writing system given by \a writingSystem to
+ the value specified by \a support. A value of true indicates that the
+ writing system is supported; a value of false indicates that it is
+ unsupported.
+
+ \sa supported()
+*/
void QSupportedWritingSystems::setSupported(QFontDatabase::WritingSystem writingSystem, bool support)
{
detach();
d->vector[writingSystem] = support;
}
+/*!
+ Returns true if the writing system given by \a writingSystem is supported;
+ otherwise returns false.
+
+ \sa setSupported()
+*/
bool QSupportedWritingSystems::supported(QFontDatabase::WritingSystem writingSystem) const
{
return d->vector.at(writingSystem);
@@ -295,7 +315,7 @@ QStringList QPlatformFontDatabase::addApplicationFont(const QByteArray &fontData
}
/*!
-
+ Releases the font handle and deletes any associated data loaded from a file.
*/
void QPlatformFontDatabase::releaseHandle(void *handle)
{
@@ -304,7 +324,13 @@ void QPlatformFontDatabase::releaseHandle(void *handle)
}
/*!
+ Returns the path to the font directory.
+
+ The font directory is stored in the general Qt settings unless it has been
+ overridden by the \c QT_QPA_FONTDIR environment variable.
+ When using builds of Qt that do not support settings, the \c QT_QPA_FONTDIR
+ environment variable is the only way to specify the font directory.
*/
QString QPlatformFontDatabase::fontDir() const
{
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index e3e5c57..60a6cb3 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -485,7 +485,8 @@ QVector<quint32> QRawFont::glyphIndexesForString(const QString &text) const
must be at least \a numChars, if that's still not enough, this function will return
false, then you can resize \a glyphIndexes from the size returned in \a numGlyphs.
- \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs()
+ \sa glyphIndexesForString(), advancesForGlyphIndexes(), QGlyphRun,
+ QTextLayout::glyphRuns(), QTextFragment::glyphRuns()
*/
bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *glyphIndexes, int *numGlyphs) const
{
diff --git a/src/gui/text/qrawfont_ft.cpp b/src/gui/text/qrawfont_ft.cpp
index 5bba221..1666df3 100644
--- a/src/gui/text/qrawfont_ft.cpp
+++ b/src/gui/text/qrawfont_ft.cpp
@@ -45,6 +45,7 @@
#include "qrawfont_p.h"
#include "qfontengine_ft_p.h"
+#include "quuid.h"
#if defined(Q_WS_X11) && !defined(QT_NO_FONTCONFIG)
# include "qfontengine_x11_p.h"
@@ -87,6 +88,7 @@ public:
FaceId faceId;
faceId.filename = "";
faceId.index = 0;
+ faceId.uuid = QUuid::createUuid().toByteArray();
return init(faceId, true, Format_None, fontData);
}
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 093b43d..aa4a20d 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1532,33 +1532,38 @@ void QTextEngine::itemize() const
const ushort *e = uc + length;
int lastScript = QUnicodeTables::Common;
while (uc < e) {
- int script = QUnicodeTables::script(*uc);
- if (script == QUnicodeTables::Inherited)
- script = lastScript;
- analysis->flags = QScriptAnalysis::None;
- if (*uc == QChar::ObjectReplacementCharacter) {
- if (analysis->bidiLevel % 2)
- --analysis->bidiLevel;
+ switch (*uc) {
+ case QChar::ObjectReplacementCharacter:
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::Object;
- } else if (*uc == QChar::LineSeparator) {
+ break;
+ case QChar::LineSeparator:
if (analysis->bidiLevel % 2)
--analysis->bidiLevel;
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::LineOrParagraphSeparator;
if (option.flags() & QTextOption::ShowLineAndParagraphSeparators)
*const_cast<ushort*>(uc) = 0x21B5; // visual line separator
- } else if (*uc == 9) {
+ break;
+ case 9: // Tab
analysis->script = QUnicodeTables::Common;
analysis->flags = QScriptAnalysis::Tab;
analysis->bidiLevel = control.baseLevel();
- } else if ((*uc == 32 || *uc == QChar::Nbsp)
- && (option.flags() & QTextOption::ShowTabsAndSpaces)) {
- analysis->script = QUnicodeTables::Common;
- analysis->flags = QScriptAnalysis::Space;
- analysis->bidiLevel = control.baseLevel();
- } else {
- analysis->script = script;
+ break;
+ case 32: // Space
+ case QChar::Nbsp:
+ if (option.flags() & QTextOption::ShowTabsAndSpaces) {
+ analysis->script = QUnicodeTables::Common;
+ analysis->flags = QScriptAnalysis::Space;
+ analysis->bidiLevel = control.baseLevel();
+ break;
+ }
+ // fall through
+ default:
+ int script = QUnicodeTables::script(*uc);
+ analysis->script = script == QUnicodeTables::Inherited ? lastScript : script;
+ analysis->flags = QScriptAnalysis::None;
+ break;
}
lastScript = analysis->script;
++uc;
@@ -2082,7 +2087,8 @@ void QTextEngine::justify(const QScriptLine &line)
}
}
- QFixed need = line.width - line.textWidth;
+ QFixed leading = leadingSpaceWidth(line);
+ QFixed need = line.width - line.textWidth - leading;
if (need < 0) {
// line overflows already!
const_cast<QScriptLine &>(line).justified = true;
@@ -2426,7 +2432,7 @@ void QTextEngine::indexAdditionalFormats()
between the text that gets truncated and the ellipsis. This is important to get
correctly shaped results for arabic text.
*/
-static bool nextCharJoins(const QString &string, int pos)
+static inline bool nextCharJoins(const QString &string, int pos)
{
while (pos < string.length() && string.at(pos).category() == QChar::Mark_NonSpacing)
++pos;
@@ -2435,13 +2441,14 @@ static bool nextCharJoins(const QString &string, int pos)
return string.at(pos).joining() != QChar::OtherJoining;
}
-static bool prevCharJoins(const QString &string, int pos)
+static inline bool prevCharJoins(const QString &string, int pos)
{
while (pos > 0 && string.at(pos - 1).category() == QChar::Mark_NonSpacing)
--pos;
if (pos == 0)
return false;
- return (string.at(pos - 1).joining() == QChar::Dual || string.at(pos - 1).joining() == QChar::Center);
+ QChar::Joining joining = string.at(pos - 1).joining();
+ return (joining == QChar::Dual || joining == QChar::Center);
}
QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int flags) const
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 515915a..4fd6ddf 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1928,12 +1928,8 @@ found:
if (line.textWidth > 0 && item < eng->layoutData->items.size())
eng->maxWidth += lbh.spaceData.textWidth;
- // In the latter case, text are drawn with trailing spaces at the beginning
- // of a line, so the naturalTextWidth should contain the space width
- if ((eng->option.flags() & QTextOption::IncludeTrailingSpaces) ||
- (line.width == QFIXED_MAX && eng->isRightToLeft())) {
+ if (eng->option.flags() & QTextOption::IncludeTrailingSpaces)
line.textWidth += lbh.spaceData.textWidth;
- }
if (lbh.spaceData.length) {
line.length += lbh.spaceData.length;
line.hasTrailingSpaces = true;
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index b6cdc52..1cfacf7 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -106,14 +106,17 @@ unix:x11 {
!embedded:!qpa:!x11:mac {
HEADERS += \
text/qfontengine_mac_p.h
- OBJECTIVE_HEADERS += \
- text/qfontengine_coretext_p.h
SOURCES += \
text/qfont_mac.cpp \
text/qrawfont_mac.cpp
OBJECTIVE_SOURCES += \
- text/qfontengine_coretext.mm \
text/qfontengine_mac.mm
+}
+!embedded:!x11:mac {
+ OBJECTIVE_HEADERS += \
+ text/qfontengine_coretext_p.h
+ OBJECTIVE_SOURCES += \
+ text/qfontengine_coretext.mm
contains(QT_CONFIG, harfbuzz) {
DEFINES += QT_ENABLE_HARFBUZZ_FOR_MAC
}