View Single Post
Old 03-22-2024, 04:13 PM   #1
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 59
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
unwanted changes of SVG code

I met epubs, in which there are used inline svg images for formating text of publisher book pages.

These images, during conversion in Calibre, are not converted correctly. When converting to docx/mobi (et cetera), conversion output of images is png, in which texts defined in svg are present – but are very dificcult to read because of their size, reduced into fractions of pixels...

This not desirable behaviour was spoted for plenty of years, without the prospect of a solution. But now, accidentally, occurs conversion epub>epub... Output epub shows the same appearance of svg images as images converted to png. Now there is posibility to see the reason, when tracking changes between input and output svg:

source inline svg:
Code:
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100%" height="100%" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 15849.6 21132.8"
 xmlns:xlink="http://www.w3.org/1999/xlink"
>
 <defs>
  <style type="text/css">
   <![CDATA[
    .fil0 {fill:#2B2A29}
    .fnt1 {font-weight:bold;font-size:493.89px;font-family:'MIRobokat'}
    .fnt0 {font-weight:normal;font-size:635px;font-family:'MIRobokat'}
   ]]>
  </style>
 </defs>
 <g id="Vrstva_x0020_1">
  
  <text x="5218.93" y="6709.26"  class="fil0 fnt0">KAREL ČAPEK</text>
  <text x="5265.25" y="7298.9"  class="fil0 fnt1">VÁLKA S MLOKY</text>
 </g>
</svg>
after conversion epub>epub
Code:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="100%" height="100%" version="1.1" viewBox="0 0 15849.6 21132.8" class="calibre2">
 <defs>
  <style type="text/css" class="calibre3">
   
    .fil0 {fill:#2B2A29}
    .fnt1 {font-weight:bold;font-size:493.89px;font-family:'MIRobokat'}
    .fnt0 {font-weight:normal;font-size:635px;font-family:'MIRobokat'}
   
  </style>
 </defs>
 <g id="Vrstva_x0020_1">
  
  <text x="5218.93" y="6709.26">KAREL ČAPEK</text>
  <text x="5265.25" y="7298.9">VÁLKA S MLOKY</text>
 </g>
</svg>
detected changes:
- removed some properties of svg element
- added class="calibre2" (height: auto; width: auto; ) to svg element
- added class="calibre3" (display: none; ) to style element
- removed CDATA section around style definition
- removed style reference from text elements

(Especially losing the connection to the styles makes the conversion output completely unreadable.)

My question is: Are such changes (or in general any changes...) of svg intentional? And is there possibility to avoid them?

Last edited by quinta@ebf.cz; 03-22-2024 at 06:48 PM.
quinta@ebf.cz is offline   Reply With Quote