README                           |    3 
 configure.ac                     |   40 ++
 libcdr.pc.in                     |    2 
 src/conv/raw/Makefile.am         |    2 
 src/conv/svg/Makefile.am         |    2 
 src/conv/text/Makefile.am        |    2 
 src/lib/CDRCollector.cpp         |    2 
 src/lib/CDRCollector.h           |    8 
 src/lib/CDRContentCollector.cpp  |  487 +++++++++++++++++++++++++++++---
 src/lib/CDRContentCollector.h    |    7 
 src/lib/CDRDocumentStructure.h   |    3 
 src/lib/CDROutputElementList.cpp |    8 
 src/lib/CDROutputElementList.h   |    1 
 src/lib/CDRParser.cpp            |  580 ++++++++++++++++++++++++++++++++++-----
 src/lib/CDRParser.h              |   12 
 src/lib/CDRPath.cpp              |   14 
 src/lib/CDRStylesCollector.cpp   |  131 +++++++-
 src/lib/CDRStylesCollector.h     |    5 
 src/lib/CDRTypes.h               |   49 ++-
 src/lib/CMXParser.cpp            |    4 
 src/lib/Makefile.am              |    6 
 src/lib/libcdr_utils.cpp         |  272 ++++++++++++++++++
 src/test/CDRTextEncodingTest.cpp |   59 +++
 src/test/Makefile.am             |    6 
 24 files changed, 1540 insertions(+), 165 deletions(-)

New commits:
commit b5cc100a456f45adf7bf6127ffb9bd60255a21aa
Author:     Fridrich Strba <[email protected]>
AuthorDate: Wed Nov 4 13:52:52 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:54:56 2026 +0100

    --without-icu: windows-1252 punctuation not taken for Mac text
    
    Mac Central European's Ö í ó (0x85 0x92 0x97) are windows-1252's
    … ’ —, so English text with an apostrophe came out "donít". Only
    0x83 0x86 0x87 0x8e 0x9a 0x9c 0x9f (rare in 1252) count as Mac;
    1252's ‘ ” – (Mac's Ď Ē Ė, not Hungarian) rule it out.
    
    Change-Id: I611f12a82e9837d2a8f645a8b968a61b79638042

diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index ca7ff91..97442cb 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -205,7 +205,8 @@ static unsigned short getEncoding(const unsigned char 
*buffer, unsigned long buf
 
 // Text from CorelDRAW for Mac (charset 0, Mac Central European code page): 
its Hungarian
 // letters lie in 0x80..0x9f (á 0x87, é 0x8e, ö 0x9a...), where Windows code 
pages have only
-// punctuation; text with Windows Hungarian letters stays Windows text
+// punctuation; text with Windows Hungarian letters stays Windows text. Mac's 
Ö í ó (0x85 0x92
+// 0x97) are windows-1252's common … ’ — ("don’t" came out "donít"): no 
evidence either way
 static bool isMacText(const unsigned char *buffer, unsigned long bufferLength)
 {
   bool mac = false;
@@ -213,9 +214,10 @@ static bool isMacText(const unsigned char *buffer, 
unsigned long bufferLength)
   {
     switch (buffer[i])
     {
-    case 0x83: case 0x85: case 0x86: case 0x87: case 0x8e: case 0x92: case 
0x97: case 0x9a: case 0x9c: case 0x9f:
+    case 0x83: case 0x86: case 0x87: case 0x8e: case 0x9a: case 0x9c: case 
0x9f:   // 1252: rare ƒ † ‡ Ž š œ Ÿ
       mac = true;
       break;
+    case 0x91: case 0x94: case 0x96:   // 1252's ‘ ” –; Mac's Ď Ē Ė, not 
Hungarian
     case 0xc1: case 0xc9: case 0xcd: case 0xd3: case 0xd5: case 0xd6: case 
0xda: case 0xdb: case 0xdc:
     case 0xe1: case 0xe9: case 0xed: case 0xf3: case 0xf6: case 0xfa: case 
0xfb: case 0xfc:
       return false;
diff --git a/src/test/CDRTextEncodingTest.cpp b/src/test/CDRTextEncodingTest.cpp
new file mode 100644
index 0000000..b962b43
--- /dev/null
+++ b/src/test/CDRTextEncodingTest.cpp
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * This file is part of the libcdr 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/.
+ */
+
+// The code page guess of text without a charset; ICU's detector guesses 
differently
+#ifndef WITH_ICU
+
+#include <cstring>
+#include <string>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "libcdr_utils.h"
+
+namespace test
+{
+
+class CDRTextEncodingTest : public CPPUNIT_NS::TestFixture
+{
+private:
+  CPPUNIT_TEST_SUITE(CDRTextEncodingTest);
+  CPPUNIT_TEST(testMacCentralEurope);
+  CPPUNIT_TEST_SUITE_END();
+
+  void testMacCentralEurope();
+};
+
+static std::string convert(const char *bytes)
+{
+  librevenge::RVNGString text;
+  libcdr::appendCharacters(text, std::vector<unsigned char>(bytes, bytes + 
strlen(bytes)), 0);
+  return text.cstr();
+}
+
+void CDRTextEncodingTest::testMacCentralEurope()
+{
+  // windows-1252 punctuation that is Mac Central European letters
+  CPPUNIT_ASSERT_EQUAL(std::string("don’t"), convert("don\x92t"));
+  CPPUNIT_ASSERT_EQUAL(std::string("Wait… it’s — done"), convert("Wait\x85 
it\x92s \x97 done"));
+  CPPUNIT_ASSERT_EQUAL(std::string("“Hi” – it’s š‡"), convert("\x93Hi\x94 \x96 
it\x92s \x9a\x87"));
+  CPPUNIT_ASSERT_EQUAL(std::string("café"), convert("caf\xe9"));
+  // CorelDRAW for Mac text
+  CPPUNIT_ASSERT_EQUAL(std::string("árvíztükör fúrógép"), 
convert("\x87rv\x92zt\x9fk\x9ar f\x9cr\x97g\x8ep"));
+  CPPUNIT_ASSERT_EQUAL(std::string("Éní"), convert("\x83n\x92"));
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(CDRTextEncodingTest);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=2 softtabstop=2 expandtab: */
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index a55bd92..20a9472 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -14,6 +14,10 @@ AM_CXXFLAGS = \
        $(BOOST_CFLAGS) \
        $(DEBUG_CXXFLAGS)
 
+if WITH_ICU
+AM_CXXFLAGS += -DWITH_ICU
+endif
+
 test_LDFLAGS = -L$(top_srcdir)/src/lib
 test_LDADD = \
        $(top_builddir)/src/lib/libcdr-internal.la \
@@ -27,6 +31,7 @@ test_LDADD = \
 
 test_SOURCES = \
        CDRInternalStreamTest.cpp \
+       CDRTextEncodingTest.cpp \
        test.cpp
 
 TESTS = $(target_test)
commit ab6f4faea1bb113195f204f3b630b70dd937c749
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 13:42:18 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:54:56 2026 +0100

    add --without-icu: text through iconv instead of ICU
    
    ICU (about 33 MB of data) only converts code pages and UTF-16 here.
    Without it: iconv (MultiByteToWideChar on Windows), UTF-16 decoded
    by hand. No charset detector: text without a charset is windows-1250
    when it has Hungarian o/u with double acute, else windows-1252.
    Default stays ICU, its code unchanged.
    
    Change-Id: I19ca481aaebbeeadad85e18b2de4525ea31a51ff

diff --git a/README b/README
index 955bd11..c9e07f3 100644
--- a/README
+++ b/README
@@ -6,7 +6,8 @@ Most up to date code is available from Git repository at 
libreoffice.org
 freedesktop.org (http://cgit.freedesktop.org/libreoffice/libcdr/). See
 https://wiki.documentfoundation.org/DLP/Libraries/libcdr for more information.
 
-libcdr requires boost, icu, lcms2, librevenge and zlib to build.
+libcdr requires boost, icu, lcms2, librevenge and zlib to build; with
+--without-icu, iconv instead of icu (none on Windows).
 
 The library is available under MPL 2.0.
 
diff --git a/configure.ac b/configure.ac
index e248c8e..e47b93e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,15 +95,42 @@ PKG_CHECK_MODULES([ZLIB],[zlib])
 AC_SUBST(ZLIB_CFLAGS)
 AC_SUBST(ZLIB_LIBS)
 
-# ========
-# Find icu
-# ========
-PKG_CHECK_MODULES([ICU], [icu-i18n >= 75 icu-uc >= 75],
-       [AX_CXX_COMPILE_STDCXX_17],
-       [PKG_CHECK_MODULES([ICU], [icu-i18n])]
+# ==================
+# Find icu (or iconv)
+# ==================
+AC_ARG_WITH([icu],
+       [AS_HELP_STRING([--without-icu], [Convert text with iconv 
(MultiByteToWideChar on Windows) instead of ICU; no charset detection])],
+       [with_icu="$withval"],
+       [with_icu=yes]
 )
+ICU_REQUIRES=
+ICONV_LIBS=
+AS_IF([test "x$with_icu" != "xno"], [
+       PKG_CHECK_MODULES([ICU], [icu-i18n >= 75 icu-uc >= 75],
+               [AX_CXX_COMPILE_STDCXX_17],
+               [PKG_CHECK_MODULES([ICU], [icu-i18n])]
+       )
+       ICU_REQUIRES=icu-i18n
+], [
+       # glibc has iconv in libc; elsewhere -liconv; Windows uses 
MultiByteToWideChar
+       AS_CASE([$host_os], [mingw*|cygwin*|msys*], [], [
+               AC_MSG_CHECKING([for iconv])
+               AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], 
[[iconv_close(iconv_open("UTF-8", "CP1250"));]])],
+                       [AC_MSG_RESULT([yes])],
+                       [save_LIBS="$LIBS"
+                       LIBS="$LIBS -liconv"
+                       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], 
[[iconv_close(iconv_open("UTF-8", "CP1250"));]])],
+                               [AC_MSG_RESULT([-liconv])
+                               ICONV_LIBS=-liconv],
+                               [AC_MSG_ERROR([iconv not found])])
+                       LIBS="$save_LIBS"])
+       ])
+])
+AM_CONDITIONAL([WITH_ICU], [test "x$with_icu" != "xno"])
 AC_SUBST(ICU_CFLAGS)
 AC_SUBST(ICU_LIBS)
+AC_SUBST(ICU_REQUIRES)
+AC_SUBST(ICONV_LIBS)
 
 
 # ===========================
@@ -363,6 +390,7 @@ Build configuration:
        debug:           ${enable_debug}
        docs:            ${build_docs}
        fuzzers:         ${enable_fuzzers}
+       icu:             ${with_icu}
        tests:           ${enable_tests}
        tools:           ${enable_tools}
        werror:          ${enable_werror}
diff --git a/libcdr.pc.in b/libcdr.pc.in
index a1aa43d..3fbb365 100644
--- a/libcdr.pc.in
+++ b/libcdr.pc.in
@@ -10,4 +10,4 @@ Requires: librevenge-0.0
 Libs: -L${libdir} -lcdr-@CDR_MAJOR_VERSION@.@CDR_MINOR_VERSION@
 Cflags: -I${includedir}/libcdr-@CDR_MAJOR_VERSION@.@CDR_MINOR_VERSION@
 
-Requires.private: icu-i18n lcms2 zlib
+Requires.private: @ICU_REQUIRES@ lcms2 zlib
diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am
index 7fd9bd2..df4b948 100644
--- a/src/conv/raw/Makefile.am
+++ b/src/conv/raw/Makefile.am
@@ -14,6 +14,7 @@ cdr2raw_DEPENDENCIES = @CDR2RAW_WIN32_RESOURCE@
 cdr2raw_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_GENERATORS_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
@@ -27,6 +28,7 @@ cmx2raw_DEPENDENCIES = @CMX2RAW_WIN32_RESOURCE@
 cmx2raw_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_GENERATORS_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am
index 57ad634..89efdbb 100644
--- a/src/conv/svg/Makefile.am
+++ b/src/conv/svg/Makefile.am
@@ -13,6 +13,7 @@ cdr2xhtml_DEPENDENCIES = @CDR2XHTML_WIN32_RESOURCE@
 cdr2xhtml_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
        @CDR2XHTML_WIN32_RESOURCE@ 
@@ -25,6 +26,7 @@ cmx2xhtml_DEPENDENCIES = @CMX2XHTML_WIN32_RESOURCE@
 cmx2xhtml_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_GENERATORS_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
diff --git a/src/conv/text/Makefile.am b/src/conv/text/Makefile.am
index 5618cdc..c15317e 100644
--- a/src/conv/text/Makefile.am
+++ b/src/conv/text/Makefile.am
@@ -14,6 +14,7 @@ cdr2text_DEPENDENCIES = @CDR2TEXT_WIN32_RESOURCE@
 cdr2text_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_GENERATORS_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
@@ -27,6 +28,7 @@ cmx2text_DEPENDENCIES = @CMX2TEXT_WIN32_RESOURCE@
 cmx2text_LDADD = \
        ../../lib/libcdr-@CDR_MAJOR_VERSION@.@[email protected] \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(REVENGE_GENERATORS_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 271e920..082d720 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -21,7 +21,11 @@ if HAVE_VISIBILITY
 AM_CXXFLAGS += -fvisibility=hidden -DLIBCDR_VISIBILITY
 endif
 
-libcdr_@CDR_MAJOR_VERSION@_@CDR_MINOR_VERSION@_la_LIBADD  = libcdr-internal.la 
$(REVENGE_LIBS) $(LCMS2_LIBS) $(ZLIB_LIBS) $(ICU_LIBS) @LIBCDR_WIN32_RESOURCE@
+if WITH_ICU
+AM_CXXFLAGS += -DWITH_ICU
+endif
+
+libcdr_@CDR_MAJOR_VERSION@_@CDR_MINOR_VERSION@_la_LIBADD  = libcdr-internal.la 
$(REVENGE_LIBS) $(LCMS2_LIBS) $(ZLIB_LIBS) $(ICU_LIBS) $(ICONV_LIBS) 
@LIBCDR_WIN32_RESOURCE@
 libcdr_@CDR_MAJOR_VERSION@_@CDR_MINOR_VERSION@_la_DEPENDENCIES = 
libcdr-internal.la @LIBCDR_WIN32_RESOURCE@
 libcdr_@CDR_MAJOR_VERSION@_@CDR_MINOR_VERSION@_la_LDFLAGS = $(version_info) 
-export-dynamic -no-undefined
 libcdr_@CDR_MAJOR_VERSION@_@CDR_MINOR_VERSION@_la_SOURCES = \
diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp
index e88bda9..ca7ff91 100644
--- a/src/lib/libcdr_utils.cpp
+++ b/src/lib/libcdr_utils.cpp
@@ -14,10 +14,22 @@
 #include <cstdio>
 #include <string.h>
 
+#ifdef WITH_ICU
 #include <unicode/ucsdet.h>
 #include <unicode/ucnv.h>
 #include <unicode/utypes.h>
 #include <unicode/utf8.h>
+#else
+#include <cerrno>
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <windows.h>   // MultiByteToWideChar: Windows has no iconv
+#include <cstdlib>
+#else
+#include <iconv.h>
+#endif
+#endif
 
 #define CDR_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
 
@@ -26,6 +38,8 @@
 namespace
 {
 
+#ifdef WITH_ICU
+
 static unsigned short getEncodingFromICUName(const char *name)
 {
   // ANSI
@@ -158,6 +172,177 @@ static void _appendUCS4(librevenge::RVNGString &text, 
UChar32 ucs4Character)
   text.append((char *)outbuf);
 }
 
+#else // WITH_ICU
+
+// No charset given (or ANSI / DEFAULT, which old Hungarian files also use for 
Central European
+// text): without ICU's charset detector, windows-1250 when the text has its 
o/u with double
+// acute (0xd5 0xdb 0xf5 0xfb: Hungarian), else 1252. Not when it also has 
letters Hungarian never
+// uses in 1250 but French / Portuguese do in 1252 (a grave or circumflex e, a 
grave a, u, i, o,
+// an a with tilde: 1250's r with acute, c / e / n with caron...): then those 
bytes are 1252's
+// O / U with tilde or circumflex (sur, aout, Portuguese o with tilde came out 
with o / u with
+// double acute).
+static unsigned short getEncoding(const unsigned char *buffer, unsigned long 
bufferLength)
+{
+  if (!buffer)
+    return 0;
+  bool doubleAcute = false;
+  for (unsigned long i = 0; i < bufferLength; i++)
+  {
+    switch (buffer[i])
+    {
+    case 0xd5: case 0xdb: case 0xf5: case 0xfb:
+      doubleAcute = true;
+      break;
+    case 0xc0: case 0xc3: case 0xc8: case 0xca: case 0xcc: case 0xd2: case 
0xd9:
+    case 0xe0: case 0xe3: case 0xe8: case 0xea: case 0xec: case 0xf2: case 
0xf9:
+      return 0;
+    default:
+      break;
+    }
+  }
+  return doubleAcute ? 0xee : 0;
+}
+
+// Text from CorelDRAW for Mac (charset 0, Mac Central European code page): 
its Hungarian
+// letters lie in 0x80..0x9f (á 0x87, é 0x8e, ö 0x9a...), where Windows code 
pages have only
+// punctuation; text with Windows Hungarian letters stays Windows text
+static bool isMacText(const unsigned char *buffer, unsigned long bufferLength)
+{
+  bool mac = false;
+  for (unsigned long i = 0; i < bufferLength; i++)
+  {
+    switch (buffer[i])
+    {
+    case 0x83: case 0x85: case 0x86: case 0x87: case 0x8e: case 0x92: case 
0x97: case 0x9a: case 0x9c: case 0x9f:
+      mac = true;
+      break;
+    case 0xc1: case 0xc9: case 0xcd: case 0xd3: case 0xd5: case 0xd6: case 
0xda: case 0xdb: case 0xdc:
+    case 0xe1: case 0xe9: case 0xed: case 0xf3: case 0xf6: case 0xfa: case 
0xfb: case 0xfc:
+      return false;
+    default:
+      break;
+    }
+  }
+  return mac;
+}
+
+static const uint32_t macCentralEurope[128] =   // 0x80..0xff
+{
+    0x00C4, 0x0100, 0x0101, 0x00C9, 0x0104, 0x00D6, 0x00DC, 0x00E1,
+    0x0105, 0x010C, 0x00E4, 0x010D, 0x0106, 0x0107, 0x00E9, 0x0179,
+    0x017A, 0x010E, 0x00ED, 0x010F, 0x0112, 0x0113, 0x0116, 0x00F3,
+    0x0117, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x011A, 0x011B, 0x00FC,
+    0x2020, 0x00B0, 0x0118, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
+    0x00AE, 0x00A9, 0x2122, 0x0119, 0x00A8, 0x2260, 0x0123, 0x012E,
+    0x012F, 0x012A, 0x2264, 0x2265, 0x012B, 0x0136, 0x2202, 0x2211,
+    0x0142, 0x013B, 0x013C, 0x013D, 0x013E, 0x0139, 0x013A, 0x0145,
+    0x0146, 0x0143, 0x00AC, 0x221A, 0x0144, 0x0147, 0x2206, 0x00AB,
+    0x00BB, 0x2026, 0x00A0, 0x0148, 0x0150, 0x00D5, 0x0151, 0x014C,
+    0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
+    0x014D, 0x0154, 0x0155, 0x0158, 0x2039, 0x203A, 0x0159, 0x0156,
+    0x0157, 0x0160, 0x201A, 0x201E, 0x0161, 0x015A, 0x015B, 0x00C1,
+    0x0164, 0x0165, 0x00CD, 0x017D, 0x017E, 0x016A, 0x00D3, 0x00D4,
+    0x016B, 0x016E, 0x00DA, 0x016F, 0x0170, 0x0171, 0x0172, 0x0173,
+    0x00DD, 0x00FD, 0x0137, 0x017B, 0x0141, 0x017C, 0x0122, 0x02C7
+};
+
+static bool isUnicodeChar(uint32_t c)
+{
+  return c < 0x110000 && (c < 0xd800 || c > 0xdfff) && (c & 0xfffe) != 0xfffe 
&& (c < 0xfdd0 || c > 0xfdef);
+}
+
+static void _appendUCS4(librevenge::RVNGString &text, uint32_t ucs4Character)
+{
+  // Convert carriage returns to new line characters
+  // Writerperfect/LibreOffice will replace them by <text:line-break>
+  if (ucs4Character == 0x0d)
+    ucs4Character = '
';
+
+  unsigned char outbuf[5];
+  int i = 0;
+  if (ucs4Character < 0x80)
+    outbuf[i++] = (unsigned char)ucs4Character;
+  else if (ucs4Character < 0x800)
+  {
+    outbuf[i++] = (unsigned char)(0xc0 | (ucs4Character >> 6));
+    outbuf[i++] = (unsigned char)(0x80 | (ucs4Character & 0x3f));
+  }
+  else if (ucs4Character < 0x10000)
+  {
+    outbuf[i++] = (unsigned char)(0xe0 | (ucs4Character >> 12));
+    outbuf[i++] = (unsigned char)(0x80 | ((ucs4Character >> 6) & 0x3f));
+    outbuf[i++] = (unsigned char)(0x80 | (ucs4Character & 0x3f));
+  }
+  else
+  {
+    outbuf[i++] = (unsigned char)(0xf0 | (ucs4Character >> 18));
+    outbuf[i++] = (unsigned char)(0x80 | ((ucs4Character >> 12) & 0x3f));
+    outbuf[i++] = (unsigned char)(0x80 | ((ucs4Character >> 6) & 0x3f));
+    outbuf[i++] = (unsigned char)(0x80 | (ucs4Character & 0x3f));
+  }
+  outbuf[i] = 0;
+
+  text.append((char *)outbuf);
+}
+
+// Converts bytes in a code page to UTF-8 with iconv (instead of ICU): 
characters it can't
+// convert are skipped, as before.
+static void _appendCodepage(librevenge::RVNGString &text, const 
std::vector<unsigned char> &characters, const char *codepage)
+{
+#ifdef _WIN32
+  // Windows' own converter, the code page number from the "CPnnnn" name; 
characters it can't
+  // convert (its replacement character) are skipped
+  const unsigned cp = strncmp(codepage, "CP", 2) == 0 ? 
(unsigned)atoi(codepage + 2) : 0;
+  if (!cp || characters.empty())
+    return;
+  const int n = MultiByteToWideChar(cp, 0, reinterpret_cast<const char 
*>(&characters[0]), (int)characters.size(), nullptr, 0);
+  if (n <= 0)
+    return;
+  std::vector<wchar_t> wide((size_t)n);
+  MultiByteToWideChar(cp, 0, reinterpret_cast<const char *>(&characters[0]), 
(int)characters.size(), &wide[0], n);
+  for (size_t i = 0; i < wide.size(); ++i)
+  {
+    uint32_t c = (uint16_t)wide[i];
+    if (c >= 0xd800 && c < 0xdc00 && i + 1 < wide.size() && (uint16_t)wide[i + 
1] >= 0xdc00 && (uint16_t)wide[i + 1] < 0xe000)
+    {
+      c = SURROGATE_VALUE(c, (uint16_t)wide[i + 1]);
+      ++i;
+    }
+    if (c != 0xfffd && isUnicodeChar(c))
+      _appendUCS4(text, c);
+  }
+#else
+  iconv_t cd = iconv_open("UTF-32LE", codepage);
+  if (cd == (iconv_t)-1)
+    return;
+  auto *src = const_cast<char *>(reinterpret_cast<const char 
*>(&characters[0]));
+  size_t srcLeft = characters.size();
+  while (srcLeft)
+  {
+    unsigned char out[4 * 64];
+    auto *dst = reinterpret_cast<char *>(out);
+    size_t dstLeft = sizeof(out);
+    size_t r = iconv(cd, &src, &srcLeft, &dst, &dstLeft);
+    for (size_t k = 0; k + 4 <= sizeof(out) - dstLeft; k += 4)
+    {
+      uint32_t c = out[k] | (out[k + 1] << 8) | (out[k + 2] << 16) | 
((uint32_t)out[k + 3] << 24);
+      if (isUnicodeChar(c))
+        _appendUCS4(text, c);
+    }
+    if (r == (size_t)-1 && errno != E2BIG)
+    {
+      if (errno == EINVAL)   // an incomplete sequence at the end
+        break;
+      src++;   // EILSEQ: skip the byte
+      srcLeft--;
+    }
+  }
+  iconv_close(cd);
+#endif
+}
+
+#endif // WITH_ICU
+
 } // anonymous namespace
 
 uint8_t libcdr::readU8(librevenge::RVNGInputStream *input, bool /* bigEndian 
*/)
@@ -326,7 +511,7 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, 
std::vector<unsigned
 {
   if (characters.empty())
     return;
-  static const UChar32 symbolmap [] =
+  static const uint32_t symbolmap [] =
   {
     0x0020, 0x0021, 0x2200, 0x0023, 0x2203, 0x0025, 0x0026, 0x220D, // 0x20 ..
     0x0028, 0x0029, 0x2217, 0x002B, 0x002C, 0x2212, 0x002E, 0x002F,
@@ -374,6 +559,7 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, 
std::vector<unsigned
       _appendUCS4(text, ucs4Character);
     }
   }
+#ifdef WITH_ICU
   else
   {
     UErrorCode status = U_ZERO_ERROR;
@@ -437,6 +623,69 @@ void libcdr::appendCharacters(librevenge::RVNGString 
&text, std::vector<unsigned
     if (conv)
       ucnv_close(conv);
   }
+#else
+  // CorelDRAW for Mac text: its charsets are often wrong too (Hungarian text 
marked Baltic);
+  // not tried for code pages with letters in 0x80..0x9f (Cyrillic, Arabic), 
none (Hebrew, Thai)
+  // or two bytes a character (East Asian: Shift-JIS lead bytes are 
0x81..0x9f, katakana came out
+  // as Mac Central European letters)
+  else if (charset != 0xcc && charset != 0xb2 && charset != 0xb1 && charset != 
0xde &&
+           charset != 0x80 && charset != 0x81 && charset != 0x86 && charset != 
0x88 &&
+           isMacText(&characters[0], characters.size()))
+  {
+    for (unsigned char c : characters)
+      _appendUCS4(text, c < 0x80 ? c : macCentralEurope[c - 0x80]);
+  }
+  else
+  {
+    const char *codepage;
+    switch (charset)
+    {
+    case 0x80: // SHIFTJIS
+      codepage = "CP932";
+      break;
+    case 0x81: // HANGUL
+      codepage = "CP949";
+      break;
+    case 0x86: // GB2312
+      codepage = "CP936";
+      break;
+    case 0x88: // CHINESEBIG5
+      codepage = "CP950";
+      break;
+    case 0xa1: // GREEEK
+      codepage = "CP1253";
+      break;
+    case 0xa2: // TURKISH
+      codepage = "CP1254";
+      break;
+    case 0xa3: // VIETNAMESE
+      codepage = "CP1258";
+      break;
+    case 0xb1: // HEBREW
+      codepage = "CP1255";
+      break;
+    case 0xb2: // ARABIC
+      codepage = "CP1256";
+      break;
+    case 0xba: // BALTIC
+      codepage = "CP1257";
+      break;
+    case 0xcc: // RUSSIAN
+      codepage = "CP1251";
+      break;
+    case 0xde: // THAI
+      codepage = "CP874";
+      break;
+    case 0xee: // CENTRAL EUROPE
+      codepage = "CP1250";
+      break;
+    default:   // ANSI, DEFAULT and others: often Central European text (old 
Hungarian files)
+      codepage = getEncoding(&characters[0], characters.size()) == 0xee ? 
"CP1250" : "CP1252";
+      break;
+    }
+    _appendCodepage(text, characters, codepage);
+  }
+#endif
 }
 
 void libcdr::appendCharacters(librevenge::RVNGString &text, 
std::vector<unsigned char> characters)
@@ -444,6 +693,7 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, 
std::vector<unsigned
   if (characters.empty())
     return;
 
+#ifdef WITH_ICU
   UErrorCode status = U_ZERO_ERROR;
   UConverter *conv = ucnv_open("UTF-16LE", &status);
 
@@ -460,6 +710,24 @@ void libcdr::appendCharacters(librevenge::RVNGString 
&text, std::vector<unsigned
   }
   if (conv)
     ucnv_close(conv);
+#else
+  // UTF-16LE (decoded here; ICU did it before): unpaired surrogates are 
skipped
+  for (size_t i = 0; i + 1 < characters.size(); i += 2)
+  {
+    uint32_t c = characters[i] | (characters[i + 1] << 8);
+    if (c >= 0xd800 && c <= 0xdbff && i + 3 < characters.size())
+    {
+      uint32_t l = characters[i + 2] | (characters[i + 3] << 8);
+      if (l >= 0xdc00 && l <= 0xdfff)
+      {
+        c = SURROGATE_VALUE(c, l);
+        i += 2;
+      }
+    }
+    if (isUnicodeChar(c))
+      _appendUCS4(text, c);
+  }
+#endif
 }
 
 void libcdr::appendUTF8Characters(librevenge::RVNGString &text, 
std::vector<unsigned char> characters)
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
index 68c7514..a55bd92 100644
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -19,6 +19,7 @@ test_LDADD = \
        $(top_builddir)/src/lib/libcdr-internal.la \
        $(CPPUNIT_LIBS) \
        $(ICU_LIBS) \
+       $(ICONV_LIBS) \
        $(LCMS2_LIBS) \
        $(REVENGE_LIBS) \
        $(REVENGE_STREAM_LIBS) \
commit 30c3df00f9542b614fa3579a19f1f75f236f8dfc
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:39:59 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:36 2026 +0100

    Patterns' SVG: pictures stretched to their boxes
    
    An SVG <image> keeps its proportions; CorelDRAW stretches a picture to its 
box. CorelDRAW 5's
    bitmap patterns, a picture on a page of its own and so a full colour 
pattern, came out with a
    strip of the tile empty at its top and bottom (a bitmap of 300 x 291 pixels 
on a square page).
    The pictures in a pattern's SVG get preserveAspectRatio="none".
    
    Change-Id: I092b5edc9d4dfbc194494d3b2ca6769d27f678ef

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index c150f70..56741b5 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -121,6 +121,17 @@ double cornerRadius(const libcdr::CDRGradient &gradient)
   return sqrt(dx * dx + dy * dy) * (shrink > 0.0 ? shrink : 0.0);
 }
 
+// A pattern's SVG with its pictures stretched to their boxes, as CorelDRAW 
draws them (an SVG
+// <image> keeps its proportions: a bitmap of 300 x 291 pixels on a square 
page left a strip of
+// the page empty at its top and bottom, the tiles of a CorelDRAW 5 bitmap 
pattern apart)
+std::string stretchedImages(const char *svg)
+{
+  std::string s(svg);
+  for (size_t i = 0; (i = s.find("<image ", i)) != std::string::npos; i += 7)
+    s.insert(i + 7, "preserveAspectRatio=\"none\" ");
+  return s;
+}
+
 // The bounding box a CMX file's header gives, in inches: its drawing's, the 
page of the SVG made
 // from it. False if it is not a little-endian CMX of 16- or 32-bit 
coordinates.
 bool cmxBoundingBox(const librevenge::RVNGBinaryData &data, libcdr::CDRBox 
&box)
@@ -897,7 +908,8 @@ void libcdr::CDRContentCollector::collectLevel(unsigned 
level)
       const char *header =
         "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" 
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\";>
";
       librevenge::RVNGBinaryData output((const unsigned char *)header, 
strlen(header));
-      output.append((const unsigned char *)svgOutput[0].cstr(), 
strlen(svgOutput[0].cstr()));
+      const std::string svg = stretchedImages(svgOutput[0].cstr());
+      output.append((const unsigned char *)svg.data(), svg.size());
       m_ps.m_vects[m_spnd] = output;
     }
 #if DUMP_VECT
@@ -1662,7 +1674,8 @@ void 
libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const librev
     const char *header =
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" 
\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\";>
";
     librevenge::RVNGBinaryData output((const unsigned char *)header, 
strlen(header));
-    output.append((const unsigned char *)svgOutput[0].cstr(), 
strlen(svgOutput[0].cstr()));
+    const std::string svg = stretchedImages(svgOutput[0].cstr());
+    output.append((const unsigned char *)svg.data(), svg.size());
     m_ps.m_vects[id] = output;
     CDRBox box;
     if (cmxBoundingBox(data, box))
commit 435fef7250cfa25e78c7a53917222a04dcae8551
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:39:59 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:36 2026 +0100

    Tiled fills: the vertical offset from the tile transform as a share of the 
tile's height
    
    A bitmap, texture or full colour fill's offset from its tile transform 
(ftil) went out as a
    share of the tile's width for both directions: a texture tile of 1.6 x 1.0 
inches moved by a
    whole tile height came out 40% of the way off, cut through by a seam.
    
    Change-Id: Id478741e8cd5eea5248848d8bd92b6a45e2e13b2

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index b69ee7d..c150f70 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -1208,7 +1208,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
             }
             if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
-              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.width;
+              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.height;
               normalize(yOffset);
               propList.insert("draw:fill-image-ref-point-y", 1.0 - yOffset, 
librevenge::RVNG_PERCENT);
             }
@@ -1270,7 +1270,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
             }
             if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
-              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.width;
+              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.height;
               while (yOffset < 0.0)
                 yOffset += 1.0;
               while (yOffset > 1.0)
@@ -1335,7 +1335,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
             }
             if (!CDR_ALMOST_ZERO(m_fillTransforms.getTranslateY()))
             {
-              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.width;
+              double yOffset = m_fillTransforms.getTranslateY() / 
m_currentFillStyle.imageFill.height;
               while (yOffset < 0.0)
                 yOffset += 1.0;
               while (yOffset > 1.0)
commit ef65b446b984ec9aa5e5ae8cd0a29435a2dc0022
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:26:59 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    Radial and square fills: svg:r reaching the box's farthest corner
    
    CorelDRAW's radial and square fills have their start colour at the bounding 
box's corner
    farthest from the centre, shrunk by twice the edge pad. Without svg:r 
librevenge's SVG made the
    radius the box's width (1 - draw:border): the corners stayed half way 
between the colours (the
    fills of vector patterns, drawn from that SVG). svg:r goes out as that 
distance, in the box's
    units; ODF consumers keep going by draw:border.
    
    Change-Id: I025ae3ac9ca73dea93e17493bef65a0874a87bd9

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 0c5f1d4..b69ee7d 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -109,6 +109,18 @@ double pageAngle(const libcdr::CDRGradient &gradient, 
const libcdr::CDRTransform
   return atan2(y1 - y0, x1 - x0);
 }
 
+// A radial or square fill's radius in its bounding box's units (svg:r; an ODF 
consumer goes by
+// draw:border): CorelDRAW's start colour reaches the box's farthest corner 
from the centre, the
+// edge pad shrinking it by twice its share (librevenge's SVG made it the 
box's width: the corners
+// were not reached)
+double cornerRadius(const libcdr::CDRGradient &gradient)
+{
+  const double cx = 0.5 + gradient.m_centerXOffset / 100.0, cy = 0.5 - 
gradient.m_centerYOffset / 100.0;
+  const double dx = cx > 0.5 ? cx : 1.0 - cx, dy = cy > 0.5 ? cy : 1.0 - cy;
+  const double shrink = 1.0 - 2.0 * gradient.m_edgeOffset / 100.0;
+  return sqrt(dx * dx + dy * dy) * (shrink > 0.0 ? shrink : 0.0);
+}
+
 // The bounding box a CMX file's header gives, in inches: its drawing's, the 
page of the SVG made
 // from it. False if it is not a little-endian CMX of 16- or 32-bit 
coordinates.
 bool cmxBoundingBox(const librevenge::RVNGBinaryData &data, libcdr::CDRBox 
&box)
@@ -1051,12 +1063,14 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
             propList.insert("draw:style", "radial");
             propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/100.0), librevenge::RVNG_PERCENT);
             propList.insert("svg:cy", (double)(0.5 - 
m_currentFillStyle.gradient.m_centerYOffset/100.0), librevenge::RVNG_PERCENT);  
 // (a share of the box, up positive)
+            propList.insert("svg:r", 
cornerRadius(m_currentFillStyle.gradient), librevenge::RVNG_PERCENT);
             break;
           case 4: // square
             propList.insert("draw:border", (2.0 * 
(double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0), 
librevenge::RVNG_PERCENT);
             propList.insert("draw:style", "square");
             propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/100.0), librevenge::RVNG_PERCENT);
             propList.insert("svg:cy", (double)(0.5 - 
m_currentFillStyle.gradient.m_centerYOffset/100.0), librevenge::RVNG_PERCENT);  
 // (a share of the box, up positive)
+            propList.insert("svg:r", 
cornerRadius(m_currentFillStyle.gradient), librevenge::RVNG_PERCENT);
             break;
           default:
             propList.insert("draw:style", "linear");
commit ed25413f658c6a5518a6dc5d2618933e60811543
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:19:39 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    Fountain fills: the angle of versions 6+ turned with the object
    
    From CorelDRAW 6 a fountain fill's angle is the object's own (0 for a fill 
on an object turned
    by 47.5 degrees, where CorelDRAW 5 stores -47.5): it went out as the 
page's, so the fill of a
    turned object did not turn with it. Its direction is now put through the 
object's transform
    (mirrored objects too), for libcdr:gradient-angle and ODF's draw:angle 
alike.
    
    Change-Id: I7560f8fbb223fedbfc26e451c9b49f438cbcd144

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index d434ee6..0c5f1d4 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -95,6 +95,20 @@ void normalizeAngle(double &angle)
     angle += 360;
 }
 
+// A fountain fill's angle on the page (radians, counter-clockwise): one of 
the object's own is
+// turned (and mirrored) with the object
+double pageAngle(const libcdr::CDRGradient &gradient, const 
libcdr::CDRTransforms &trafos)
+{
+  if (!gradient.m_objectAngle || trafos.empty())
+    return gradient.m_angle;
+  double x0 = 0.0, y0 = 0.0, x1 = cos(gradient.m_angle), y1 = 
sin(gradient.m_angle);
+  trafos.applyToPoint(x0, y0);
+  trafos.applyToPoint(x1, y1);
+  if (CDR_ALMOST_ZERO(x1 - x0) && CDR_ALMOST_ZERO(y1 - y0))
+    return gradient.m_angle;
+  return atan2(y1 - y0, x1 - x0);
+}
+
 // The bounding box a CMX file's header gives, in inches: its drawing's, the 
page of the SVG made
 // from it. False if it is not a little-endian CMX of 16- or 32-bit 
coordinates.
 bool cmxBoundingBox(const librevenge::RVNGBinaryData &data, libcdr::CDRBox 
&box)
@@ -1016,7 +1030,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
         }
         else if (m_currentFillStyle.gradient.m_stops.size() == 2)
         {
-          double angle = m_currentFillStyle.gradient.m_angle * 180 / M_PI;
+          double angle = pageAngle(m_currentFillStyle.gradient, 
m_currentTransforms) * 180 / M_PI;
           normalizeAngle(angle);
           propList.insert("draw:fill", "gradient");
           propList.insert("draw:start-color", 
m_ps.getRGBColorString(m_currentFillStyle.gradient.m_stops[0].m_color));
@@ -1066,7 +1080,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
         {
           propList.insert("draw:fill", "gradient");
           propList.insert("draw:style", "linear");
-          double angle = m_currentFillStyle.gradient.m_angle * 180 / M_PI;
+          double angle = pageAngle(m_currentFillStyle.gradient, 
m_currentTransforms) * 180 / M_PI;
           angle += 90.0;
           normalizeAngle(angle);
           propList.insert("draw:angle", (int)angle);
@@ -1090,7 +1104,7 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           static const char *const types[] = { "linear", "linear", "radial", 
"conical", "square" };
           const CDRGradient &gradient = m_currentFillStyle.gradient;
           propList.insert("libcdr:gradient-type", types[gradient.m_type < 5 ? 
gradient.m_type : 0]);
-          propList.insert("libcdr:gradient-angle", gradient.m_angle * 180 / 
M_PI);
+          propList.insert("libcdr:gradient-angle", pageAngle(gradient, 
m_currentTransforms) * 180 / M_PI);
           propList.insert("libcdr:gradient-center-x", gradient.m_centerXOffset 
/ 100.0);
           propList.insert("libcdr:gradient-center-y", gradient.m_centerYOffset 
/ 100.0);
           propList.insert("libcdr:gradient-edge", gradient.m_edgeOffset / 
100.0);
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 2c59417..995d814 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -1563,6 +1563,7 @@ void 
libcdr::CDRParser::readFild(librevenge::RVNGInputStream *input, unsigned le
       gradient.m_edgeOffset = readS16(input);
     }
     gradient.m_angle = readAngle(input);
+    gradient.m_objectAngle = m_version >= 600;   // (CorelDRAW 5: -47.5 for a 
fill of 0 on an object turned by it)
     gradient.m_centerXOffset = readInteger(input);
     gradient.m_centerYOffset = readInteger(input);
     if (m_version >= 600)
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index d113e29..d610148 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -82,9 +82,10 @@ struct CDRGradient
   int m_edgeOffset;
   int m_centerXOffset;
   int m_centerYOffset;
+  bool m_objectAngle;   // the angle is the object's own (versions 6+), turned 
with it; else the page's
   std::vector<CDRGradientStop> m_stops;
   CDRGradient()
-    : m_type(0), m_mode(0), m_angle(0.0), m_midPoint(0.0), m_edgeOffset(0), 
m_centerXOffset(0), m_centerYOffset(0), m_stops() {}
+    : m_type(0), m_mode(0), m_angle(0.0), m_midPoint(0.0), m_edgeOffset(0), 
m_centerXOffset(0), m_centerYOffset(0), m_objectAngle(false), m_stops() {}
 };
 
 struct CDRImageFill
commit 9ef6b356907945c9e26fbcae274154a035492da2
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:47:22 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    Arrowheads: CorelDRAW 5's, and their own units
    
    CorelDRAW 5's arrw records (the id followed by 2 bytes, not 4) are read:
    its lines' arrowheads were missing. A line's arrowheads also go out in
    their own units (libcdr:marker-start / -end, SVG path data, the tip at the
    line's end, y along the line) with libcdr:marker-unit, one of them in
    inches: twice the line's width, no less than 0.028 inch (as CorelDRAW 9's
    PDF exports show: 2.016 pt for 1000 units of a 0.216 and a 0.72 pt line,
    2.88 pt of a 1.44 pt one). draw:marker-*-path is transformed for ODF's
    drawing of markers and loses that scale.
    
    Change-Id: I6d2cec5d03be7bcc28cd0df7c4307af3ca3be0b9

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 45bc46e..d434ee6 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -41,6 +41,32 @@ namespace libcdr
 namespace
 {
 
+// An arrowhead's outline as SVG path data in its own units, as its arrw 
record gives it (libcdr's
+// own libcdr:marker-start / -end: draw:marker-*-path is transformed for ODF's 
drawing of markers)
+librevenge::RVNGString markerPath(const libcdr::CDRPath &marker)
+{
+  librevenge::RVNGPropertyListVector vec;
+  marker.writeOut(vec);
+  librevenge::RVNGString out;
+  for (unsigned long i = 0; i < vec.count(); ++i)
+  {
+    const librevenge::RVNGPropertyList &e = vec[i];
+    if (!e["librevenge:path-action"])
+      continue;
+    librevenge::RVNGString action = e["librevenge:path-action"]->getStr();
+    librevenge::RVNGString part;
+    if (action == "C" && e["svg:x1"] && e["svg:y1"] && e["svg:x2"] && 
e["svg:y2"] && e["svg:x"] && e["svg:y"])
+      part.sprintf("C%g %g %g %g %g %g", e["svg:x1"]->getDouble(), 
e["svg:y1"]->getDouble(), e["svg:x2"]->getDouble(),
+                   e["svg:y2"]->getDouble(), e["svg:x"]->getDouble(), 
e["svg:y"]->getDouble());
+    else if ((action == "M" || action == "L") && e["svg:x"] && e["svg:y"])
+      part.sprintf("%s%g %g", action.cstr(), e["svg:x"]->getDouble(), 
e["svg:y"]->getDouble());
+    else if (action == "Z")
+      part = "Z";
+    out.append(part);
+  }
+  return out;
+}
+
 /// Move the number into [0;1] range.
 void normalize(double &d)
 {
@@ -1335,6 +1361,20 @@ void 
libcdr::CDRContentCollector::_lineProperties(librevenge::RVNGPropertyList &
       }
       scale *= m_currentLineStyle.stretch;
       propList.insert("svg:stroke-width", m_currentLineStyle.lineWidth * 
scale);
+      // arrowheads, in their own units: 1 (1000 in a CorelDRAW 5 arrw record) 
is twice the line's
+      // width, but no less than 0.028 inch (as CorelDRAW 9's PDF exports 
show); the tip at the
+      // line's end, the arrowhead's y axis along the line (libcdr's own 
properties)
+      const bool hasStartMarker = m_currentLineStyle.startMarker && 
!m_currentLineStyle.startMarker->empty();
+      const bool hasEndMarker = m_currentLineStyle.endMarker && 
!m_currentLineStyle.endMarker->empty();
+      if (hasStartMarker || hasEndMarker)
+      {
+        double width = m_currentLineStyle.lineWidth * scale;
+        propList.insert("libcdr:marker-unit", 2.0 * (width > 0.014 ? width : 
0.014));
+        if (hasStartMarker)
+          propList.insert("libcdr:marker-start", 
markerPath(*m_currentLineStyle.startMarker));
+        if (hasEndMarker)
+          propList.insert("libcdr:marker-end", 
markerPath(*m_currentLineStyle.endMarker));
+      }
       propList.insert("svg:stroke-color", 
m_ps.getRGBColorString(m_currentLineStyle.color));
 
       switch (m_currentLineStyle.capsType)
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 01d574a..2c59417 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -1193,12 +1193,13 @@ void 
libcdr::CDRParser::readPath(librevenge::RVNGInputStream *input)
 void libcdr::CDRParser::readArrw(librevenge::RVNGInputStream *input, unsigned 
length)
 {
   CDR_DEBUG_MSG(("CDRParser::readArrw
"));
-  if (m_version < 600)
+  // (CorelDRAW 5 as well, its id followed by 2 bytes, not 4: its lines' 
arrowheads were missing)
+  if (m_version < 500)
     return;
   if (!_redirectX6Chunk(&input, length))
     throw GenericException();
   unsigned arrowId = readU32(input);
-  input->seek(4, librevenge::RVNG_SEEK_CUR);
+  input->seek(m_version < 600 ? 2 : 4, librevenge::RVNG_SEEK_CUR);
   unsigned long pointNum = readU16(input);
   const unsigned short pointSize = 2 * (m_precision == PRECISION_16BIT ? 2 : 
4) + 1;
   const unsigned long maxLength = getRemainingLength(input);
commit 7511cb7f1af13044c7473d2f35a5434868dd0a86
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:05:56 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    Full colour patterns: the fill's SVG cut to the pattern's tile
    
    A vector pattern (vpat) is a CMX file of its objects, which reach beyond 
the tile; the SVG made
    of it had their bounding box as its page, and the whole page was tiled: the 
objects with margins
    round them, or a quarter of the tile, repeated. The tile is in the fill 
record (CorelDRAW 6 to
    12): of the 21 bytes after the flags, one byte, the tile as a rectangle of 
the pattern's own
    drawing (x0, y0, x1, y1), then 4 bytes. The CMX header's bounding box 
places it on the SVG's
    page, and the fill's SVG gets it as its viewBox and size.
    
    Change-Id: If774de3de92ed5096313ddfac4410c0051468112

diff --git a/src/lib/CDRCollector.cpp b/src/lib/CDRCollector.cpp
index 7298f6c..60ed6bf 100644
--- a/src/lib/CDRCollector.cpp
+++ b/src/lib/CDRCollector.cpp
@@ -17,7 +17,7 @@
 #include "libcdr_utils.h"
 
 libcdr::CDRParserState::CDRParserState()
-  : m_bmps(), m_monoBmps(), m_patterns(), m_vects(), m_pages(), 
m_documentPalette(), m_texts(),
+  : m_bmps(), m_monoBmps(), m_patterns(), m_vects(), m_vectBoxes(), m_pages(), 
m_documentPalette(), m_texts(),
     m_styles(), m_fillStyles(), m_lineStyles(),
     m_colorTransformCMYK2RGB(nullptr), m_colorTransformLab2RGB(nullptr), 
m_colorTransformRGB2RGB(nullptr)
 {
diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h
index e1298e7..e8f25dc 100644
--- a/src/lib/CDRCollector.h
+++ b/src/lib/CDRCollector.h
@@ -37,6 +37,7 @@ public:
   std::set<unsigned> m_monoBmps;   // the 1-bit (black and white) ones: 
coloured by the object using them
   std::map<unsigned, CDRPattern> m_patterns;
   std::map<unsigned, librevenge::RVNGBinaryData> m_vects;
+  std::map<unsigned, CDRBox> m_vectBoxes;   // a vector pattern's drawing: the 
page of its SVG in m_vects
   std::vector<CDRPage> m_pages;
   std::map<unsigned, CDRColor> m_documentPalette;
   std::map<unsigned, std::vector<CDRTextLine> > m_texts;
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index d6504e9..45bc46e 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -9,6 +9,8 @@
 
 #include "CDRContentCollector.h"
 
+#include <cstdint>
+#include <string>
 #include <utility>
 
 #include <math.h>
@@ -67,6 +69,59 @@ void normalizeAngle(double &angle)
     angle += 360;
 }
 
+// The bounding box a CMX file's header gives, in inches: its drawing's, the 
page of the SVG made
+// from it. False if it is not a little-endian CMX of 16- or 32-bit 
coordinates.
+bool cmxBoundingBox(const librevenge::RVNGBinaryData &data, libcdr::CDRBox 
&box)
+{
+  const unsigned char *p = data.getDataBuffer();
+  if (!p || data.size() < 0x84 || memcmp(p, "RIFF", 4) || memcmp(p + 8, 
"CMX1", 4) || memcmp(p + 12, "cont", 4) || p[0x44] != '2')
+    return false;
+  double c[4];
+  for (int k = 0; k < 4; ++k)
+  {
+    if (p[0x48] == '4')
+    {
+      const unsigned char *q = p + 0x74 + 4 * k;
+      c[k] = (int32_t)((uint32_t)q[0] | (uint32_t)q[1] << 8 | (uint32_t)q[2] 
<< 16 | (uint32_t)q[3] << 24) / 254000.0;
+    }
+    else if (p[0x48] == '2')
+    {
+      const unsigned char *q = p + 0x74 + 2 * k;
+      c[k] = (int16_t)((uint16_t)q[0] | (uint16_t)q[1] << 8) / 1000.0;
+    }
+    else
+      return false;
+  }
+  box = libcdr::CDRBox(c[0], c[1], c[2], c[3]);
+  return box.getWidth() > 0 && box.getHeight() > 0;
+}
+
+// A full colour pattern's SVG (its drawing, on the page `page`) cut to its 
tile: the root's viewBox
+// (points, y down from the page's top) and size set to the tile's
+librevenge::RVNGBinaryData tileSVG(const librevenge::RVNGBinaryData &svg, 
const libcdr::CDRBox &page, const libcdr::CDRBox &tile)
+{
+  std::string s((const char *)svg.getDataBuffer(), svg.size());
+  const size_t start = s.find("<svg ");
+  const size_t end = start == std::string::npos ? std::string::npos : 
s.find('>', start);
+  if (end == std::string::npos)
+    return svg;
+  std::string tag = s.substr(start, end - start);
+  for (const char *name : {" width=\"", " height=\"", " viewBox=\""})
+  {
+    const size_t i = tag.find(name);
+    const size_t j = i == std::string::npos ? i : tag.find('"', i + 
strlen(name));
+    if (j != std::string::npos)
+      tag.erase(i, j + 1 - i);
+  }
+  librevenge::RVNGString attributes;
+  attributes.sprintf(" width=\"%.4fin\" height=\"%.4fin\" viewBox=\"%.4f %.4f 
%.4f %.4f\"", tile.getWidth(), tile.getHeight(),
+                     (tile.getMinX() - page.getMinX()) * 72.0, (page.getMinY() 
+ page.getHeight() - tile.getMinY() - tile.getHeight()) * 72.0,
+                     tile.getWidth() * 72.0, tile.getHeight() * 72.0);
+  tag += attributes.cstr();
+  s.replace(start, end - start, tag);
+  return librevenge::RVNGBinaryData((const unsigned char *)s.data(), s.size());
+}
+
 }
 }
 
@@ -1181,7 +1236,12 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
         {
           propList.insert("draw:fill", "bitmap");
           propList.insert("librevenge:mime-type", "image/svg+xml");
-          propList.insert("draw:fill-image", iterVect->second);
+          const CDRBox &tile = m_currentFillStyle.imageFill.tile;
+          auto iterBox = 
m_ps.m_vectBoxes.find(m_currentFillStyle.imageFill.id);
+          if (tile.getWidth() > 0 && tile.getHeight() > 0 && iterBox != 
m_ps.m_vectBoxes.end())
+            propList.insert("draw:fill-image", tileSVG(iterVect->second, 
iterBox->second, tile));
+          else
+            propList.insert("draw:fill-image", iterVect->second);
           propList.insert("style:repeat", "repeat");
           if (m_currentFillStyle.imageFill.isRelative)
           {
@@ -1536,6 +1596,9 @@ void 
libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const librev
     librevenge::RVNGBinaryData output((const unsigned char *)header, 
strlen(header));
     output.append((const unsigned char *)svgOutput[0].cstr(), 
strlen(svgOutput[0].cstr()));
     m_ps.m_vects[id] = output;
+    CDRBox box;
+    if (cmxBoundingBox(data, box))
+      m_ps.m_vectBoxes[id] = box;
   }
 #if DUMP_VECT
   librevenge::RVNGString filename;
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index f6645dd..01d574a 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -1705,13 +1705,27 @@ void 
libcdr::CDRParser::readFild(librevenge::RVNGInputStream *input, unsigned le
       patternWidth = (double)tmpWidth / 100.0;
       patternHeight = (double)tmpHeight / 100.0;
     }
+    CDRBox tile;
     if (m_version >= 1300)
       input->seek(17, librevenge::RVNG_SEEK_CUR);
+    else if (m_version >= 600)
+    {
+      // the tile: a rectangle of the pattern's own drawing, whose objects may 
reach beyond it
+      // (CorelDRAW 6 .. 12; the pattern's CMX gives only their bounding box)
+      input->seek(1, librevenge::RVNG_SEEK_CUR);
+      const double x0 = readCoordinate(input);
+      const double y0 = readCoordinate(input);
+      const double x1 = readCoordinate(input);
+      const double y1 = readCoordinate(input);
+      tile = CDRBox(x0, y0, x1, y1);
+      input->seek(4, librevenge::RVNG_SEEK_CUR);
+    }
     else
       input->seek(21, librevenge::RVNG_SEEK_CUR);
     if (m_version >= 600)
       patternId = readUnsigned(input);
     imageFill = libcdr::CDRImageFill(patternId, patternWidth, patternHeight, 
isRelative, tileOffsetX, tileOffsetY, rcpOffset, flags);
+    imageFill.tile = tile;
   }
   break;
   case 11: // Texture
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index 3f49cd6..d113e29 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -97,10 +97,11 @@ struct CDRImageFill
   double yOffset;
   double rcpOffset;
   unsigned char flags;
-  CDRImageFill() : id(0), width(0.0), height(0.0), isRelative(false), 
xOffset(0.0), yOffset(0.0), rcpOffset(0.0), flags(0)
+  CDRBox tile;   // a full colour pattern's tile in its own drawing (empty: 
its whole drawing)
+  CDRImageFill() : id(0), width(0.0), height(0.0), isRelative(false), 
xOffset(0.0), yOffset(0.0), rcpOffset(0.0), flags(0), tile()
   {}
   CDRImageFill(unsigned i, double w, double h, bool r, double x, double y, 
double o, unsigned char f)
-    : id(i), width(w), height(h), isRelative(r), xOffset(x), yOffset(y), 
rcpOffset(o), flags(f) {}
+    : id(i), width(w), height(h), isRelative(r), xOffset(x), yOffset(y), 
rcpOffset(o), flags(f), tile() {}
 };
 
 struct CDRFillStyle
commit 28792f6e31a3ea16efc1318a32141fa9afafef96
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:05:56 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    Radial and square fills: svg:cx / svg:cy from the centre's offsets
    
    svg:cy took the horizontal offset, and both took half of it: the offset is 
a share of the
    bounding box's width / height (up positive), 0.5 putting the centre on the 
edge.
    
    Change-Id: Ib9dbebab9dbac3b7af2a4d64f1e13ad70b57ab07

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index def4e20..d6504e9 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -954,14 +954,14 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           case 2: // radial
             propList.insert("draw:border", (2.0 * 
(double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0), 
librevenge::RVNG_PERCENT);
             propList.insert("draw:style", "radial");
-            propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT);
-            propList.insert("svg:cy", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT);
+            propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/100.0), librevenge::RVNG_PERCENT);
+            propList.insert("svg:cy", (double)(0.5 - 
m_currentFillStyle.gradient.m_centerYOffset/100.0), librevenge::RVNG_PERCENT);  
 // (a share of the box, up positive)
             break;
           case 4: // square
             propList.insert("draw:border", (2.0 * 
(double)(m_currentFillStyle.gradient.m_edgeOffset)/100.0), 
librevenge::RVNG_PERCENT);
             propList.insert("draw:style", "square");
-            propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT);
-            propList.insert("svg:cy", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/200.0), librevenge::RVNG_PERCENT);
+            propList.insert("svg:cx", (double)(0.5 + 
m_currentFillStyle.gradient.m_centerXOffset/100.0), librevenge::RVNG_PERCENT);
+            propList.insert("svg:cy", (double)(0.5 - 
m_currentFillStyle.gradient.m_centerYOffset/100.0), librevenge::RVNG_PERCENT);  
 // (a share of the box, up positive)
             break;
           default:
             propList.insert("draw:style", "linear");
commit 384e90642b875c0e8750bc7d849e919f0fd16802
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:05:56 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:35 2026 +0100

    CMX: fountain fill types counted from 0
    
    A CMX fountain fill's type is 0 linear, 1 radial, 2 conical, 3 square; 
libcdr's are 1 .. 4, as
    in CDR files: the radial fills of CMX (those of vector patterns among them) 
came out linear, the
    conical ones radial.
    
    Change-Id: I016a4b1a20b006a6a2535a79076cf67193fb571d

diff --git a/src/lib/CMXParser.cpp b/src/lib/CMXParser.cpp
index 93a3a7a..3934b48 100644
--- a/src/lib/CMXParser.cpp
+++ b/src/lib/CMXParser.cpp
@@ -1144,7 +1144,7 @@ bool 
libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
         {
         case CMX_Tag_RenderAttr_FillSpec_Fountain_Base:
         {
-          gradient.m_type = (unsigned char)(readU16(input, m_bigEndian) & 
0xff);
+          gradient.m_type = (unsigned char)((readU16(input, m_bigEndian) & 
0xff) + 1);   // (CMX: 0 linear .. 3 square; CDR: 1 ..)
           /* unsigned short screen = */ readU16(input, m_bigEndian);
           gradient.m_edgeOffset = readU16(input, m_bigEndian);
           gradient.m_angle = readAngle(input, m_bigEndian);
@@ -1182,7 +1182,7 @@ bool 
libcdr::CMXParser::readFill(librevenge::RVNGInputStream *input)
     else if (m_precision == libcdr::PRECISION_16BIT)
     {
       CDR_DEBUG_MSG(("    Fountain fill
"));
-      gradient.m_type = (unsigned char)(readU16(input, m_bigEndian) & 0xff);
+      gradient.m_type = (unsigned char)((readU16(input, m_bigEndian) & 0xff) + 
1);   // (CMX: 0 linear .. 3 square; CDR: 1 ..)
       /* unsigned short screen = */ readU16(input, m_bigEndian);
       gradient.m_edgeOffset = readU16(input, m_bigEndian);
       gradient.m_angle = readAngle(input, m_bigEndian);
commit b748ad8221abf43dc08f82f5f2991dd6935ceb84
Author:     A'rpi <[email protected]>
AuthorDate: Wed Nov 4 10:05:56 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:34 2026 +0100

    Every fill even-odd, as CorelDRAW fills
    
    svg:fill-rule evenodd went out with solid fills only: a ring of two circles 
drawn the same way
    round, with a fountain or a pattern fill, came out a disc (and so did the 
holes of other combined
    objects). CorelDRAW fills every object even-odd.
    
    Change-Id: Ibbc832fc827f0aeceaacf3ff835cf9041bf3b229

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 29c01b9..def4e20 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -908,6 +908,9 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
 
   if (m_fillOpacity < 1.0)
     propList.insert("draw:opacity", m_fillOpacity, librevenge::RVNG_PERCENT);
+  // CorelDRAW fills every object even-odd (a ring of two circles drawn the 
same way round, with a
+  // gradient or a pattern too)
+  propList.insert("svg:fill-rule", "evenodd");
   if (m_currentFillStyle.fillType == 0)
     propList.insert("draw:fill", "none");
   else
@@ -921,7 +924,6 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
       case 1: // Solid
         propList.insert("draw:fill", "solid");
         propList.insert("draw:fill-color", 
m_ps.getRGBColorString(m_currentFillStyle.color1));
-        propList.insert("svg:fill-rule", "evenodd");
         break;
       case 2: // Gradient
         if (m_currentFillStyle.gradient.m_stops.empty())
@@ -930,7 +932,6 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
         {
           propList.insert("draw:fill", "solid");
           propList.insert("draw:fill-color", 
m_ps.getRGBColorString(m_currentFillStyle.gradient.m_stops[0].m_color));
-          propList.insert("svg:fill-rule", "evenodd");
         }
         else if (m_currentFillStyle.gradient.m_stops.size() == 2)
         {
@@ -1109,7 +1110,6 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           // We did not find the pattern, so fill solid with the background 
colour
           propList.insert("draw:fill", "solid");
           propList.insert("draw:fill-color", 
m_ps.getRGBColorString(m_currentFillStyle.color2));
-          propList.insert("svg:fill-rule", "evenodd");
         }
       }
       break;
commit a76d3bbd1f840124cd87186c9d74f527348d32f2
Author:     A'rpi <[email protected]>
AuthorDate: Mon Nov 2 09:30:46 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:34 2026 +0100

    Text styles: a run's style built once per run, not per character
    
    collectText copied the paragraph's CDRStyle (with its line and fill
    styles, strings and marker paths) for every character to have the run's
    style ready when the run changed; now only when it changes.
    
    Change-Id: Id36297ba1f1c86707826a3d8f8fcf8f858f7c5e5

diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index e7b3613..39866c9 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -304,9 +304,9 @@ void libcdr::CDRStylesCollector::collectText(unsigned 
textId, unsigned styleId,
     bool twoByte = charDescriptions[i] & 0x01;
     bool lineBreak = data[j] == 0x0d && (!twoByte || (j + 1 < data.size() && 
data[j + 1] == 0));
     unsigned key = lineBreak ? 0x100 | charDescriptions[i] : 
charDescriptions[i];
-    tmpCharStyle = styleOf(tmpKey);
-    if (key != tmpKey)
+    if (key != tmpKey)   // (the run's style only here: a CDRStyle is big, it 
was copied for every character)
     {
+      tmpCharStyle = styleOf(tmpKey);
       librevenge::RVNGString text;
       if (tmpKey & 0x100)   // (line breaks, not converted: a symbol font's 
code page made them other characters)
         for (size_t k = 0; k < tmpTextData.size(); k += (tmpKey & 0x01) ? 2 : 
1)
commit c289d3794476d74877daa4d2797d9dee1d740dd0
Author:     A'rpi <[email protected]>
AuthorDate: Mon Nov 2 07:57:53 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:34 2026 +0100

    Wholly transparent bitmaps left out
    
    A 1-bit bitmap all white without a fill, or a bitmap whose transparency
    mask is 0 everywhere, went out with alpha 0 everywhere, which BMP readers
    (libcdr's bitmaps have alpha 0 when opaque) take for an opaque image: a
    black or white rectangle where nothing shows. Such bitmaps are not output.
    
    Change-Id: I93ec20c96d16c3445dd3ee95110e03f7a85b5fdb

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index c3df919..29c01b9 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -486,12 +486,14 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
     else if (imageData.size() > 4 && !memcmp(head, "GIF8", 4))
       mimeType = "image/gif";
     propList.insert("librevenge:mime-type", mimeType);
-    propList.insert("office:binary-data", m_currentImageMono ? 
_monoImage(m_currentImage.getImage()) : m_currentImage.getImage());
+    const librevenge::RVNGBinaryData image = m_currentImageMono ? 
_monoImage(imageData) : imageData;
+    propList.insert("office:binary-data", image);
     // the bitmap's own outline (a bitmap cropped with the Shape tool, or a 
pattern tile of an
     // imported PDF): it shows only inside it (libcdr's own: librevenge has no 
clip for images)
     if (imageClip.count())
       propList.insert("libcdr:clip-path", imageClip);
-    outputElement.addGraphicObject(propList);
+    if (image.size())   // (empty: a 1-bit bitmap with nothing to show)
+      outputElement.addGraphicObject(propList);
   }
   if (m_currentText && !m_currentText->empty())
   {
@@ -864,7 +866,9 @@ void 
libcdr::CDRContentCollector::collectPolygonTransform(unsigned numAngles, un
 
 // A 1-bit bitmap as CorelDRAW colours it: its black pixels in the object's 
outline colour (black
 // without an outline), its white ones in the fill colour (transparent without 
a fill). bmp: the
-// 32-bit BMP of CDRStylesCollector::collectBmp, its pixels 0x000000 or 
0xffffff.
+// 32-bit BMP of CDRStylesCollector::collectBmp, its pixels 0x000000 or 
0xffffff. Empty when all
+// its pixels are transparent (all white without a fill): a BMP whose alpha is 
0 everywhere is
+// read as an opaque one (a black rectangle).
 librevenge::RVNGBinaryData libcdr::CDRContentCollector::_monoImage(const 
librevenge::RVNGBinaryData &bmp)
 {
   librevenge::RVNGPropertyList style;   // (resolves the object's fill and 
line styles)
@@ -878,14 +882,18 @@ librevenge::RVNGBinaryData 
libcdr::CDRContentCollector::_monoImage(const libreve
   if (bmp.size() < offset)
     return bmp;
   std::vector<unsigned char> data(bmp.getDataBuffer(), bmp.getDataBuffer() + 
bmp.size());
+  bool shown = false;
   for (unsigned long i = offset; i + 4 <= data.size(); i += 4)
   {
     unsigned v = (data[i] & 1) ? bg : fg;
+    shown = shown || v;
     data[i] = (unsigned char)v;
     data[i + 1] = (unsigned char)(v >> 8);
     data[i + 2] = (unsigned char)(v >> 16);
     data[i + 3] = (unsigned char)(v >> 24);
   }
+  if (!shown)
+    return librevenge::RVNGBinaryData();
   return librevenge::RVNGBinaryData(data.data(), data.size());
 }
 
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 4539999..e7b3613 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -194,20 +194,27 @@ void libcdr::CDRStylesCollector::collectBmp(unsigned 
imageId, unsigned colorMode
 #endif
 
     // a transparency mask: its values become the alpha of the pixels (left 0 
otherwise,
-    // which BMP readers take as an opaque image)
+    // which BMP readers take as an opaque image); a wholly transparent bitmap 
is left out (its
+    // alpha 0 everywhere would read as an opaque one)
+    bool shown = true;
     if (m_maskId == imageId && m_maskWidth == width && m_maskHeight == height 
&& height &&
         m_mask.size() / height >= width && pixels.size() == (unsigned 
long)width * height * 4)
     {
+      shown = false;
       const unsigned long maskStride = m_mask.size() / height;
       for (unsigned j = 0; j < height; ++j)
         for (unsigned k = 0; k < width; ++k)
+        {
           pixels[((unsigned long)j * width + k) * 4 + 3] = m_mask[j * 
maskStride + k];
+          shown = shown || m_mask[j * maskStride + k];
+        }
     }
     image.append(pixels.data(), pixels.size());
     m_mask.clear();
     m_maskId = 0;
 
-    m_ps.m_bmps[imageId] = image;
+    if (shown)
+      m_ps.m_bmps[imageId] = image;
   }
 }
 
commit ca636327ffef77f04c81ffcff3af4c254b597934
Author:     A'rpi <[email protected]>
AuthorDate: Mon Nov 2 07:57:52 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:34 2026 +0100

    East Asian character sets ignored in CorelDRAW 5 files only
    
    CorelDRAW 5 files mark Hungarian text with Shift-JIS, Hangul, GB2312 or
    Big5 too; those were taken for no character set in every version, so any
    later file's real CJK text came out wrong. Now only CorelDRAW 5's text
    styles and font records drop them (in the samples, CJK-marked text other
    than font names is all in CorelDRAW 5 files, all Hungarian; no sample's
    rendering changed).
    
    Change-Id: I1d95ef707a472319903975ed6cd5fb2765259d98

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 81df029..f6645dd 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -41,6 +41,14 @@
 namespace
 {
 
+// A CorelDRAW 5 text style's character set: those files mark Central European 
(Hungarian) text
+// with East Asian ones too (Shift-JIS, Hangul, GB2312, Big5: it came out as 
CJK characters); no
+// character set (guessed from the text) instead. Later versions' East Asian 
text keeps its own.
+unsigned short version5CharSet(unsigned short charSet)
+{
+  return charSet == 0x80 || charSet == 0x81 || charSet == 0x86 || charSet == 
0x88 ? 0 : charSet;
+}
+
 unsigned getCDRVersion(char c)
 {
   if (c == 0x20)
@@ -2302,6 +2310,8 @@ void 
libcdr::CDRParser::readFont(librevenge::RVNGInputStream *input, unsigned le
   if (m_version >= 500)   // (CorelDRAW 4: the name follows the id)
   {
     fontEncoding = readU16(input);
+    if (m_version < 600)
+      fontEncoding = version5CharSet(fontEncoding);
     input->seek(14, librevenge::RVNG_SEEK_CUR);
   }
   std::vector<unsigned char> name;
@@ -3178,7 +3188,7 @@ void 
libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
         }
         unsigned short charSet = readU8(input);
         if (charSet)
-          style.m_charSet = charSet;
+          style.m_charSet = version5CharSet(charSet);
       }
       else
         input->seek(2, librevenge::RVNG_SEEK_CUR);
@@ -3349,7 +3359,7 @@ void 
libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
       }
       unsigned short charSet = readUnsignedShort(input);
       if (charSet)
-        style.m_charSet = charSet;
+        style.m_charSet = m_version < 600 ? version5CharSet(charSet) : charSet;
       if (m_version >= 600)
         input->seek(8, librevenge::RVNG_SEEK_CUR);
       style.m_fontSize = readCoordinate(input);
commit 5104cb172aa490424870ff99a35b9438a4d09ec8
Author:     A'rpi <[email protected]>
AuthorDate: Mon Nov 2 07:32:05 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:34 2026 +0100

    text: a leading line break dropped in version 16+ too
    
    Texts of CorelDRAW X6 and later files that start with a line break came
    out a line lower than meant as well (a business card's contact lines one
    line below the address beside them, a title's second line far from the
    rule above it). Checked against the files' own page previews and
    CorelDRAW.
    
    Change-Id: I192721dd5ad797229e98e48cad018b82b62ab8c7

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 211cde4..81df029 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3033,6 +3033,7 @@ void 
libcdr::CDRParser::readTxsm16(librevenge::RVNGInputStream *input)
       input->seek(1, librevenge::RVNG_SEEK_CUR); //skip the 0 ending character
       if (fitted)
         readFittedPlaces(input, charDescriptions, styles);
+      dropLeadingLineBreak(textData, charDescriptions);
 
       if (!textData.empty())
         m_collector->collectText(textId, stlId, textData, charDescriptions, 
styles);
commit 733829b048700d945a6542ecef00daabc758f427
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 21:33:57 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:33 2026 +0100

    Fountain fills: the midpoint as a third stop
    
    A two colour fill's midpoint (versions 7 and later) goes out as a stop
    there with the colours half mixed: CorelDRAW mixes them evenly on both
    sides of it (measured on its PDF exports of conical fills with midpoints
    from 1 to 99); it was ignored.
    
    Change-Id: Idbe661af887813a72d733ed24ddd0da75ee09571

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 7d60e90..c3df919 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -1011,6 +1011,22 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
             stopElement.insert("svg:offset", gradStop.m_offset, 
librevenge::RVNG_PERCENT);
             stopElement.insert("svg:stop-color", 
m_ps.getRGBColorString(gradStop.m_color));
             stops.append(stopElement);
+            // a two colour fill's midpoint (versions 7+; 0 before): the 
colours half mixed there,
+            // evenly on both sides of it (as CorelDRAW 9's PDF exports show)
+            if (gradient.m_stops.size() == 2 && &gradStop == 
&gradient.m_stops[0] && gradient.m_midPoint > 0.0
+                && gradient.m_midPoint < 1.0 && gradient.m_midPoint != 0.5)
+            {
+              const unsigned a = 
m_ps._getRGBColor(gradient.m_stops[0].m_color);
+              const unsigned b = 
m_ps._getRGBColor(gradient.m_stops[1].m_color);
+              const double at = gradient.m_stops[0].m_offset + 
gradient.m_midPoint * (gradient.m_stops[1].m_offset - 
gradient.m_stops[0].m_offset);
+              librevenge::RVNGString mixed;
+              mixed.sprintf("#%.2x%.2x%.2x", (((a >> 16) & 0xff) + ((b >> 16) 
& 0xff) + 1) / 2,
+                            (((a >> 8) & 0xff) + ((b >> 8) & 0xff) + 1) / 2, 
((a & 0xff) + (b & 0xff) + 1) / 2);
+              librevenge::RVNGPropertyList midElement;
+              midElement.insert("svg:offset", at, librevenge::RVNG_PERCENT);
+              midElement.insert("svg:stop-color", mixed);
+              stops.append(midElement);
+            }
           }
           propList.insert("libcdr:gradient-stops", stops);
         }
commit d2b639cf168fb315110cf77352193ffa497bec37
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 21:06:37 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:33 2026 +0100

    Fountain fills: their CorelDRAW type and geometry for renderers
    
    The type (linear, radial, conical, square), the angle, the centre's
    offset (both: the vertical one was not passed on), the edge pad and the
    stops as libcdr's own properties (libcdr:gradient-*): ODF has no conical
    gradient and sizes its radial and square ones otherwise, conical fills
    were drawn linear, square ones round.
    
    Change-Id: I7c02a400480e618a7d1aac5ffc3cfc276311408b

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index b85be98..7d60e90 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -991,6 +991,29 @@ void 
libcdr::CDRContentCollector::_fillProperties(librevenge::RVNGPropertyList &
           }
           propList.insert("svg:linearGradient", vec);
         }
+        // the fountain fill as CorelDRAW draws it (libcdr's own properties: 
ODF has no conical
+        // gradient, and its radial and square ones are sized otherwise): the 
type, the angle
+        // (degrees, counter-clockwise), the centre's offset and the edge pad 
(shares) and the stops
+        // from the start colour to the end colour
+        if (m_currentFillStyle.gradient.m_stops.size() > 1)
+        {
+          static const char *const types[] = { "linear", "linear", "radial", 
"conical", "square" };
+          const CDRGradient &gradient = m_currentFillStyle.gradient;
+          propList.insert("libcdr:gradient-type", types[gradient.m_type < 5 ? 
gradient.m_type : 0]);
+          propList.insert("libcdr:gradient-angle", gradient.m_angle * 180 / 
M_PI);
+          propList.insert("libcdr:gradient-center-x", gradient.m_centerXOffset 
/ 100.0);
+          propList.insert("libcdr:gradient-center-y", gradient.m_centerYOffset 
/ 100.0);
+          propList.insert("libcdr:gradient-edge", gradient.m_edgeOffset / 
100.0);
+          librevenge::RVNGPropertyListVector stops;
+          for (auto &gradStop : gradient.m_stops)
+          {
+            librevenge::RVNGPropertyList stopElement;
+            stopElement.insert("svg:offset", gradStop.m_offset, 
librevenge::RVNG_PERCENT);
+            stopElement.insert("svg:stop-color", 
m_ps.getRGBColorString(gradStop.m_color));
+            stops.append(stopElement);
+          }
+          propList.insert("libcdr:gradient-stops", stops);
+        }
         break;
       case 7: // Pattern
       case 8: // Pattern
commit a8451699f010b284c57399bc2601e96356dd4b06
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 19:10:16 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:33 2026 +0100

    CorelDRAW 2 shapes without an outline
    
    A CorelDRAW 2 (WL) outline's type 0 is no outline (as CorelDRAW 5 draws
    such files): it was a black hairline round every shape (a clip art's
    lips and bunny were outlined all over).
    
    Change-Id: I7b92d6e97650f302bf62565f61e4eeb8524187f4

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index cbe1271..211cde4 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -1291,8 +1291,9 @@ void 
libcdr::CDRParser::readWaldoOutl(librevenge::RVNGInputStream *input)
 {
   if (m_version >= 400)
     return;
+  // (0: no outline, as CorelDRAW 5 draws such files; it was a black hairline 
round every shape)
   unsigned short lineType = readU8(input);
-  lineType <<= 1;
+  lineType = lineType ? lineType << 1 : 1;
   auto lineWidth = (double)readCoordinate(input);
   double stretch = (double)readU16(input) / 100.0;
   double angle = readAngle(input);
commit 1e36ccaa10fc5c8f9c3d5d3f46ff5e3ace427697
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:36:03 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:33 2026 +0100

    CorelDRAW 5 subscripts
    
    A CorelDRAW 5 text style override's placement byte, after its font style,
    is 4 for a subscript: half the size, a fifth of the size lower (as
    CorelDRAW 9's PDF exports of such files show). It was skipped, so
    formulas' indices stood on the line at full size.
    
    Change-Id: I8c4694405e897473131640307460f47de82e82f5

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index ccfb760..cbe1271 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3184,7 +3184,12 @@ void 
libcdr::CDRParser::readTxsm5(librevenge::RVNGInputStream *input)
         setFontStyle(style, readU16(input));
       else
         input->seek(2, librevenge::RVNG_SEEK_CUR);
-      input->seek(4, librevenge::RVNG_SEEK_CUR);
+      // with the style, the characters' placement: 4 a subscript (as 
CorelDRAW 9's PDF exports show);
+      // it was skipped, so formulas' indices stood on the line at full size
+      input->seek(3, librevenge::RVNG_SEEK_CUR);
+      unsigned char placement = readU8(input);
+      if ((flag&0x02) && placement == 4)
+        style.m_subscript = true;
       if (flag&0x04)
         style.m_fontSize = readCoordinate(input);
       else
diff --git a/src/lib/CDRStylesCollector.cpp b/src/lib/CDRStylesCollector.cpp
index 813a72d..4539999 100644
--- a/src/lib/CDRStylesCollector.cpp
+++ b/src/lib/CDRStylesCollector.cpp
@@ -283,6 +283,11 @@ void libcdr::CDRStylesCollector::collectText(unsigned 
textId, unsigned styleId,
       style.overrideStyle(iter->second);
     if ((key & 0x100) && defaultCharStyle.m_fontSize > 0)
       style.m_fontSize = defaultCharStyle.m_fontSize;
+    else if (style.m_subscript)   // (the shift in the subscript's em: a fifth 
of the full size)
+    {
+      style.m_fontSize /= 2.0;
+      style.m_shiftY -= 0.4;
+    }
     return style;
   };
 
diff --git a/src/lib/CDRTypes.h b/src/lib/CDRTypes.h
index 420cef6..3f49cd6 100644
--- a/src/lib/CDRTypes.h
+++ b/src/lib/CDRTypes.h
@@ -148,6 +148,7 @@ struct CDRStyle
   unsigned m_fontItalic;   // 0: not set, 1 upright, 2 italic
   double m_shiftX, m_shiftY;   // characters moved from their place, in em (up 
positive)
   double m_rotation;   // characters turned about their place, in degrees 
(counter-clockwise)
+  bool m_subscript;    // (CorelDRAW 5) half the size, a fifth of the size 
lower
   unsigned m_align;
   double m_leftIndent, m_firstIndent, m_rightIndent;
   double m_lineSpacing;   // the line spacing: > 0 a share of the character 
height (1.0: 100%), < 0 in points, 0: not set
@@ -160,7 +161,7 @@ struct CDRStyle
   unsigned m_parentId;
   CDRStyle()
     : m_charSet((unsigned short)-1), m_fontName(),
-      m_fontSize(0.0), m_fontWeight(0), m_fontItalic(0), m_shiftX(0.0), 
m_shiftY(0.0), m_rotation(0.0), m_align(0), m_leftIndent(0.0), 
m_firstIndent(0.0),
+      m_fontSize(0.0), m_fontWeight(0), m_fontItalic(0), m_shiftX(0.0), 
m_shiftY(0.0), m_rotation(0.0), m_subscript(false), m_align(0), 
m_leftIndent(0.0), m_firstIndent(0.0),
       m_rightIndent(0.0), m_lineSpacing(0.0), m_spaceBefore(0.0), 
m_spaceAfter(0.0), m_hasParagraphSpacing(false),
       m_charSpacing(0.0), m_wordSpacing(1.0), m_hasCharSpacing(false), 
m_lineStyle(), m_fillStyle(), m_parentId(0)
   {
@@ -185,6 +186,8 @@ struct CDRStyle
       m_shiftY = override.m_shiftY;
     if (!CDR_ALMOST_ZERO(override.m_rotation))
       m_rotation = override.m_rotation;
+    if (override.m_subscript)
+      m_subscript = true;
     if (override.m_align)
       m_align = override.m_align;
     if (!CDR_ALMOST_ZERO(override.m_leftIndent) && 
!CDR_ALMOST_ZERO(override.m_firstIndent) && 
!CDR_ALMOST_ZERO(override.m_rightIndent))
commit 8c7f9f403a1eb349957b5e221a12d4ff6bdea64b
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:36:03 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:33 2026 +0100

    The Symbol font's characters
    
    The Symbol font's characters are Greek letters and signs (the symbol
    character set), whatever its font record's other field says: CorelDRAW 5's
    give 0x40 there, so a sum sign came out as an S, a mu as an m, a logic
    gate's greater-or-equal as a superscript 3.
    
    Change-Id: I740bb0c5815df13d43e534d881df3d8857bec311

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 8110eb4..ccfb760 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -2336,6 +2336,10 @@ void 
libcdr::CDRParser::readFont(librevenge::RVNGInputStream *input, unsigned le
   }
   if (!fontEncoding)
     processNameForEncoding(fontName, fontEncoding);
+  // the Symbol font's characters are Greek letters and signs: CorelDRAW 5's 
font records give
+  // another value there (0x40), so a sum sign came out as an S, a mu as an m
+  if (fontName == "Symbol")
+    fontEncoding = 0x02;
   std::map<unsigned, CDRFont>::const_iterator iter = m_fonts.find(fontId);
   // Asume that the first font with the given ID is a font
   // that we want, the others are substitution fonts. We might
commit 6e52de1604f530ae1622a04ae29f5171a75aeddc
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:25:48 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    CorelDRAW 4 texts' fill and outline
    
    A CorelDRAW 4 artistic text's characters take its object's fill and
    outline (its style's are the default text style's): a text with an outline
    and no fill came out filled black, as CorelDRAW 9's PDF export of it shows.
    collectArtisticText tells so.
    
    Change-Id: I0c8eae794dd8f72d3f0f3253e1b42ca8e93e4780

diff --git a/src/lib/CDRCollector.h b/src/lib/CDRCollector.h
index 5e39bf6..e1298e7 100644
--- a/src/lib/CDRCollector.h
+++ b/src/lib/CDRCollector.h
@@ -101,7 +101,8 @@ public:
   virtual void collectPaletteEntry(unsigned colorId, unsigned userId, const 
CDRColor &color) = 0;
   virtual void collectText(unsigned textId, unsigned styleId, const 
std::vector<unsigned char> &data,
                            const std::vector<unsigned char> &charDescriptions, 
const std::map<unsigned, CDRStyle> &styleOverrides) = 0;
-  virtual void collectArtisticText(double x, double y) = 0;
+  // objectStyle: the text object's fill and outline are its characters' 
(CorelDRAW 4)
+  virtual void collectArtisticText(double x, double y, bool objectStyle = 
false) = 0;
   virtual void collectParagraphText(double x, double y, double width, double 
height) = 0;
   virtual void collectStld(unsigned id, const CDRStyle &style) = 0;
   virtual void collectStyleId(unsigned id) = 0;
diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 08b16b0..b85be98 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -75,7 +75,7 @@ 
libcdr::CDRContentCollector::CDRContentCollector(libcdr::CDRParserState &ps, lib
   : m_painter(painter), m_isDocumentStarted(false), m_isPageProperties(false), 
m_isPageStarted(false),
     m_ignorePage(false), m_page(ps.m_pages[0]), m_pageIndex(0), 
m_currentFillStyle(), m_currentLineStyle(),
     m_spnd(0), m_currentObjectLevel(0), m_currentGroupLevel(0), 
m_currentVectLevel(0), m_currentPageLevel(0),
-    m_currentStyleId(0), m_currentImage(), m_currentImageMono(false), 
m_currentText(nullptr), m_currentBBox(), m_currentTextBox(), m_currentPath(),
+    m_currentStyleId(0), m_currentImage(), m_currentImageMono(false), 
m_currentText(nullptr), m_currentTextObjectStyle(false), m_currentBBox(), 
m_currentTextBox(), m_currentPath(),
     m_currentTransforms(), m_fillTransforms(), m_polygon(), 
m_isInPolygon(false), m_isInSpline(false),
     m_outputElementsStack(nullptr), m_contentOutputElementsStack(), 
m_fillOutputElementsStack(),
     m_outputElementsQueue(nullptr), m_contentOutputElementsQueue(), 
m_fillOutputElementsQueue(),
@@ -676,10 +676,13 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
             spanProps.insert("fo:font-weight", "bold");
           if (j.m_style.m_fontItalic == 2)
             spanProps.insert("fo:font-style", "italic");
-          if (j.m_style.m_fillStyle.fillType == 0)   // (no fill, outlined 
characters: libcdr's own, as for shapes)
+          // (a CorelDRAW 4 text: its object's fill and outline, when it has 
them: a text with an
+          // outline and no fill came out black)
+          const CDRFillStyle &fill = m_currentTextObjectStyle && 
m_currentFillStyle.fillType != (unsigned short)-1 ? m_currentFillStyle : 
j.m_style.m_fillStyle;
+          if (fill.fillType == 0)   // (no fill: libcdr's own, as for shapes)
             spanProps.insert("draw:fill", "none");
-          else if (j.m_style.m_fillStyle.fillType != (unsigned short)-1)
-            spanProps.insert("fo:color", 
m_ps.getRGBColorString(j.m_style.m_fillStyle.color1));
+          else if (fill.fillType != (unsigned short)-1)
+            spanProps.insert("fo:color", m_ps.getRGBColorString(fill.color1));
           // the character and word spacing: shares of a space's width 
(libcdr's own: ODF's
           // fo:letter-spacing is a length, and the font's space is not known 
here)
           if (!CDR_ALMOST_ZERO(j.m_style.m_charSpacing))
@@ -688,7 +691,7 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
             spanProps.insert("libcdr:word-spacing", j.m_style.m_wordSpacing, 
librevenge::RVNG_GENERIC);
           // the characters' outline (as a shape's; no ODF property for this): 
it was left out, so
           // white texts with a thin black outline melted into a light 
background
-          const CDRLineStyle &outline = j.m_style.m_lineStyle;
+          const CDRLineStyle &outline = m_currentTextObjectStyle && 
m_currentLineStyle.lineType != (unsigned short)-1 ? m_currentLineStyle : 
j.m_style.m_lineStyle;
           if (outline.lineType != (unsigned short)-1 && !(outline.lineType & 
0x1) && (outline.lineType & 0x6))
           {
             double scale = outline.lineType & 0x20 ? (scaleX > scaleY ? scaleX 
: scaleY) : 1.0;   // scale with image
@@ -719,6 +722,7 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
   m_fillTransforms = libcdr::CDRTransforms();
   m_fillOpacity = 1.0;
   m_currentText = nullptr;
+  m_currentTextObjectStyle = false;
 }
 
 void libcdr::CDRContentCollector::collectTransform(const CDRTransforms 
&transforms, bool considerGroupTransform)
@@ -1509,8 +1513,9 @@ void 
libcdr::CDRContentCollector::collectVectorPattern(unsigned id, const librev
 #endif
 }
 
-void libcdr::CDRContentCollector::collectArtisticText(double x, double y)
+void libcdr::CDRContentCollector::collectArtisticText(double x, double y, bool 
objectStyle)
 {
+  m_currentTextObjectStyle = objectStyle;
   m_currentTextBox = CDRBox(x, y, x, y);
   m_currentBBox.m_w *= 2.0;
   std::map<unsigned, std::vector<CDRTextLine> >::const_iterator iter = 
m_ps.m_texts.find(m_spnd);
diff --git a/src/lib/CDRContentCollector.h b/src/lib/CDRContentCollector.h
index b4ae0a8..6ba7ac5 100644
--- a/src/lib/CDRContentCollector.h
+++ b/src/lib/CDRContentCollector.h
@@ -67,7 +67,7 @@ public:
   void collectPaletteEntry(unsigned, unsigned, const CDRColor &) override {}
   void collectText(unsigned, unsigned, const std::vector<unsigned char> &,
                    const std::vector<unsigned char> &, const 
std::map<unsigned, CDRStyle> &) override {}
-  void collectArtisticText(double x, double y) override;
+  void collectArtisticText(double x, double y, bool objectStyle = false) 
override;
   void collectParagraphText(double x, double y, double width, double height) 
override;
   void collectStld(unsigned, const CDRStyle &) override {}
   void collectStyleId(unsigned styleId) override;
@@ -120,6 +120,7 @@ private:
   CDRImage m_currentImage;
   bool m_currentImageMono;   // a 1-bit bitmap (see _monoImage)
   const std::vector<CDRTextLine> *m_currentText;
+  bool m_currentTextObjectStyle;   // its characters take the object's fill 
and outline (see collectArtisticText)
   CDRBox m_currentBBox;
   CDRBox m_currentTextBox;
 
diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index e493bf6..8110eb4 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3436,7 +3436,7 @@ void 
libcdr::CDRParser::readArtisticText4(librevenge::RVNGInputStream *input, un
   if (!textData.empty())
     m_collector->collectText(textId, styleId, textData, charDescriptions, 
std::map<unsigned, CDRStyle>());
   m_collector->collectSpnd(textId);
-  m_collector->collectArtisticText(0.0, 0.0);
+  m_collector->collectArtisticText(0.0, 0.0, true);
 }
 
 // The document's embedded (OLE) objects: an OLE storage with an "Embedding 
<n>" storage each. The
diff --git a/src/lib/CDRStylesCollector.h b/src/lib/CDRStylesCollector.h
index ef644e3..d7350fb 100644
--- a/src/lib/CDRStylesCollector.h
+++ b/src/lib/CDRStylesCollector.h
@@ -65,7 +65,7 @@ public:
   void collectPaletteEntry(unsigned colorId, unsigned userId, const CDRColor 
&color) override;
   void collectText(unsigned textId, unsigned styleId, const 
std::vector<unsigned char> &data,
                    const std::vector<unsigned char> &charDescriptions, const 
std::map<unsigned, CDRStyle> &styleOverrides) override;
-  void collectArtisticText(double, double) override {}
+  void collectArtisticText(double, double, bool) override {}
   void collectParagraphText(double, double, double, double) override {}
   void collectStld(unsigned id, const CDRStyle &style) override;
   void collectStyleId(unsigned) override {}
commit 49995fb0fb87b4ce1bb39ed6b4860ac4763e0017
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:25:47 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    Texts without a fill
    
    A text whose characters have no fill (only their outline: an engraving's
    lettering) gives its spans draw:fill none, as a shape does, instead of no
    colour at all: a viewer filled them black.
    
    Change-Id: I2eb5fa3da97f6da2c74bb80e607f11c4d484726b

diff --git a/src/lib/CDRContentCollector.cpp b/src/lib/CDRContentCollector.cpp
index 13ab7dd..08b16b0 100644
--- a/src/lib/CDRContentCollector.cpp
+++ b/src/lib/CDRContentCollector.cpp
@@ -676,7 +676,9 @@ void libcdr::CDRContentCollector::_flushCurrentPath()
             spanProps.insert("fo:font-weight", "bold");
           if (j.m_style.m_fontItalic == 2)
             spanProps.insert("fo:font-style", "italic");
-          if (j.m_style.m_fillStyle.fillType != (unsigned short)-1)
+          if (j.m_style.m_fillStyle.fillType == 0)   // (no fill, outlined 
characters: libcdr's own, as for shapes)
+            spanProps.insert("draw:fill", "none");
+          else if (j.m_style.m_fillStyle.fillType != (unsigned short)-1)
             spanProps.insert("fo:color", 
m_ps.getRGBColorString(j.m_style.m_fillStyle.color1));
           // the character and word spacing: shares of a space's width 
(libcdr's own: ODF's
           // fo:letter-spacing is a length, and the font's space is not known 
here)
commit 1d9ee9662c12a7d1c2b5e38c5f92a857f14d84a7
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 18:15:35 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    CorelDRAW 4 font styles
    
    A CorelDRAW 4 style's font style is 1 normal, 2 bold, 4 italic (as
    CorelDRAW 9's PDF exports of such files show), not CorelDRAW 5's style
    word: bold headings and italic names came out normal.
    
    Change-Id: I14cf0923a74f1f1558c244f1707fec3297e1af42

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 6b24093..e493bf6 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3342,7 +3342,16 @@ void 
libcdr::CDRParser::readStyd(librevenge::RVNGInputStream *input)
       if (m_version >= 600)
         input->seek(8, librevenge::RVNG_SEEK_CUR);
       style.m_fontSize = readCoordinate(input);
-      if (m_version < 600)   // the font style (see setFontStyle)
+      if (m_version < 500)   // CorelDRAW 4's font style: 1 normal, 2 bold, 4 
italic (as its PDF exports
+      {                       // show; its bold headings were not bold)
+        unsigned short fontStyle = readU16(input);
+        if (fontStyle == 1 || fontStyle == 2 || fontStyle == 4)
+        {
+          style.m_fontWeight = fontStyle == 2 ? 700 : 400;
+          style.m_fontItalic = fontStyle == 4 ? 2 : 1;
+        }
+      }
+      else if (m_version < 600)   // the font style (see setFontStyle)
         setFontStyle(style, readU16(input));
       break;
     }
commit 9506e996936f57bbcf767472beb19100fe960be1
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 15:44:26 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    CorelDRAW 2/3 group transforms
    
    A group's transform is the last 24 bytes of the 0x8c part of its more data
    record; that part may have 10 more bytes before them or none, but they
    were always read from 0x26: such a group was stretched out of the page (a
    drawing came out as a line). A group whose record is missing keeps no
    transform instead of one read from the wrong place.
    
    Change-Id: I341f2dbe37f9ca64f8304739dd0f42d1eea6179c

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index 811ca3f..6b24093 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -366,19 +366,27 @@ bool 
libcdr::CDRParser::parseWaldo(librevenge::RVNGInputStream *input)
       double y1 = readCoordinate(input);
       unsigned short flags = readU16(input);
       CDRTransform trafo;
-      if (moreDataID)
-      {
-        std::map<unsigned, WaldoRecordInfo>::const_iterator iter7 = 
records7.find(moreDataID);
-        if (iter7 != records7.end())
-          input->seek(iter7->second.offset, librevenge::RVNG_SEEK_SET);
-        input->seek(0x26, librevenge::RVNG_SEEK_CUR);
-        double v0 = readFixedPoint(input);
-        double v1 = readFixedPoint(input);
-        double v2 = readFixedPoint(input) / 1000.0;
-        double v3 = readFixedPoint(input);
-        double v4 = readFixedPoint(input);
-        double v5 = readFixedPoint(input) / 1000.0;
-        trafo = CDRTransform(v0, v1, v2, v3, v4, v5);
+      // the group's transform: the last 24 bytes of the 0x8c part of its more 
data record (that
+      // part has 10 more bytes before them, or none: they were always read 
from 0x26, so such a
+      // group was stretched out of the page; a missing record left them read 
from the wrong place)
+      std::map<unsigned, WaldoRecordInfo>::const_iterator iter7 = 
records7.find(moreDataID);
+      if (moreDataID && iter7 != records7.end())
+      {
+        input->seek(iter7->second.offset + 0x12, librevenge::RVNG_SEEK_SET);
+        unsigned short tag = readU16(input);
+        input->seek(4, librevenge::RVNG_SEEK_CUR);
+        unsigned partLength = readU32(input);
+        if (tag == 0x8c && partLength >= 24 && partLength <= 0x100)
+        {
+          input->seek(partLength - 24, librevenge::RVNG_SEEK_CUR);
+          double v0 = readFixedPoint(input);
+          double v1 = readFixedPoint(input);
+          double v2 = readFixedPoint(input) / 1000.0;
+          double v3 = readFixedPoint(input);
+          double v4 = readFixedPoint(input);
+          double v5 = readFixedPoint(input) / 1000.0;
+          trafo = CDRTransform(v0, v1, v2, v3, v4, v5);
+        }
       }
       records1[record.id] = WaldoRecordType1(record.id, next, previous, child, 
parent, flags, x0, y0, x1, y1, trafo);
     }
commit 194446b37dc3cd129b5bf0d436354029fad92f48
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 15:27:39 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    Text outlines from version 16
    
    An X6+ style string's character outline was always given line type 0,
    which is none to the content collector: no text outline showed. An outline
    with a type (0: solid) and a width is drawn now; one without a type (width
    0) is none.
    
    Change-Id: Ic170df1d67918faf2c8853f9cd68811dcb8d68e5

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index bb85f92..811ca3f 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -3574,8 +3574,11 @@ void 
libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u
 
     if (!!pt.get_child_optional("character.outline"))
     {
-      style.m_lineStyle.lineType = 0;
+      // an outline with a type (0: solid) and a width is drawn, one without 
(width 0) is none;
+      // all were of type 0 here, which is none to the content collector (no 
text outline showed)
+      boost::optional<unsigned> lineType = 
pt.get_optional<unsigned>("character.outline.type");
       boost::optional<unsigned> lineWidth = 
pt.get_optional<unsigned>("character.outline.width");
+      style.m_lineStyle.lineType = !lineType || !lineWidth || !lineWidth.get() 
? 1 : lineType.get() == 0 ? 2 : 0;
       if (!!lineWidth)
         style.m_lineStyle.lineWidth = (double)lineWidth.get() / 254000.0;
       boost::optional<std::string> color = 
pt.get_optional<std::string>("character.outline.color");
commit 41d41e838de485000d79ce1826391c5b67488188
Author:     A'rpi <[email protected]>
AuthorDate: Sun Nov 1 15:27:39 2026 +0100
Commit:     Fridrich Strba <[email protected]>
CommitDate: Wed Nov 4 13:37:32 2026 +0100

    Texts fitted to a path from version 16
    
    From CorelDRAW X6 on a fitted text's characters' places follow its text as
    in versions 8 to 15 (24 bytes a character; the rotation from 0 to 360
    degrees): read there too, by one function now. Such texts came out on a
    straight line beside their path.
    
    Change-Id: I5ac85c770274658540410477df0e357d72876895

diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp
index e71ec2c..bb85f92 100644
--- a/src/lib/CDRParser.cpp
+++ b/src/lib/CDRParser.cpp
@@ -250,6 +250,40 @@ void dropLeadingLineBreak(std::vector<unsigned char> 
&textData, std::vector<unsi
   charDescriptions.erase(charDescriptions.begin());
 }
 
+// A text fitted to a path: each character's place, 24 bytes a character after 
the text (its shift
+// from its place in 1/100 em, up positive; its rotation in 1/1000000 degree, 
counter-clockwise; 12
+// more bytes), as CorelDRAW laid it on the path. They become each character's 
own style (the
+// styles are numbered in a byte: up to 127 of them). They were skipped: the 
texts fitted to a
+// circle (a seal's lettering) came out on a straight line over it.
+void readFittedPlaces(librevenge::RVNGInputStream *input, std::vector<unsigned 
char> &charDescriptions,
+                      std::map<unsigned, libcdr::CDRStyle> &styles)
+{
+  const unsigned long numChars = charDescriptions.size();
+  if (styles.size() + numChars > 127 || libcdr::getRemainingLength(input) < 24 
* numChars)
+    return;
+  const unsigned firstKey = 2 * (unsigned)styles.size();
+  for (unsigned long i = 0; i < numChars; ++i)
+  {
+    int shiftX = libcdr::readS32(input);
+    int shiftY = libcdr::readS32(input);
+    int rotation = libcdr::readS32(input);
+    input->seek(12, librevenge::RVNG_SEEK_CUR);
+    libcdr::CDRStyle style;
+    auto iter = styles.find(charDescriptions[i] & 0xfe);
+    if (iter != styles.end())
+      style = iter->second;
+    style.m_shiftX = shiftX / 100.0;
+    style.m_shiftY = shiftY / 100.0;
+    style.m_rotation = rotation / 1000000.0;
+    unsigned key = firstKey + 2 * (unsigned)i;
+    styles[key] = style;
+    charDescriptions[i] = (unsigned char)(key | (charDescriptions[i] & 0x01));
+  }
+  // left aligned: the places are from the text's origin, its placement on the 
path in them
+  // (the paragraph takes its alignment from the text's first run, of style 0)
+  styles[0].m_align = 1;
+}
+
 } // anonymous namespace
 
 libcdr::CDRParser::CDRParser(const 
std::vector<std::unique_ptr<librevenge::RVNGInputStream>> &externalStreams, 
libcdr::CDRCollector *collector)
@@ -2853,35 +2887,8 @@ void 
libcdr::CDRParser::readTxsm(librevenge::RVNGInputStream *input, unsigned le
       if (numBytesRead)
         memcpy(&textData[0], buffer, numBytesRead);
       input->seek(1, librevenge::RVNG_SEEK_CUR); //skip the 0 ending character
-      // a text fitted to a path: each character's place, 24 bytes a character 
(its shift from its
-      // place in 1/100 em, up positive; its rotation in 1/1000000 degree, 
counter-clockwise; 12
-      // more bytes), as CorelDRAW laid it on the path. They become each 
character's own style
-      // (the styles are numbered in a byte: up to 127 of them). They were 
skipped: the texts
-      // fitted to a circle (a seal's lettering) came out on a straight line 
over it.
-      if (fitted && styles.size() + numChars <= 127 && 
getRemainingLength(input) >= 24 * numChars)
-      {
-        const unsigned firstKey = 2 * (unsigned)styles.size();
-        for (unsigned long i = 0; i < numChars; ++i)
-        {
-          int shiftX = readS32(input);
-          int shiftY = readS32(input);
-          int rotation = readS32(input);
-          input->seek(12, librevenge::RVNG_SEEK_CUR);
-          CDRStyle style;
-          auto iter = styles.find(charDescriptions[i] & 0xfe);
-          if (iter != styles.end())
-            style = iter->second;
-          style.m_shiftX = shiftX / 100.0;
-          style.m_shiftY = shiftY / 100.0;
-          style.m_rotation = rotation / 1000000.0;
-          unsigned key = firstKey + 2 * (unsigned)i;
-          styles[key] = style;
-          charDescriptions[i] = (unsigned char)(key | (charDescriptions[i] & 
0x01));
-        }
-        // left aligned: the places are from the text's origin, its placement 
on the path in them
-        // (the paragraph takes its alignment from the text's first run, of 
style 0)
-e 
... etc. - the rest is truncated

Reply via email to