summaryrefslogtreecommitdiff
path: root/vcl/inc/fontinstance.hxx
AgeCommit message (Collapse)Author
2019-11-24tdf#121740 cache font data to speed up PPT loadNoel Grandin
takes the load time from 24s to 21s for me. The cache was determined experimentally for this document. Change-Id: I34c78d1ff99cb8e72b274a201ded61d23e66941a Reviewed-on: https://gerrit.libreoffice.org/83470 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 90ea305110e5881256ba272800074a2a9f6b613d) Reviewed-on: https://gerrit.libreoffice.org/83542
2019-11-08tdf#121740 speed up font loadingNoel Grandin
by caching whether the font is a graphite font. Takes load time from 27s to 23s for me. Change-Id: I7b14a8bd305b27a088f363d19ebfb6fe774d3b02 Reviewed-on: https://gerrit.libreoffice.org/82267 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-09-22tdf#127325: Revert "Use HarfBuzz to get glyph bounding rectangle"Khaled Hosny
This reverts commit 502d73cda8fa1f482634bb6435fd1440757fdad9. Change-Id: Ib1a318e6d9a722f9ca056ba1df3a6f2ab19855e5 Reviewed-on: https://gerrit.libreoffice.org/79323 Tested-by: Jenkins Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2019-08-27Return empty HarfBuzz font instead of nullptrKhaled Hosny
hb_font_get_empty() returns an empty, singleton font object that can be safely passed to HarfBuzz API that would otherwise crash if given a nullptr. Keep the assert to catch calls to this code in debug builds, since it is really a bug for LogicalFontInstance implementations without a backed HarfBuzz font to call code that requires it. Change-Id: I93e2b3204eb08b0c4c54587bc0f60cbf3c18c7d7 Reviewed-on: https://gerrit.libreoffice.org/78178 Tested-by: Jenkins Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2019-08-25Use HarfBuzz to get glyph bounding rectangleKhaled Hosny
For consistent cross-platform results that also matches our glyph advances since platform functions might be using hints which we don’t use. Keep platform-specific implementations as fallback since HarfBuzz internal font functions (that we use) did not support glyph extents for fonts with CFF table before 2.3.0. Change-Id: I62c6c703ea37d41fd0998309dacadd56565a0fae Reviewed-on: https://gerrit.libreoffice.org/77870 Tested-by: Jenkins Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2019-06-16tdf#121486: Correct scale of broken fonts on WindowsKhaled Hosny
Some fonts have negative tmAveCharWidth which makes no sense (fonts can't have negative glyph width, so the average can't be negative) and it would cause our code to apply negative scale to the glyphs of these fonts making them drawn on the flipped horizontally. Fix this by using the absolute value so it is always positive. Change-Id: I731e7aad80dae734847679a1b08c6ac78111e16c Reviewed-on: https://gerrit.libreoffice.org/74109 Tested-by: Jenkins Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2019-06-13tdf#42949 Fix IWYU warnings in vcl/inc/*Gabor Kelemen
Platform-specific subdirs are left alone: android, ios, osx, quartz, win Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Icbb906b7fbc960240c73c56d3dae2a78b06a0f53 Reviewed-on: https://gerrit.libreoffice.org/73754 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2019-01-07tdf#42949 Fix IWYU warnings in include/vcl/[v-x]*Gabor Kelemen
Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I98f49765c6b74808dcbd692e0f375dd2848fcfd4 Reviewed-on: https://gerrit.libreoffice.org/65614 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
2018-11-15loplugin:staticmethods in vclNoel Grandin
Change-Id: I00333677db711761510a35dfae5ce70d61fb9491 Reviewed-on: https://gerrit.libreoffice.org/63397 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-30Move SalGraphics glyph functions into FontInstanceJan-Marek Glogowski
As we already rely on the GlyphItem's font instance, consequently this removes the SalGraphics GlyphItem based functions. Also unifies the glyph bound rect cache handling. An interesting aspect is the rotated glyph bounding box handling moved from CairoTextRender to FreetypeFont. It doesn't look like an implementation detail for Cairo, so it may have been a bug. Change-Id: I81bbb5d8ee98fb77a1eee05568c456f9e4553023 Reviewed-on: https://gerrit.libreoffice.org/62503 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-30Rely on the font instance of the glyphJan-Marek Glogowski
The FreetypeFont might already have released the font instance of the glyph, but the glyphs font instance must still be valid, so use this instead to cache glyph bound rect. For whatever reason the Windows compiler doesn't accept inline functions in the GlyphItem struct and wants to export them in the DLL, even when declared VCL_DLLPRIVATE, so this just uses static inlines as a workaround. Change-Id: I4539d91a846a54a05f9648638494e1e99f704b0a Reviewed-on: https://gerrit.libreoffice.org/62425 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-25Move GlyphItem into its own headerJan-Marek Glogowski
Actually GlyphItem should be VCL internal, but this requires a transparent SalLayoutGlyphs (i.e. via pImpl), which I'm too lazy to implement currently. This seperation makes the affected source files more obvious and later migration of vcl/glyphitem.hxx easier. While at it apply the coding style and add '_' to member prefix. Change-Id: I61497af5c628c40f51597ce0ef286c47321acbc2 Reviewed-on: https://gerrit.libreoffice.org/62358 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-10-25loplugin:unusedmethodsNoel Grandin
Change-Id: I1f9ac5f8a090f365d9a21486029e1c13d721a4a4 Reviewed-on: https://gerrit.libreoffice.org/62338 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-10-06Add a glyph-bound-rect cache to the font cacheJan-Marek Glogowski
This way the font cache can correctly invalidate the cached glyph rects when a font is dropped from the cache. Change-Id: I050866099742334f01cac1b872228a017ddb5e9b Reviewed-on: https://gerrit.libreoffice.org/61371 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2018-08-22rename FontSelectPatternAttributes to FontSelectPatternCaolán McNamara
Change-Id: I2c018e2e61707c0d89178b0cb38a0918906e23cb Reviewed-on: https://gerrit.libreoffice.org/59390 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-08-22turn the cache around to work on LogicalFontInstanceCaolán McNamara
instead of a FontSelectPattern with an associated LogicalFontInstance use a LogicalFontInstance with owned FontSelectPatternAttributes Change-Id: I939f84731fcb8db5ff6484dcfbd2f9199bb50d23 Reviewed-on: https://gerrit.libreoffice.org/59388 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-08-21use LogicalFontInstance with SalGraphicsCaolán McNamara
Change-Id: I66fb1ff4b2fdcc211e0a9d5831f6dcc5e564e789 Reviewed-on: https://gerrit.libreoffice.org/59372 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2018-06-08hold LogicalFontInstance with rtl::ReferenceNoel Grandin
instead of manual reference counting. Also the releasing of not-currently-in-use LogicalFontInstance objects from the cache is made less aggressive - we now only flush entries until we have less than CACHE_SIZE instances, instead of flushing the whole cache. Change-Id: Ib235b132776b5f09ae8ae93a933c2eebe5fa9610 Reviewed-on: https://gerrit.libreoffice.org/55384 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-07manage PhysicalFontFace by rtl::ReferenceNoel Grandin
Change-Id: I8f66b5afb066fe83abb83c56ebde6f21197f894b Reviewed-on: https://gerrit.libreoffice.org/55333 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-05-12Use HarfBuzz to get Kashida widthKhaled Hosny
One less platform-specific piece of code. Change-Id: Ib04c5f1434046e26ead2aaedace67127a5513e55 Reviewed-on: https://gerrit.libreoffice.org/54098 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2018-05-08Refactor CommonSalLayout font handlingJan-Marek Glogowski
Moves all platform specific code from CommonSalLayout into the platform specific plugins. This way the vcl library won't depend on the Qt5 libraries and the Qt5Font header can be moved into the qt5 VCL plugin. While at it, switch the CommonSalLayouts font reference from the FontSelectPattern to the LogicalFontInstance and also add the harfbuzz font handling to the instance. Change-Id: Ida910b8d88837ea949a2f84394ccc0cfae153060 Reviewed-on: https://gerrit.libreoffice.org/47408 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2018-05-07Move PhysicalFontFace member of FontSelectPatternJan-Marek Glogowski
A FontSelectPattern describes a general font request. It can be used to find the best matching LogicalFontInstance. The instance will be created based on a PhysicalFontFace, which is really a factory since commit 8b700794b2746070814e9ff416ecd7bbb1c902e7. Following this workflow, this moves the PhysicalFontFace pointer to the instance and makes it constant. Which leaves some special symbol font handling code in the hash and instance lookup code path. It used to query the font face directly from the instance. I'm not sure of the correct handling. The related commits where made to fix #i89002#, which has an attached test document. 1. commit 849f618270da313f9339dda29a9f35938434c91d 2. commit 8c9823d311fdf8092cc75873e4565325d204a658 The document is as broken as it was before the patch. The symbol substitution still works, but the 'Q's are missing when displaying a symbol font. I also don't understand all the reinterpret_casts for fake font ids. I guess this was used to prevent the crashes I see, where a PhysicalFontFace referenced in a valid LogicalFontInstance is freed and a later FontId check in the GlyphCache crashes. So this now checks for a valid cache instead. Change-Id: If8ee5a6288e66cfa4c419289fbdd5b5da128c6ea Reviewed-on: https://gerrit.libreoffice.org/47279 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
2018-01-17loplugin:useuniqueptr in LogicalFontInstanceNoel Grandin
Change-Id: Id0ba44d9080294576dbafc47e68dff41a8257d29
2017-12-28Try to handle fonts orphaned from cache gracefullyMike Kaganski
ImplFontCache::Invalidate deletes unused entries (with zero ref count), and keeps other entries, but clears everything (including still used fonts) from its instance list. In the same time, those fonts' mpFontCache pointers kept pointing to this cache object. External clients released font instance by calling its cache's Release method; this itself allows for broken invariants that cache's mnRef0Count is equal to number of unused font instances in its list. Also, those fonts never got released, leaking because ImplFontCache only ever deletes objects in its list. What is worse, sometimes font caches get deleted after invalidation (see OutputDevice::ImplClearFontData). As the instance list of the cache is empty at the point of delete, the cache destructor doesn't delete those fonts that were orphaned at the moment of invalidation (those fonts are still used by some client objects, so deleting them is clearly wrong). But since the font instances still have cache pointer referring the already deleted cache, releasing the instances (by calling deleted cache's Release member function) must lead do some weird results. This patch moves the Acquire/Release to LogicalFontInstance, which now checks if its cache pointer is valid, and if it is, the cache is used to do the work (as before); otherwise, the font handles its lifetime itself, and deletes itself when its reference counter is zero. The cache invalidation clears the cache pointer of the still-used instances. Change-Id: I29811272dda814cbc81f14668d63e385ce772332 Reviewed-on: https://gerrit.libreoffice.org/47111 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
2017-12-15Protect all LogicalFontInstance constructorsJan-Marek Glogowski
This way LogicalFontInstance can just be constructed by a PhysicalFontFace based factory. The patch also drops the wrong "Java logical font" comment added by commit 125cdf3404e60cf78f2a5547e9a06ce994df5c8e. Change-Id: Ibd5d7da0c3a65dbfa2c8ae6b05cf616d39b749f2 Reviewed-on: https://gerrit.libreoffice.org/46475 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
2016-09-02boost::intrusive_ptr->tools::SvRefCaolán McNamara
Change-Id: I4c913dc62efe3f3747e78670f4efb0216d95c4ad Reviewed-on: https://gerrit.libreoffice.org/28585 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2016-05-11remove unused return type from SalGraphics::SetFontNoel Grandin
Change-Id: I0ca41130f5e1028a70f1242f7af3366b7c57c572 Reviewed-on: https://gerrit.libreoffice.org/24833 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-01-29vcl: changes to included vcl headersChris Sherlock
Changes made to allow for harmonization of vcl/inc/impfont.hxx and vcl/inc/fontattributes: - comment added showing the similarities between impfont.hxx and fontattributes.hxx (made in fontattributes.hxx) - extra line space added for my own convinience as I tend to switch between tabs listing vcl/inc/impfont.hxx and vcl/inc/fontattributes.hxx in OpenGrok because that's how I roll - fontattributes.hxx doesn't need rtl/textenc.hxx, that's already included in rtl/ustring.hxx, so swapped to use this instead - fontattibutes.hxx now includes i18nlangtag/languagetag.hxx - this will be needed when I add the LanguageTag properties that exist in impfont.hxx - unotools/fontdefs.hxx added to: + vcl/source/font/PhysicalFontCollection.cxx + vcl/source/font/PhysicalFontFamily.cxx + vcl/source/font/PhysicalFontFace.cxx + vcl/source/font/font.cxx These are the only specific files that actually need this include. Thus this has been removed as an included header from fontattributes.hxx - vcl/inc/fontinstance.hxx doesn't need the reference counter to be a sal_uLong, a sal_uInt32 will suffice (if we need more references than that then I suggest there is a problem somewhere in the code!) - rearranged vcl/source/font/font.cxx's included headers Change-Id: I8d61a5c05989356c056b962adc5aa670940addd2
2016-01-27vcl: fix header guards for fontinstance.hxxChris Sherlock
Change-Id: I1f81ea50802f9c17f7af58db09a86cf2b680d4c6
2016-01-14vcl: change ImplFontMetricData to be reference counted via intrusive_ptrChris Sherlock
Change-Id: Ie9f5fbd21a6223520cbea3af6436beb407d7a88c Reviewed-on: https://gerrit.libreoffice.org/21477 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-01-14vcl: cleanup fontinstance.hxx - remove unneeded fwd decls and includesChris Sherlock
Change-Id: I2425451a6a0378025b047f9125abb53aa414f238
2016-01-14vcl: move ImplFontCache into own private headerChris Sherlock
Change-Id: Ic4444f54fabe03319de9add93653f6b7c91d6fce
2016-01-12vcl: resplit FontAttributes from ImplFontMetricDataChris Sherlock
The change I made in commit 7b974e056df3 ("vcl: merge ImplFontMetricData with ImplFontAttributes") was... ill-advised. For starters, there really needs to be this split as FontSelectPattern needs it, and PhysicalFontFace only requires the font attributes, not the metric data. So the merge was unfortunately, in my mind, a failure and I'm manually backing it out now. Change-Id: Iac38f0815f984541e2f55099c965376dd88eeb43 Reviewed-on: https://gerrit.libreoffice.org/21380 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-01-10vcl: promote ImplFontAttributes to FontAttributesChris Sherlock
ImplFontAttributes is no longer merely a pImpl (or "compilation firewall", take your pick) but is a fully fledged class in its own right that is used by a number of classes, including FontSelectPattern, LogicalFontInstance and PhysicalFontFace. Thus I'm "promoting" the use of this class in the codebase. Change-Id: I26866080a64796978d1c25efbcd16e3e6f94aaa5 Reviewed-on: https://gerrit.libreoffice.org/21305 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2016-01-09vcl: rename m_pFontCache to mpFontCache in LogicalFontInstanceChris Sherlock
This is the only variable in LogicalFontInstance with m_ as the prefix, so changing to mpFontCache for consistency. Also small tab cleanup in fontmanager.hxx Change-Id: Id79392337795259568fbe71efb5200f1e31219a8
2016-01-08vcl: change ImplFontEntry to LogicalFontInstanceChris Sherlock
There is a TODO in the code that suggests to do this, when I looked at the collaboration diagram on Doxygen things made a LOT more sense. Change-Id: If335498bb70872ffa5738cc5c17660faec84c35e Reviewed-on: https://gerrit.libreoffice.org/21257 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>