![]() |
#1 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 580
Karma: 810184
Join Date: Sep 2010
Location: Norway
Device: prs-t1, tablet, Nook Simple, assorted kindles, iPad
|
Text with fixed proportional size
...I know, inconsistent title. What I wonder is if it is possible to make a given word always fill a certain proportion of the display?
Something analogous to Code:
img {width:80%} It doesn't seem possible without using SVG, but maybe somebody has a CSS trick up their sleeve? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
Why not just use SVG?
|
![]() |
![]() |
![]() |
#3 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
https://www.mobileread.com/forums/sho...06&postcount=7 Hmmm, the problem is the text, not the box where is going to be the text. You can make a box in order to fill always, let's say, 80% width and 25% height. Maybe using a font-size measured in "vw" (or in "vh") (let's say: font-size: 5vw or font-size: 8vh) could do the trick. But I don't know if works in all ereaders (more probably not ![]() Also I can think in a solution that uses svg partially. For example: In your stylesheet.css file write: Code:
html { height: 100%; /* very important */ margin: 0; } body { height: 100%; /* very important */ margin: 0; } .container { display: table; height: 25%; width: 80%; text-indent: 0; text-align: center; vertical-align: middle; margin: 0 auto; /* or margin: 0 10%; */ border: 2px solid black; } .content { display: table-cell; vertical-align: middle; background: url("../Images/Image1.svg") center center no-repeat; background-size: contain; height: 100%; } Code:
<div class="container"> <p class="content"> </p> </div> Code:
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="80" height="20" id="svg3010"> <text x="40" y="12.5" text-anchor="middle" fill="red" style="font-size: 10px; font-weight: bold">This is a title</text> </svg> and here another screenshoot (with another size): Below you can see the respective ePub. Of course, this kind of things doesn't work in ADE ![]() Regards Rubén Last edited by RbnJrg; 11-26-2013 at 09:05 AM. |
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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
|
Try this:
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="80%" height="50%" viewBox="0 0 1000 300" xmlns="http://www.w3.org/2000/svg" version="1.1"> <desc>Example text01 - 'Hello, out there' in blue</desc> <text x="50" y="50" font-family="Verdana" font-size="50px" fill="blue" > Hello, out there </text> </svg> The pixels are scaled to fit the width and height settings. |
![]() |
![]() |
![]() |
#5 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
But in an PRS-300, it doesn't respond to text size settings. But in ADE it does. Interesting technique.
|
![]() |
![]() |
![]() |
#6 |
Fanatic
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 580
Karma: 810184
Join Date: Sep 2010
Location: Norway
Device: prs-t1, tablet, Nook Simple, assorted kindles, iPad
|
Thanks for all your replies.
As I suspected, SVG seems to be the only way. My slight reservation has been due to mrmikel's observation for the PRS-300, which probably also is true for the PRS-505, which also has a rather patchy SVG implementation. If I am to follow the SVG path, then I'm sorely tempted to convert the text to paths in Inkscape or similar, and stop worrying about font handling in different readers' SVG implementations. BTW, does anybody know of a command-line method in linux for converting a string in a given font to an svg file? |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,634
Karma: 8566337
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
This solution (with partial use of SVG) also works in ADE:
In the stylesheet: Code:
html { height: 100%; /* very important */ margin: 0; } body { height: 100%; /* very important */ margin: 0; } .container { height: 25%; width: 80%; text-indent: 0; text-align: center; margin: 0 10%; background: url("../Images/Image1.svg") center center no-repeat; background-size: contain; border: 2px solid blue; } Code:
<div class="container"> </div> Code:
<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="600" height="200" id="svg3010"> <text x="300" y="130" text-anchor="middle" fill="red" style="font-size: 100px; font-weight: bold">This is a title</text> </svg> Regards Rubén |
![]() |
![]() |
![]() |
#8 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
This is how it looks in the reader library.
It runs outside of the bounds of the box. Sigh. |
![]() |
![]() |
![]() |
#9 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Also, the height: 100% in the body and html can cause serious issues in at least the PRS-T* series. It can block you from moving to another page by both the hardware button and the swipe.
|
![]() |
![]() |
![]() |
#10 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
Dale |
|
![]() |
![]() |
![]() |
#11 |
Color me gone
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,089
Karma: 1445295
Join Date: Apr 2008
Location: Central Oregon Coast
Device: PRS-300
|
I shrunk the text size to 80 px and it works great in the Reader Library. Makes me want to experiment with more things.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adjustable line spacing not proportional to font size | GeoffR | Kobo Reader | 35 | 05-01-2014 07:59 AM |
Text with Fixed Layout | Gerlyn | Sigil | 11 | 04-09-2013 07:03 AM |
Making certain pages a fixed size? | lhgrappler | Sigil | 6 | 01-25-2011 11:11 AM |
Making certain pages a fixed size? | lhgrappler | ePub | 1 | 01-24-2011 08:34 PM |
fixed table size | JiYu | Amazon Kindle | 4 | 09-26-2010 12:02 PM |