summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-141-1/+1
|\ | | | | | | | | | | | | Conflicts: src/gui/text/qfontengine_qpf2.cpp Change-Id: Ib04f92c41d0edd55d3aef8fb1708d917fba0f2a8
* | Merge remote-tracking branch 'origin/5.3' into devFrederik Gladhorn2014-07-011-6/+21
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/qnx-x86-qcc/qplatformdefs.h src/corelib/global/qglobal.h src/network/socket/qnativesocketengine_winrt.cpp src/plugins/platforms/android/androidjniaccessibility.cpp src/plugins/platforms/windows/qwindowswindow.cpp Manually adjusted: mkspecs/qnx-armle-v7-qcc/qplatformdefs.h to include 9ce697f2d54be6d94381c72af28dda79cbc027d4 Thanks goes to Sergio for the qnx mkspecs adjustments. Change-Id: I53b1fd6bc5bc884e5ee2c2b84975f58171a1cb8e
| * Fix crash when reusing HB_Face in another font engineKonstantin Ritt2014-06-181-6/+21
| | | | | | | | | | | | | | | | | | | | After 717d39ac083e80, if HB_Face was instantiated by QFontEngineFT A and then used by QFontEngineFT B, whilst A already destroyed, a crash occurs in hb_getSFntTable() due to accessing a stale pointer. Task-number: QTBUG-39278 Change-Id: I3428669a311f49cdda1725b778f45219cbcf470d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* | Ensure we don't re-use webfonts where the "local" font has been requestedKonstantin Ritt2014-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | For webfonts, we can't rely on the fontDef (and hence the cache Key) alone, since the resulting fontcache key might be strictly identical. Instead we have to check if the cached engine doesn't belong to a webfont when we're looking for a "local" font. Change-Id: I2de11c8fdbef53362b66674d3429a042e1835757 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
* | qpa: Clean up and refactor qfontengine_qpaTor Arne Vestbø2014-05-151-0/+115
|/ | | | | | | | | | | QFontEngineQPA was really QFontEngineQPF2, and has been renamed. The multi font engine in qfontengine_qpa.cpp was really a base implementation of a multi font engine, used by other multi font engines, and has been renamed and moved accordingly into qfontengine_p.h/cpp. Change-Id: Iac7409c4dbf0fdc3ee993ce4f7dc96cb00a422e6 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
* Add virtual function to QFontEngine report if outlines are reliableJørgen Lind2014-05-061-0/+9
| | | | | | | | | GetGlyphOutline fails for ttf fonts with embedded bitmaps. This results in distancefield rendering not rendering glyphs (for the failed paths). We need to fall back to texture rendering if this is the case. Change-Id: Ibdf7dc5c1d34f513c436f88fabbdcc4089bb6fef Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* [HB] Ensure we always working with non-multi font engineKonstantin Ritt2014-04-041-0/+5
| | | | | Change-Id: If88385d4cecdc527b7952d34e48f7ba889173c6c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use QStringIterator instead of homebrewKonstantin Ritt2014-03-101-6/+5
| | | | | | | Task-number: QTBUG-15664 Change-Id: I1ed3eb04ddd822e57a4d993af656dfe283f3af1a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Make QFontEngine::type() non-virtualKonstantin Ritt2014-03-051-17/+12
| | | | | Change-Id: I24ece90d6d8f96dad0c41a474a491b4ea96d97c3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Get rid of QFontEngine::name()Konstantin Ritt2014-03-051-6/+0
| | | | | | | | It was only used in QFontCache debug output, and some engines weren't even report a name. Change-Id: I6cec4b75f105f5a4e1405f50188bebb3a3f04e33 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Optimize QFontEngineMulti::stringToCMap() in case of missing glyphsKonstantin Ritt2014-03-051-15/+7
| | | | | | | | | Use recently introduced glyphIndex() method and only recalc advances if the glyph is present in the font. This allows to avoid restoring the old advance when the glyph was not found in the fallback fonts. Change-Id: I3e0aa549961767e5448816327328101cf6a78873 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Optimize glyph lookups with QFontEngine::glyphIndex(uint)Konstantin Ritt2014-03-051-61/+11
| | | | | | Change-Id: I56c7e727f3d9b08195f38939106620c744c6eaf0 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: BogDan Vatra <bogdan@kde.org>
* Disable 'gsub' table check for AAT fonts on MacKonstantin Ritt2014-03-041-0/+9
| | | | | | | In AAT fonts, 'gsub' table is effectively replaced by 'mort'/'morx' table. Change-Id: Ifa044c8e28c3f2aab0f57ba5e3e6b99ada84d37c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce a generic QFontEngine::canRender() implementationKonstantin Ritt2014-03-031-2/+13
| | | | | | | | ...which uses the recently introduced glyphIndex() method; get rid of re-implementations that did almost the same. Change-Id: I6d32d2cee6a31f57de6aee05ed8d120d4a1f4e9c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce QFontEngine::glyphIndex(uint)Konstantin Ritt2014-03-031-0/+35
| | | | | | | | | ...an optimized drop-in replacement for the code like this: `stringToCMap(&uc, 1, &g, &numGlyphs, QFontEngine::GlyphIndicesOnly)` (aka "get the glyph index for exactly one Unicode character"). Change-Id: I22babf49f7cf28892d27533a5ac51ad449779f75 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Unify QFontEngine*::stringToCMap() behaviorKonstantin Ritt2014-03-031-0/+1
| | | | | | | | Ensure the params are valid and make QCoreTextFontEngine::stringToCMap() handle the unsufficient buffer case exactly like the other engines does. Change-Id: I078af37da917cf2bac709b12aa827ed4128e5f30 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Unify QFontEngine::getSfntTableData() behavior on all platformsKonstantin Ritt2014-03-021-2/+19
| | | | | | | | | | | | Being a most significant method in the font API, getSfntTableData() must behave in exactly the same way on all platforms. Briefly, it must return true if the table exists in the font, despite the other params, and always stores the table data length in 'length' param, thus reporting the amount of bytes actually needed to store the table data in a buffer. Change-Id: I7a15465020c1ea818ea46a05ea3b9b7e1cd60d14 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Unify glyph format between QFontEngine and QFontEngineGlyphCacheTor Arne Vestbø2014-02-191-3/+26
| | | | | | | | | | | | Instead of the glyph cache having its own cache type that always mapped one to one to a font engine glyph format, causing confusion and needless conversions, the glyph caches now use QFontEngine's glyph format enum. This also removes the iffy use of an int for the glyphFormat in the font engines. Change-Id: I529bad5c179e004f63e152f7dcc311d298c3db98 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Merge "Merge remote-tracking branch 'origin/stable' into dev" into ↵Frederik Gladhorn2014-02-111-1/+12
|\ | | | | | | refs/staging/dev
| * Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-071-1/+12
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/gui/kernel/qguiapplication.cpp src/plugins/platforms/android/androidjnimain.cpp src/plugins/platforms/android/qandroidplatformintegration.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/android/qandroidplatformopenglcontext.cpp src/plugins/platforms/cocoa/qcocoawindow.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/sql/doc/src/sql-driver.qdoc src/widgets/widgets/qtoolbararealayout.cpp Change-Id: Ifd7e58760c3cb6bd8a7d1dd32ef83b7ec190d41e
| | * Fix crash due to a stale pointer dereferencingKonstantin Ritt2014-01-161-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HB face caching mechanism introduced in 227e9a40cfeb7e00658cd3 wasn't complete due that fact that HB-NG doesn't parse the entire font table at once but rather references a table on-demand. This incompleteness caused a crash in case the engine doesn't get cached or when it removed from the cache and then re-used. Task-number: QTBUG-36099 Change-Id: I7816836107655ce7cf6eb9683bb5dc7f892f9cd1 Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: Michael Krasnyk <michael.krasnyk@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
* | | QFontEngineBox: Fix assertion for code points beyond BMPKonstantin Ritt2014-02-091-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | ...due to a typo introduced in d8225fab8fb8b21fb5d and stricter checks introduced in 4e319ca4c47a99295c1. This uses recently added QStringIterator to decrease the code duplication. Change-Id: Ib1c2519db1c4d65f3ac14e6f9ae3fa272860b1dd Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | | Optimize stringToCMap() usageKonstantin Ritt2014-02-071-24/+47
|/ / | | | | | | | | | | | | | | | | | | | | | | CMAP guarantees there is 1:1 mapping between the Unicode code points array and the glyph indexes array, which means the QString length always greater than or equal to a sufficient glyph indexes array length. Simply add some asserts and improve the memory consumption and the performance where possible. Change-Id: I0bc8cdba5f86c1c0ba9e79c8d5f96cbe56ec463e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Fix character mirroring issue with HarfBuzz-NGKonstantin Ritt2014-02-041-6/+36
| | | | | | | | | | | | | | | | | | | | HarfBuzz-NG does character mirroring where appropriate. A simple solution is to unset RightToLeft shaper flag when text gets shaped with HB-NG. Instead, move the mirroring code right to HB-old proxy function and decrease code duplication. Change-Id: Icdcd50b73b3e6a43da4b85addc7d8f51edf86512 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | [QFontEngineBox] Fix incorrect advances for SMP code pointsKonstantin Ritt2014-01-301-4/+11
| | | | | | | | | | | | | | | | In UTF-16, SMP code point is encoded with a pair of surrogates, thus making SMP code point twice wider than BMP code point. Change-Id: Ifb0e78cff50cca7231d07097a730188bd98c54cb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Get rid of QGlyphLayout::advances_yKonstantin Ritt2014-01-301-58/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...and thus consume 4 bytes less per glyph and increase the performance a bit. It seems, the only CTFontGetAdvancesForGlyphs() returns both x and y advances, though y advances are always equal to 0 for horizontal orientation and x advances are always equal to 0 for vertical orientation. Also, rename `advances_x` to `advances` for consistency and declare QGlyphLayout's data size in a single place. Change-Id: I56b20f893f8a6feb7aa870e3edbca99dd93ba2e2 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Defer HarfBuzz face loading up until it gets usedKonstantin Ritt2014-01-241-2/+6
|/ | | | | | | | This didn't work for a loooong time already; not it is possible to re-introduce this optimization once again. Change-Id: I35c40e68933227bda6cbc038c2d8f6709db62451 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Revert "Store the font's scalability in QFontEngine."Yoann Lopes2013-11-271-2/+1
| | | | | | | | | | | | This reverts commit 65b12fbdb13d34c61bcadd5cc8fd6ee28a8dfafd. QFontEngine is not always loaded from QFontDatabase, resulting in the flag not being set. Change-Id: I39bc5bd4a8dea153d191cfc55f4324195f75f64c Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Store the font's scalability in QFontEngine.Yoann Lopes2013-10-311-1/+2
| | | | | | | | | This is an enabler to fallback to native font rendering when using a bitmap font in Qt Quick. Task-number: QTBUG-32737 Change-Id: I6d841dd5ef54d78a00f7fab9d80e9c95ff7f7b98 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Make it possible to clear glyph caches from the font engine.Gunnar Sletta2013-10-181-0/+10
| | | | | Change-Id: Iea62bc1727269ed3893d8b4dbcefa583f1b85d7f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* De-inline virtuals of some non-exported private classes in QtGuiThiago Macieira2013-09-231-0/+9
| | | | | | | | | | This is to work around a bug in GCC 4.7's link-time optimiser. Without it, linking QtOpenGL and QtPrintSupport fails because the compiler generates the code for the virtuals, including the virtual table, but not the methods. Change-Id: Idcecd51c32e6228e0eefe67f1bd630ea1f5d5da7 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Decrease code duplication in QFontDatabase-sKonstantin Ritt2013-09-131-0/+8
| | | | | | | | Move scriptRequiresOpenType() body right into QFontEngine::supportsScript(), thus centralizing use of this performance cheat. Change-Id: I5f494b086f8f900b631c491f41e9cb800002c0f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Implement QFontEngine::harfbuzzFont/Face() with HarfBuzz-NGKonstantin Ritt2013-09-131-2/+2
| | | | | Change-Id: I5d4fed66d66e8aa650fe181e61dcc2345f0f907a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Make QFontEngine not derive from QObjectKonstantin Ritt2013-09-101-1/+1
| | | | | | | | | | | | | Whilst having the objectName set for each engine is somewhat handy when debugging, deriving from QObject just for that is a wasting of memory in all other cases. This also broke the font engine abstraction by allowing qobject_cast() to access some private data; the only sane way to distinguish engines is querying their Type value. Change-Id: Ib1d195692859eb39089f6d8d9016cb8f9dcc0400 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add HarfBuzz-to-Qt bridging codeKonstantin Ritt2013-09-081-0/+37
| | | | | Change-Id: I2f61566fe69d18b80d5831238beb27b34b7be1c8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove deprecated QtAlgorithms calls from QtGuiGiuseppe D'Angelo2013-09-051-1/+3
| | | | | | | | QtAlgorithms is getting deprecated, see http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I324ddf6129fe8884ecea97ef47abb7c071dfb34c Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
* Get rid of HB dependency in FT font engineKonstantin Ritt2013-08-201-14/+10
| | | | | | | | | Instead of loading HB face in QFreetypeFace::getFace(), defer allocation until the first FT font engine for that face gets initialized; then, QFreetypeFace "reparents" and manages the loaded HB face. Change-Id: I2ac8ead4c6ed25d341af9c9cf0c34dfb979f8390 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix possible crash due to integer overflowKonstantin Ritt2013-08-151-1/+1
| | | | | | | | | | | | | QFontEngineMulti::stringToCMap() stores the fallback engine index in a glyph index'es high byte, which means the maximum fallback engine index it can store is 255, so limit the number of tries we're doing to this value. Otherwise we could end up with `fontEngineMulti->engine(glyph >> 24) == 0` after successful stringToCMap() call. Task-number: QTBUG-30412 Change-Id: I06907a39186fd207f3ce4b732a1a54e615744082 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Don't allocate QGlyphLayout data, when possibleKonstantin Ritt2013-08-141-30/+37
| | | | | | | | | | | | | | | ...and operate directly on a passed array pointers, without having to copy the input and output data. Calling QFontEngine:: stringToCMap()/recalcAdvances() with partially-constructed QGlyphLayout is completely safe iff `glyphs` and `advances_?` members were initialized. Also get rid of QGlyphLayoutInstance that was used just in a single place and never was really needed. Change-Id: I48fab246fd69fc869f948220a553c3574d93c772 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QFontEngine: Fix cache_cost might be not initializedKonstantin Ritt2013-04-141-0/+1
| | | | | | Change-Id: I4cf4de5797e6623a71593e8f382496188e3abac8 Reviewed-by: jian liang <jianliang79@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix integer overflow for very large fontsKonstantin Ritt2013-04-121-3/+7
| | | | | | | | This caused glitches up to unreadable text with i.e. pixelSize 256 and stretch factor 4x /* ((256*4)<<16)<<6 */. Change-Id: Ib6a038a043d820a94bd2019c50390a815a2a8277 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* Fix font stretching issueKonstantin Ritt2013-03-261-2/+2
| | | | | | | | We're treating fontDef.pixelSize as a box height everywhere but in harfbuzzFont initialization code the logic was opposite. Change-Id: I4eecf7861a6084c7f2dbe1df85a71f2e251da845 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix handling of 0x00AD code with symbol fonts (Win/QPA/QPF/fallback)Konstantin Ritt2013-03-261-0/+1
| | | | | | | | | ...by updating HB_Face::isSymbolFont value to make HB know that the font is a symbol font. U+00AD is a Unicode soft hyphen character, which shouldn't be threated like a default ignorable (invisible) when 0x00AD occurred in a symbol font. Change-Id: Idd4760aded644f7f11a1a8d3c03c348abc69a3e4 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Fix the font engines leakingKonstantin Ritt2013-03-201-6/+34
| | | | | | | | | | | | | | | 1. when there were some engines with ref > 1 in the cache, prior to calling QFontDatabase::{add,remove}ApplicationFont()/removeAllApplicationFonts() (QFontCache::clear() has never decreased engine's cache_count); 2. when the QFontEngineData's engine is not in cache i.e. the Box or Test font engine (~QFontEngineData() didn't free engines it keeps). Instead of using the font engine's (external) "cache_count" counter, QFontCache now references a given font engine every time it is inserted to the cache and dereferences exactly that number of times in clear(). Change-Id: I87677ebd24c1f4a81a53526f2e726e596b043c61 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Avoid using HB types in QFontEngine APIKonstantin Ritt2013-03-131-27/+47
| | | | | | | | | | | This affects HB_Font and HB_Face. As of now, the Hurfbuzz API usage is concentrated in qfontengine(|_ft).cpp and qtextengine.cpp, thus it is a lot easier to switch to Hurfbuzz-NG. Change-Id: Ie06959efd5d6080fe44c407d9f5de0a07dd1c210 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Josh Faust <jfaust@suitabletech.com>
* Replace HB types used in API with Qt analogsKonstantin Ritt2013-03-121-3/+3
| | | | | | | | | | hb_uint32 <-> quint32 HB_Glyph <-> glyph_t HB_Fixed <-> QFixed, HB_FixedPoint <-> QFixedPoint HB_GlyphAttributes <-> QGlyphAttributes Change-Id: I4338ec4ce9a9c20ea591606ab10e6ef4f19931b8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix selection of fonts that require OpenType featuresKonstantin Ritt2013-03-041-0/+5
| | | | | | | | HB_Face's supported_scripts[] expects HB_Script, so QChar::Script should be remapped via script_to_hbscript(). Change-Id: Ib068c35ab76567fe9a61da7d8ab01133a6f58bc0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add support for color glyphs (Emoji) on Mac OS X and iOSTor Arne Vestbø2013-02-131-0/+7
| | | | | | | | | | | | | A new glyph type is added to the glyph caches for ARGB bitmap glyphs, and the raster and OpenGL paint engines have been modified to support this glyph type for drawCachedGlyphs(). The CoreText font engine implements support for these glyphs through the CTFontDrawGlyphs API, since CGContextShowGlyphsWithAdvances does not handle color glyphs. Change-Id: Idad9ce75a911cae130d65aebe59142772a16fc12 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>