Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > ePub

Notices

Reply
 
Thread Tools Search this Thread
Old 04-03-2015, 11:24 PM   #1
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,749
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
images and captions

What's the best way to keep a caption with an image such that the caption never ends up on another screen from the image?
JSWolf is offline   Reply With Quote
Old 04-04-2015, 12:40 AM   #2
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
If I needed to do that, I'd probably draw the bitmap and the caption text using SVG in a single "image", and then use the usual techniques for scaling the SVG image up to the size of the screen.

Caveat: With this approach, you probably must include at least one embedded font and use it for all your captions if you want the rendering to be even halfway consistent across readers. I mean, there are ways to embed arbitrary blobs of HTML in SVG, which could in theory allow you to let the reader determine the sizing and style, but IIRC, that feature isn't very well supported.
dgatwood is offline   Reply With Quote
Old 04-04-2015, 04:23 AM   #3
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,749
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
I don't need it to be consistent. I just need it to drop both the image and the caption yto the next screen if the both don't fit in the space left on the screen. I'm hoping to find a way that's not having to use SVG to draw the caption. I want the caption to be in whatever the body font is.
JSWolf is offline   Reply With Quote
Old 04-04-2015, 06:49 AM   #4
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Easy:

Code:
<div style="page-break-inside: avoid">
<img src="snowball.jpg" alt=""/>
<p>A cool image</p>
</div>
and get the readers to properly support it

Since I'm afraid ADE and relatives don't obey "page-break-inside", dgatwood's suggestion is probably the best that you can expect.

Personally, I code it as I showed, I don't like to use workarounds for specific software bugs and limitations. (I'm still hoping for a decently compliant reader some time in the future.)
Jellby is offline   Reply With Quote
Old 04-04-2015, 04:49 PM   #5
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by JSWolf View Post
I don't need it to be consistent. I just need it to drop both the image and the caption yto the next screen if the both don't fit in the space left on the screen. I'm hoping to find a way that's not having to use SVG to draw the caption. I want the caption to be in whatever the body font is.
You can use SVG and still to have the caption in whatever the body font is; watch this post:

https://www.mobileread.com/forums/sho...92&postcount=4

The caption will be in the main font (also you could use a custom font if you embed it). In that post I don't set a font-size but is possible to do it.

Regards
RbnJrg is offline   Reply With Quote
Old 04-04-2015, 05:29 PM   #6
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by Jellby View Post
Easy:

Code:
<div style="page-break-inside: avoid">
<img src="snowball.jpg" alt=""/>
<p>A cool image</p>
</div>
and get the readers to properly support it

Since I'm afraid ADE and relatives don't obey "page-break-inside", dgatwood's suggestion is probably the best that you can expect.
Not just ADE. Even WebKit doesn't support pbi:avoid unless they've fixed it in the last year or so. They support pbb:always and pba:always, but they ignore pbi entirely. I'm pretty sure I filed a bug about it almost a decade ago, and it got duped to a bug from many years earlier. In other words, don't count on that ever working right.


Quote:
Originally Posted by RbnJrg View Post
You can use SVG and still to have the caption in whatever the body font is; watch this post:

https://www.mobileread.com/forums/sho...92&postcount=4
The problem potentially comes when you try to deploy on Kindle, where the base font size isn't necessarily 12 point. There's a distinct possibility that the text would be rendered either unusably small or so large that it gets clipped by the viewBox.

I suppose you could remove the viewBox so that everything gets sized to the largest thing in the SVG image (which might be the text), but I'm not sure what other problems that could cause.

I'm not saying it won't work if you don't specify an explicit font and size, but in the back of my head, it sets off warning bells.

Last edited by dgatwood; 04-04-2015 at 05:31 PM.
dgatwood is offline   Reply With Quote
Old 04-05-2015, 05:51 AM   #7
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by dgatwood View Post
The problem potentially comes when you try to deploy on Kindle, where the base font size isn't necessarily 12 point.
You can set any font-size for the caption and Kindle (with .kf8 support) wil accept it by using the font-atribute (you mustn't use css styles). In the Kindle Publishing Guidelines you can read the following:

Code:
3.6.10 Image Guideline #10:
Displaying Text Correctly within SVG
To display text correctly within an SVG, use the
font-size attribute for <text> inside the SVG.

Example
<html>
<body>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<text x="20" y="20" font-size="20" fill="red">svg text sample</text>
</svg>
</body>
</html>
So, for example the base font-size could be 1em (or whatever) and the caption to have a font-size of 8pt or 10pt.

Regards
Rubén

Last edited by RbnJrg; 04-05-2015 at 05:54 AM.
RbnJrg is offline   Reply With Quote
Old 04-05-2015, 08:58 PM   #8
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by RbnJrg View Post
You can set any font-size for the caption and Kindle (with .kf8 support) wil accept it by using the font-atribute (you mustn't use css styles). In the Kindle Publishing Guidelines you can read the following:
I think you missed my point. You can't guarantee what fonts are going to be available on the device, and different fonts render at different sizes. And when you're printing those fonts into a fixed-size box, the odds of them getting clipped are pretty good.
dgatwood is offline   Reply With Quote
Old 04-05-2015, 10:46 PM   #9
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by dgatwood View Post
I think you missed my point. You can't guarantee what fonts are going to be available on the device, and different fonts render at different sizes. And when you're printing those fonts into a fixed-size box, the odds of them getting clipped are pretty good.
On Kindle we can know what fonts are available. And if one want to be sure about the font used in the caption, we can embed a custom font. But with a correct layout of the svg wrapper, you can be sure that the caption will be always ok. Finally, if we are talking about Kindle, then there is another method (this one only works on Kindle and iPad -maybe also in Kobo-); image and caption will remain in the same page, ALWAYS, no matter the font-size (the user can change the font-size at will and the caption will remain with the image). Read this post:

https://www.mobileread.com/forums/sho...36&postcount=4

Again, this method only works for Kindle with support for .kf8.

Regards
Rubén
RbnJrg is offline   Reply With Quote
Old 04-06-2015, 02:41 AM   #10
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
But this is the ePub forum, so Kindle (and iPad, if you mean iBooks) are secondary
Jellby is offline   Reply With Quote
Old 04-06-2015, 06:03 AM   #11
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,764
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by Jellby View Post
But this is the ePub forum, so Kindle (and iPad, if you mean iBooks) are secondary
Yes, you are right, but dgatwood has doubts about using SVG on Kindle:

Quote:
The problem potentially comes when you try to deploy on Kindle, where the base font size isn't necessarily 12 point.
But is true, I mustn't bring the topic at this subforum
RbnJrg is offline   Reply With Quote
Old 04-06-2015, 12:11 PM   #12
DaleDe
Grand Sorcerer
DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.DaleDe ought to be getting tired of karma fortunes by now.
 
DaleDe's Avatar
 
Posts: 11,470
Karma: 13095790
Join Date: Aug 2007
Location: Grass Valley, CA
Device: EB 1150, EZ Reader, Literati, iPad 2 & Air 2, iPhone 7
Quote:
Originally Posted by JSWolf View Post
What's the best way to keep a caption with an image such that the caption never ends up on another screen from the image?
Use SVG and make a big enough viewbox that the caption is inside the area.

Dale
DaleDe is offline   Reply With Quote
Old 04-07-2015, 05:23 AM   #13
Ghitulescu
Fanatic
Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.Ghitulescu ought to be getting tired of karma fortunes by now.
 
Posts: 563
Karma: 403106
Join Date: Aug 2014
Device: PRS-T1
Quote:
Originally Posted by Jellby View Post
Easy:

Code:
<div style="page-break-inside: avoid">
<img src="snowball.jpg" alt=""/>
<p>A cool image</p>
</div>
and get the readers to properly support it
I believe that would assume that the physical size of the screen would allow for a full display of the image and the text beneath.
If the image size is greater that what the screen can accommodate what happens depends entirely on the Reader.

It may work with widow/orphan attributes (again provided the physical size allows it), of course where supported.

Or one can make a floating block with display: inline-block eg in a div comprising both items. Again, where it is supported.
Ghitulescu is offline   Reply With Quote
Old 04-07-2015, 11:27 AM   #14
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 7,549
Karma: 19500001
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
Quote:
Originally Posted by Ghitulescu View Post
Or one can make a floating block with display: inline-block eg in a div comprising both items. Again, where it is supported.
Yes, the difference is page-break-inside is a required property, and inline-block isn't. Readers that don't support the former are non-compliant, those that don't support the latter are probably non-compliant too, but for other reasons. However, it's probably more likely to find support for inline-block, so maybe one should try this.
Jellby is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cracked.com: Missing images and small image captions damien18 Recipes 4 11-30-2014 11:14 PM
Best way to format images and captions in EPUB silviolorusso ePub 6 05-03-2013 07:51 AM
Epubs: keeping images and captions together verydeepwater ePub 13 12-02-2012 04:33 PM
Images and captions in epub Balaji Workshop 3 08-19-2011 08:00 AM
captions and images together detede Apple Devices 11 06-14-2010 09:00 PM


All times are GMT -4. The time now is 04:16 PM.


MobileRead.com is a privately owned, operated and funded community.