summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
AgeCommit message (Collapse)Author
2023-12-31Replace "size() == 0 with empty()" (vcl)Julien Nabet
Change-Id: If93925fca6c0bb27ea5570d500e13b195b993f36 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161471 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2023-11-29Extended loplugin:ostr: vclStephan Bergmann
Change-Id: Ia9e958deec9716e38381a027451d5ee821efe23d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160095 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
2023-10-20Extended loplugin:ostr: Automatic rewrite O[U]StringLiteral: vclStephan Bergmann
Change-Id: Iaeacacbbb0eec907d884219aa2bcfe7a86f00a2c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158291 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-15Drop OStringConstExpr, use constexpr OString insteadStephan Bergmann
Change-Id: Ibb41a27fe7d5456d8db0c98821d5b2acf8586b70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157949 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-10-15pStringIds can be constexprStephan Bergmann
This array lacked being const[expr], presumably accidentally, ever since it got introduced in 2d1f08d63942666c0094904f50ba8c512ab69b9d "CWS-TOOLING: integrate CWS otf01". Change-Id: Ia8f8207ed5b0668356cafd284d4de595b5890cb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157948 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2023-07-31tdf#156230 remove now unused various bit and piecesNoel Grandin
Change-Id: I0ad88d402329bbc6882f53f6c20c22b97189a27f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155077 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
2023-07-30Drop freshly unused font subsetting codeKhaled Hosny
These output font formats were for PostScript that is now gone. Change-Id: Ib29f921fe25432aaa558ba842ee77fe1e8023d47 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155069 Reviewed-by: خالد حسني <khaled@libreoffice.org> Tested-by: خالد حسني <khaled@libreoffice.org>
2023-07-25tdf#156437: Fix missing name inside embedded Type 1 font in PDFKhaled Hosny
Regression from: commit 7415ce2b9795a78f836bc5e5bffb4b56eee26b21 Author: Khaled Hosny <khaled@aliftype.com> Date: Mon Dec 5 20:52:13 2022 +0200 tdf#113048: Fix PDF ascender and descender of some fonts We were setting the font in PDF /Font dictionary, but not inside the font itself. Change-Id: I1936f615f62fd7afa8f31d66d35dbded879328c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154880 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
2023-04-10Drop SvStream::WriteCharPtrMike Kaganski
WriteOString is a better replacement Change-Id: Ic431b9aeb98d19fe61cff71360eee555105cc2bf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150192 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2023-03-07clang-tidy dead-storeNoel Grandin
Change-Id: I40574713beaf1799cbc177a679e3485b4dc4eb1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148349 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2023-02-26cid#1521198 Untrusted loop boundCaolán McNamara
move sanity check inside CountTTCFonts so it applies to the fd smuggle in via filename mechanism Change-Id: Id2fee5801d71720747a8736859681e7c9a324bc3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147740 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-02-20cid#1521192 Argument cannot be negativeCaolán McNamara
Change-Id: Ifd1b8c3391ed3576dfa61311c8bd46d1b284771e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147349 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2023-02-09Enable opening of downloaded fonts only in ForKit in OnlineTor Lillqvist
We want that only the ForKit process needs to have access to new font files added to a Collabora Online instance dynamically by downloading from a server. There are however many locations in the Kit process, in core and in external libraries like harfbuzz, where the code wants to open a font file. Handle this so that the ForKit process opens such a downloaded font file and doesn't close it. The file descriptor is thus inherited by Kit processes. The font file pathname passed on to other code is a fake on in the format "/:FD:/%d" where the %d is the file descriptor of the opened font file. Add checks in all places where font files are opened, look for this special pathname format, and modify the code to just dup() the already open file descriptor in that case. All this is relevant for Linux only, as Collabora Online runs on Linux. Do the above for harfbuzz, cairo, fontconfig, and freetype. In addition make sure that these libraries (except harfbuzz which needs to be a static library and freetype) when bundled, on Linux, are built as shared libraries, and won't be confused with the corresponding system libraries by making sure their sonames are different. Change-Id: Ib059cb27e1637d07bb709249abd0d984f948caa9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140714 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146341 Tested-by: Jenkins
2022-12-06Shuffle code aroundKhaled Hosny
Change-Id: I3b3a88c91634fb19a39d21cdd0095d34badea1e0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143687 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-12-06Simplify PhysicalFontFace::CreateFontSubset() a bitKhaled Hosny
Hide the logic inside fontsubset and don’t leak it to the caller. Change-Id: Ibc845e0051eaeb64e8de42f80d4d404fd6a3880e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143686 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-12-06tdf#113048: Fix PDF ascender and descender of some fontsKhaled Hosny
Use the same ascender and descender calculation for fonts with CFF table as fonts without CFF table. This also provides a better fix for tdf#138325 and tdf#151039. Change-Id: I416a123199e94401fa557fce95013eb8b0590e33 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143683 Tested-by: خالد حسني <khaled@aliftype.com> Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-12-05Drop dummy functionKhaled Hosny
Type 1 support is long and this was always dead code anyway. Change-Id: Ia00626e7d44419af333feb59d4dc52e624ffd263 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143682 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-11-21be more specific on what "Symbol" isCaolán McNamara
Change-Id: Icd08628848cce74407552f57660d75b1ac9816bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143009 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-11-21vcl: GCC 12.2.1 -Werror=maybe-uninitializedMichael Stahl
Change-Id: I54ff61456682a312d5507aa6d740c0a72ea33ce1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142981 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
2022-11-21loplugin:unusedfields start removing unused weld fieldsNoel Grandin
Change-Id: If736ff669ffe24c3dd111c26285c19fc65806a3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142946 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-11-08Combine o3tl::RestoreGuard into comphelper::ValueRestorationGuardStephan Bergmann
Change-Id: Iec42b3bf348ba82a98d4ad8236a9e8b95fdfe5f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142422 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-08Address some of the sprintf in vcl/source/fontsubset/cff.cxxStephan Bergmann
...(which cause -Werror,-Wdeprecated-declarations with macOS 13 SDK), by turning Type1Emitter::maBuffer into an OStringBuffer Change-Id: I4207290c103f8aa99644d23d04a072f5241360bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142416 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-08Address some of the sprintf in vcl/source/fontsubset/cff.cxxStephan Bergmann
...(which cause -Werror,-Wdeprecated-declarations with macOS 13 SDK), by making CffSubsetterContext::getString, and in turn CffSubsetterContext::getGlyphName, return OString. Which in turn required adding rtl::OStringConstExpr and OString::unacquired counterparts of rtl/ustring.hxx functionality to rtl/string.hxx. (It's not quite clear to me whether the nMaxLen clipping in CffSubsetterContext::getString was only there to avoid overflow of the-- somewhat arbitrarily sized?---static aNameBuf, so could go now, or rather served as a more general safety measure to not read past the mpReadPtr buffer end and should thus remain. Hence, I added a TODO comment for now.) Change-Id: I473d5a54a4be5b02917e197391e4f0982dcf690c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142412 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-08Fix string comparisonsStephan Bergmann
As discussed in the comments at <https://gerrit.libreoffice.org/c/core/+/139908/4#message-cf9911a7e4464d53d8ef852ad0c03e609dd4ac88> "tdf#123234: Fix subsetting CFF deprecated endchar", this probably happened to work most of the time "because pGlyphName presumably /does/ point at elements of the pStringIds array (or the ".notdef" literal near the top of CffSubsetterContext:getGlyphName body), and compilers generally /do/ deduplicate string literals at least per TU." But at least the "sterling" literal in pStandardEncoding does not have a matching literal in pStringIds, so that could never have matched pGlyphName via ==. Change-Id: I7e82cf709f02d426da9c6097e596bbd92b5d4d04 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142405 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-08Introduce o3tl::RestoreGuardStephan Bergmann
Change-Id: Ic0c1a73668e990c91ef6e90e8c01e669761fe356 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142403 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-11-08CffSubsetterContext::getString never returns nullStephan Bergmann
Change-Id: I57e59b7659a9da2b291e8d6876617990f9e3a530 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142404 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-10-22loplugin:unusedmethodsNoel Grandin
Change-Id: I3c94d68cb85adc2005a5a5e3b03a311732f782c3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141617 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-10-15tdf#123234: Fix subsetting CFF deprecated endcharKhaled Hosny
Type 2 “endchar” operator can take 4 extra arguments and act like Type 1 “seac” operator. Although this is documented as deprecated, the fonts in the bug report use it. Detect the presence of the extra arguments and output a “seac” operator for them. Change-Id: Ic24ec8fda586c82612f0cc13f2f31585d40ad9c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139908 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-10-03vcl: Drop redundant checkKhaled Hosny
The code already does the same check above. Change-Id: Ia9a9bd743235f888af1bb8ff2bd7f16e9776619e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140898 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-10-03tdf#112152: Fix subsetting empty glyphsKhaled Hosny
When traversing the components of composite glyphs, the code was treating a component pointing to an empty glyph (e.g. space) as an error, but it is not. An overzealous bounds check. Regression from: commit 41007842ed9bb5d6165792a197769f72dae55a2c Author: Martin Hosken <martin_hosken@sil.org> Date: Thu Sep 10 10:14:18 2015 +0700 Refactor graphite integration and update graphite Change-Id: Ie352f17cb08cd5762ff2a339662248a536b4e934 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140897 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-10-01Unused constantsKhaled Hosny
Change-Id: Ic43a4e52b5ea40e54b368815e504840cb2c78aab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140845 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-10-01vcl: Move TrueTypeFace where it is usedKhaled Hosny
No need to make it module public. Easier to modify it. Change-Id: I119381d463c8f176b355fc7df111011ae518b49d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140821 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-09-30vcl: Apply variations to font metricsKhaled Hosny
Use HarfBuzz API instead of reading the raw font table directly, since HarfBuzz will apply the font variations as needed. For non-variable fonts we still also use HarfBuzz font metrics API, but in a more fine-grained way to maintain backward-compatibility. Change-Id: If6b12a11ecb63356be92ef4f0714355ae77378f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140799 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-09-29split utl::TempFile into fast and named variantsNoel Grandin
which makes it easier to know what each variant requires to stay on it's happy path Change-Id: I3275a2543573367714bc78092e882f6535507285 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140469 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-26crashtesting: don't assert on bogus font name in embedded ttfCaolán McNamara
seen with kde156448-1.pdf, fontforge also warns about the fontname. Looks like the name starts in little endian (wrong) before switching to big endian and/or is initially out by one. 䄀爀椀愀氀-BoldItalic should have been Arial-BoldItalic Change-Id: I4cd9f8bc6bc70d6e9a91c24801629ba140a3b675 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140614 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-09-25Some simplificationMike Kaganski
Change-Id: I7b455d1cb33bba2b3f2dfb3f469639519cd3076d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140552 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
2022-09-24use faster TempFile for font subset writingNoel Grandin
by not asking for the name or URL, we stay on the happy path, which is faster on Windows Change-Id: Ia333ab251fc0fc4129ad0610412c5c509914a58e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140453 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-24vcl: accept bitmap fonts in OpenTTFontFile()Khaled Hosny
We never subset such fonts after: commit 77cce80bb56801acf22da2149bd597d0d7793e3b Author: Khaled Hosny <khaled@aliftype.com> Date: Thu Sep 22 23:35:12 2022 +0200 vcl: tdf#121327 PDF export for bitmap color fonts But PrintFontManager::analyzeSfntFile() calls this function for non-subsetting uses, it probably shouldn’t since all info it should possibly need can come from FontConfig, but re-instate this for now. This check is very blunt and it would lead to empty fonts in PDF if we ever try to subset such a font, but lets clean this up later. Change-Id: I804d0244ee24a4b4e92b36efd26b376cbe40784d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140542 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-09-24simplify CmapSubTableNoel Grandin
use vector rather than handrolling it Change-Id: Ie160d5d60470e01434c61d80a2c7965e9126d508 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140540 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-24flattenTrueTypeTableGenericNoel Grandin
Change-Id: I197b2f45943513af7a514c92b5896bda659adf9d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140536 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-24flatten TrueTypeTablePostNoel Grandin
Change-Id: Ifafd87770732dd3f461dbb6823b92796331fa683 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140529 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-23remove some dead codeNoel Grandin
after commit 590796ca0866168e3129d2abd0a0197114cddcdc Author: Noel Grandin <noelgrandin@gmail.com> Date: Wed Sep 21 20:44:42 2022 +0200 convert TrueTypeTable to C++ class Change-Id: I5c656011ebe37529788cea6a749c07ada2378385 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140433 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-23vcl: tdf#121327 PDF export for bitmap color fontsKhaled Hosny
This change extracts the PNG data from the sbix/CBDT tables and embeds them as PDF Type 3 glyphs. In case the font supports both color layers and color bitmaps, the color layer take priority. This also reverts the part of the following commit that allowed bitmap fonts when creating font subsets because this is not needed now as the such fonts will now not reach the subsetting code. commit dcf7792da2aa2a1ef774a124f7b21f68fff0fd15 Author: Khaled Hosny <khaledhosny@eglug.org> Date: Tue Aug 27 15:19:15 2019 +0200 Make Noto Color Emoji font work on Linux Change-Id: I350ec97956f37ae574956b22712869fd6d1a6990 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140457 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
2022-09-23cid#1515535 Explicit null dereferencedCaolán McNamara
get length of glyf before std::move it Change-Id: If2d9a2cc533d65ef4b8e0481cf7db677bf5e4349 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140472 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
2022-09-23-Werror=class-memaccessStephan Bergmann
...since 590796ca0866168e3129d2abd0a0197114cddcdc "convert TrueTypeTable to C++ class" Change-Id: I9c1908ba0618f5a04bc669e722ea5ad54ae217b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140471 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2022-09-23cid#1515534 invalidate_iteratorJulien Nabet
Change-Id: Ib7763b2a7df858ad8749eca35d3e7518a39fad75 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140470 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2022-09-22convert TrueTypeTable to C++ classNoel Grandin
Change-Id: I06f01c79414380e37dc006cc7f7fdce1976035f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140357 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-21convert TrueTypeCreator to a C++ classNoel Grandin
Change-Id: I07cd2dfeb947f555b31bd0dccb91fb76f549c675 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140268 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-21use more unique_ptrNoel Grandin
Change-Id: I7836a1b1813d16db53ca0d6cc2b2ff2ae95e70cb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140267 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2022-09-21convert GlyphOffsets to a C++ classNoel Grandin
Change-Id: If693a5d0a94da666fd0361d45a3047890d9dec8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140265 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>