![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Svg wrapper with a caption text field
Hi
A brand new plugin allows us to create svg wrappers with Sigil. It's the same technique as the one used by Calibre for cover pages. However as it applies for any image we may find in the text, one naturally thinks as to how make it work with a caption. This question is about how to insert (integrate?) inside a svg wrapper a text field containing a caption so as the two fit together in the same page. Rationale When one adds images to one EPUB, many of them have captions. and it has always been tricky to find the right balance and be confident that the caption will be included with the image in the displayed page. The current situation is not a happy one: some trust the engine (height: auto, width:auto), some trust the CSS (max-width... and/or page-break-inside: avoid), some others make deep calculations (width:63.5%; ) others even insert the image and its caption in a two cells frame, what is sure is that everybody is praying God. ![]() If a svg all-in-one solution could be found, there would be a good chance that the bundle (image + caption) would stay together. That would be a big step forward for humanity. I tried to fiddle a little with the code. One should maybe add something like that somewhere, maybe by tweaking the viewbox to add a kind of lower stripe? Code:
<text text-anchor="middle" x="50%" y="40" style="fill:black; font-size:25px; font-family:serif;font-style:italic;">Caption</text> Please find enclosed an EPUB2 test file with two images of very different size (without caption!) to play with. Last edited by roger64; 01-29-2016 at 08:47 PM. |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Be aware that on a lot of readers (all?) based on ADE will not honor text-anchor="middle" in SVG. See also this thread: https://www.mobileread.com/forums/sho...d.php?t=190530
|
![]() |
![]() |
![]() |
#3 |
Interested in the matter
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
I use a standard wrapper for all the covers (and other images with text) of Verne's e-books that I upload to MRB. Look at:
https://www.mobileread.com/forums/sea...rchid=10365787 Specifically this cover has text above and below the image. Look at: https://www.mobileread.com/forums/sho...d.php?t=268249 Playing with the parameters, you can make the image with text that you want. The wrapper works perfectly in ADE Last edited by jbacelar; 01-30-2016 at 03:20 AM. |
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
@jbacelar
I am impressed by all your works! and you translate too? ![]() So your cover is pretty interesting and exactly to the point. Something definitely can be done. I understand we can only insert text line by line and that a block of text is not allowed. For the image, could you give some practical advice about their size? Should they have a standard size? do you manage to adapt to bigger sizes or is there a need to scale them before mixing them with text? @Toxaris The referenced thread is over three years old. With incoming EPUB3, the svg support must have improved everywhere. Last edited by roger64; 01-30-2016 at 04:30 AM. |
![]() |
![]() |
![]() |
#5 | |||
Interested in the matter
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
Quote:
![]() Quote:
![]() Quote:
|
|||
![]() |
![]() |
![]() |
#6 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Quote:
Now we have to think how to automate it. The general use would be: image on top, caption down (some lines). I think the user could be offered a choice of how many lines of text he needs for the caption, and according to that the image would take more or less height. Well, I am not the developer... ![]() I will prepare my images accordingly, one with a short caption, another one with a longer one and God will decide. ![]() |
|
![]() |
![]() |
![]() |
#7 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
What you want is quite easy to get. I will give you an example: 1. Suppose that your image has a width of 2000px and a height of 3008px. According to that, you defined the "viewbox" of the svg wrapper as: viewBox="0 0 2000 3008" 2. Now you want to add a caption to that image. The first thing you have to do is to modify the size of the viewbox, so that it will be a bit larger. Let's say that our new viewBox definition will be: viewBox="0 0 2000 3150" 3. The next step is to add the following declaration inside the svg wrapper: Code:
<text x="1000" y="3120" text-anchor="middle" font-size="100" font-family="sans-serif" font-weight="bold">YOUR CAPTION HERE</text> As you can see, I set x="1000" instead of x="50%" because "%" is not acepted by some rendering engines. And as we want the caption centered, and the image has a width of 2000px, then we must use x="1000". Then you see y="3120". This is the bottom margin of the caption. As we set a height -in wiewBox- of 3150, "y" can't be bigger than "3150". And since we are using a value of 3120, that means that below the caption, we'll have a blank space of 3150 - 3120 = 30px. Finally, since the height of the image is 3008px, and the bottom margin of the caption is 3120 (according to this example), we should use a font-size lower than 3120 - 3008 = 112px. In the example, I'm using a font-size of 100px, that means that before the caption we'll have a blank space of 12px (3120 - 100 = 3020; 3020 - 3008 = 12). 4. To end all; add to the <body> tag the style "margin:0" (so, you'll have <body style="margin:0"> That's all. I attach your epub with some modifications so you can understand better the code. Regards Rubén PS: As you can see, instead of using style="font-size:100; font-family: sans-serif; font-weight:bold", I'm using font-size="100" font-family="sans-serif" font-weight="bold"; that is because Kindle has issues with the first form of defining styles with svg images and text. If you are not going to use Kindle anyway, you can use any of both way of declaring styles. Last edited by RbnJrg; 01-30-2016 at 12:01 PM. |
|
![]() |
![]() |
![]() |
#8 |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Interesting thread. Thank you all!
Por mi parte (that's the only Spanish I know), I avoid all this by incorporating the caption into the preceding paragraph when it's absolutely necessary that the reader have the information in his mind while looking at the image. |
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
|
Hi Rubén
Thanks for your explanations (also for practical advice like the one for not using %) and of course your sample. We now have a choice between two solutions. When I tried to set it up, I had been confused by the view box. You and jbacelar make it look simple! I have no doubt that one of the two will soon be implemented. It will be developer's choice. y muchas gracias para nuestros dos amigos (a bit longer than Notjohn) ![]() Last edited by roger64; 01-30-2016 at 08:18 AM. Reason: amigos |
![]() |
![]() |
![]() |
#10 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Quote:
It doesn't break the SVG, it just won't center the text IIRC. |
|
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
You are welcome
![]() Quote:
Regards |
|
![]() |
![]() |
![]() |
#12 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
Regards Rubén |
|
![]() |
![]() |
![]() |
#13 | |
mostly an observer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,518
Karma: 987654
Join Date: Dec 2012
Device: Kindle
|
Quote:
To be sure, I'm generally uploading photographs, not complicated graphs etc, and I'm generally writing about historical stuff, not maths or technology that requires a lecturer with a pointer to explain what's being shown. |
|
![]() |
![]() |
![]() |
#14 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Scaling images with SVG wrapper | Pablo | ePub | 4 | 07-07-2015 01:44 PM |
Svg wrapper and image resizing | Nabodita | ePub | 24 | 05-02-2014 12:21 AM |
Need Example SVG wrapper including caption | GrannyGrump | ePub | 30 | 11-06-2013 03:20 AM |
Adding an SVG Wrapper | ghostyjack | Sigil | 16 | 06-15-2013 05:13 AM |
An Issue about a SVG wrapper | RbnJrg | Kindle Formats | 29 | 06-10-2013 08:11 PM |