diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-07-12 09:42:41 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-07-12 11:38:46 +0200 |
commit | a9f3c11375525a7708378dd3648febc40db1ad20 (patch) | |
tree | dc4182c07e2a53e0ef99462a47d773423ece180a /sw/qa | |
parent | f5685bdfff370be57cf37f1dc746026c6bfd6113 (diff) |
tdf#162002 DOCX import: ignore subsetted embedded fonts for editing
Open the bugdoc, some characters use a fallback font, some not, while
the same font is used in Word for all characters.
It turns out that the bugdoc has a subsetted embedded font, and the font
only has 8 glyphs, which explains the inconsistent rendering.
Fix the problem by ignoring subsetted fonts for the editing case: if a
font is subsetted then only use the embedded font for viewing. First
also had to fix up the tokenizer, as it had the wrong type for the
subsetted attribute, so we couldn't get its boolean value
(OOXMLStringValue doesn't override getInt(), so OOXMLValue::getInt()
returns 0 unconditionally).
Note that in theory we can have embedded fonts which are nominally
subsetted but in practice they have a "reasonable" amount of glyphs in
them, those are currently discarded, but should be probably still kept
in a follow-up change.
Change-Id: I3e6dfbb246d464fede64f183a3f244edc70e7b8a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170397
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/writerfilter/dmapper/FontTable.cxx | 44 | ||||
-rw-r--r-- | sw/qa/writerfilter/dmapper/data/subsetted-embedded-font.docx | bin | 0 -> 36987 bytes |
2 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/writerfilter/dmapper/FontTable.cxx b/sw/qa/writerfilter/dmapper/FontTable.cxx new file mode 100644 index 000000000000..798d68d0a193 --- /dev/null +++ b/sw/qa/writerfilter/dmapper/FontTable.cxx @@ -0,0 +1,44 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <test/unoapi_test.hxx> + +#include <vcl/embeddedfontshelper.hxx> + +using namespace com::sun::star; + +namespace +{ +/// Tests for sw/source/writerfilter/dmapper/FontTable.cxx. +class Test : public UnoApiTest +{ +public: + Test() + : UnoApiTest(u"/sw/qa/writerfilter/dmapper/data/"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testSubsettedEmbeddedFont) +{ + // Given a document with a subsetted embedded font, loaded for editing: + loadFromFile(u"subsetted-embedded-font.docx"); + + // When checking if the font is available: + OUString aUrl = EmbeddedFontsHelper::fontFileUrl( + u"IBM Plex Serif Light", FAMILY_ROMAN, ITALIC_NONE, WEIGHT_NORMAL, PITCH_VARIABLE, + EmbeddedFontsHelper::FontRights::ViewingAllowed); + + // Then make sure the subsetted font is not available, given that the newly inserted characters + // during editing may be missing from the subsetted font: + CPPUNIT_ASSERT(aUrl.isEmpty()); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/writerfilter/dmapper/data/subsetted-embedded-font.docx b/sw/qa/writerfilter/dmapper/data/subsetted-embedded-font.docx Binary files differnew file mode 100644 index 000000000000..85d97a1513ba --- /dev/null +++ b/sw/qa/writerfilter/dmapper/data/subsetted-embedded-font.docx |