diff options
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 27 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase_qpa.cpp | 5 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 14 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.cpp | 10 | ||||
-rw-r--r-- | src/gui/text/qplatformfontdatabase.h | 3 | ||||
-rw-r--r-- | src/gui/text/text.pri | 2 |
6 files changed, 31 insertions, 30 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e87e6eb83b..5714645728 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -273,27 +273,15 @@ struct QtFontFoundry QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &styleName, bool create) { int pos = 0; - if (count) { - // if styleName for searching first if possible - if (!styleName.isEmpty()) { - for (; pos < count; pos++) { - if (styles[pos]->styleName == styleName) - return styles[pos]; - } - } - int low = 0; - int high = count; - pos = count / 2; - while (high > low) { + for (; pos < count; pos++) { + bool hasStyleName = !styleName.isEmpty(); // search styleName first if available + if (hasStyleName && !styles[pos]->styleName.isEmpty()) { + if (styles[pos]->styleName == styleName) + return styles[pos]; + } else { if (styles[pos]->key == key) return styles[pos]; - if (styles[pos]->key < key) - low = pos + 1; - else - high = pos; - pos = (high + low) / 2; } - pos = low; } if (!create) return 0; @@ -308,7 +296,6 @@ QtFontStyle *QtFontFoundry::style(const QtFontStyle::Key &key, const QString &st QtFontStyle *style = new QtFontStyle(key); style->styleName = styleName; - memmove(styles + pos + 1, styles + pos, (count-pos)*sizeof(QtFontStyle *)); styles[pos] = style; count++; return styles[pos]; @@ -594,7 +581,7 @@ QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create) if (res < 0) pos++; - // qDebug("adding family %s at %d total=%d", f.latin1(), pos, count); + // qDebug() << "adding family " << f.toLatin1() << " at " << pos << " total=" << count; if (!(count % 8)) { QtFontFamily **newFamilies = (QtFontFamily **) realloc(families, diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 366f995790..70a8af0b66 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -52,7 +52,8 @@ QT_BEGIN_NAMESPACE -Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &foundryname, int weight, +Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &stylename, + const QString &foundryname, int weight, QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *handle) @@ -75,7 +76,7 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &fou } QtFontFoundry *foundry = f->foundry(foundryname, true); - QtFontStyle *fontStyle = foundry->style(styleKey, QString(), true); + QtFontStyle *fontStyle = foundry->style(styleKey, stylename, true); fontStyle->smoothScalable = scalable; fontStyle->antialiased = antialiased; QtFontSize *size = fontStyle->pixelSize(pixelSize ? pixelSize : SMOOTH_SCALABLE, true); diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index b9a7e69c9d..aa9879882b 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -588,6 +588,16 @@ static void convertRGBToARGB_V(const uchar *src, uint *dst, int width, int heigh } } +static void convertGRAYToARGB(const uchar *src, uint *dst, int width, int height, int src_pitch) { + for (int y = 0; y < height; ++y) { + int readpos = (y * src_pitch); + int writepos = (y * width); + for (int x = 0; x < width; ++x) { + dst[writepos + x] = (0xFF << 24) + (src[readpos + x] << 16) + (src[readpos + x] << 8) + src[readpos + x]; + } + } +} + static void convoluteBitmap(const uchar *src, uchar *dst, int width, int height, int pitch) { // convolute the bitmap with a triangle filter to get rid of color fringes @@ -1016,7 +1026,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, bitmap.rows = info.height*vfactor; bitmap.width = hpixels; bitmap.pitch = format == Format_Mono ? (((info.width + 31) & ~31) >> 3) : ((bitmap.width + 3) & ~3); - if (!hsubpixel && vfactor == 1) + if (!hsubpixel && vfactor == 1 && format != Format_A32) bitmap.buffer = glyph_buffer; else bitmap.buffer = new uchar[bitmap.rows*bitmap.pitch]; @@ -1047,6 +1057,8 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, delete [] convoluted; } else if (vfactor != 1) { convertRGBToARGB_V(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch, subpixelType != QFontEngineFT::Subpixel_VRGB, true); + } else if (format == Format_A32 && bitmap.pixel_mode == FT_PIXEL_MODE_GRAY) { + convertGRAYToARGB(bitmap.buffer, (uint *)glyph_buffer, info.width, info.height, bitmap.pitch); } if (bitmap.buffer != glyph_buffer) diff --git a/src/gui/text/qplatformfontdatabase.cpp b/src/gui/text/qplatformfontdatabase.cpp index f3e573e313..903b1e4c3d 100644 --- a/src/gui/text/qplatformfontdatabase.cpp +++ b/src/gui/text/qplatformfontdatabase.cpp @@ -47,7 +47,8 @@ QT_BEGIN_NAMESPACE -extern void qt_registerFont(const QString &familyname, const QString &foundryname, int weight, +extern void qt_registerFont(const QString &familyname, const QString &stylename, + const QString &foundryname, int weight, QFont::Style style, int stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *hanlde); @@ -89,7 +90,7 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void * } } QFont::Stretch stretch = QFont::Unstretched; - registerFont(fontName,QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle); + registerFont(fontName,QString(),QString(),fontWeight,fontStyle,stretch,true,false,pixelSize,false,writingSystems,handle); } } else { qDebug() << "header verification of QPF2 font failed. maybe it is corrupt?"; @@ -117,7 +118,8 @@ void QPlatformFontDatabase::registerQPF2Font(const QByteArray &dataArray, void * \sa registerQPF2Font() */ -void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight, +void QPlatformFontDatabase::registerFont(const QString &familyname, const QString &stylename, + const QString &foundryname, QFont::Weight weight, QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *usrPtr) @@ -125,7 +127,7 @@ void QPlatformFontDatabase::registerFont(const QString &familyname, const QStrin if (scalable) pixelSize = 0; - qt_registerFont(familyname, foundryname, weight, style, + qt_registerFont(familyname, stylename, foundryname, weight, style, stretch, antialiased, scalable, pixelSize, fixedPitch, writingSystems, usrPtr); } diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h index fe7782be8f..7d9834fa37 100644 --- a/src/gui/text/qplatformfontdatabase.h +++ b/src/gui/text/qplatformfontdatabase.h @@ -116,7 +116,8 @@ public: //callback static void registerQPF2Font(const QByteArray &dataArray, void *handle); - static void registerFont(const QString &familyname, const QString &foundryname, QFont::Weight weight, + static void registerFont(const QString &familyname, const QString &stylename, + const QString &foundryname, QFont::Weight weight, QFont::Style style, QFont::Stretch stretch, bool antialiased, bool scalable, int pixelSize, bool fixedPitch, const QSupportedWritingSystems &writingSystems, void *handle); diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index face6f248f..436b7c7aec 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -85,5 +85,3 @@ SOURCES += \ HEADERS += \ text/qplatformfontdatabase.h - -INCLUDEPATH += ../3rdparty/harfbuzz/src |