Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-05-2009, 05:55 PM   #1
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Question Changing default font styles and sizes

Using the command line to convert text to epub, using any2epub. Sometimes the title is to big to fit all on one line and I would like the font to be smaller. also sometimes I would like to change a font style. Is there a config file for this or a css and where would I find it?
Thanks,
Paul
p3aul is offline   Reply With Quote
Old 07-06-2009, 10:16 AM   #2
dpierron
calibre2opds guru
dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.
 
dpierron's Avatar
 
Posts: 532
Karma: 8792
Join Date: Aug 2005
Location: Metz, France
Device: iPhone, iPad, PRS-650
this would be the --override-css option ...
dpierron is offline   Reply With Quote
Old 07-07-2009, 01:04 AM   #3
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Thanks for replying!
I looked in the Calibre folder and couldn't find a css file that was providing the default values. I also looked at the individule files in the epub package and although there were 3 css files in there, 0 had no font info, 1, was empty and 3 had some values for body, but no font specifications. I couldn't find any values for the title.

Just *where* is Calibre picking up these default values? They have to come from somewhere because the title is changed to a larger font and the body is given a times-roman style in the conversion before it is transferred to the 505.
If I use the the -override option, what would the layout of my own css file be? How would I name the elements?
Thanks,
Paul

Last edited by p3aul; 07-07-2009 at 01:07 AM. Reason: clarify
p3aul is offline   Reply With Quote
Old 07-07-2009, 09:46 AM   #4
dpierron
calibre2opds guru
dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.
 
dpierron's Avatar
 
Posts: 532
Karma: 8792
Join Date: Aug 2005
Location: Metz, France
Device: iPhone, iPad, PRS-650
Hi Paul,

I don't know where Calibre stores its default values, I'd guess it's in a constant compiled in the program...

Anyway, using --override-css is quite simple, all you have to do is specify the path of your custom CSS file :

Code:
  
--override-css=OVERRIDE_CSS
                        Either the path to a CSS stylesheet or raw CSS. This
                        CSS will override any existing CSS declarations in the
                        source files.
As for what to put in this file, I can't tell ; it depends on the input file, the way Calibre generates the content (and therefore the name of the class specified for the titles elements) : you'll have to experiment.

As far as I know it should be something like :

Code:
h1 {
    font-size:0.9em;
   }
Of course, the element name (h1 in this example) can vary, it could be h2, h3 or whatever level choosen by Calibre, or even a custom element.
Also, the font-size value is yours to choose

Tell me if I can help you further !

Cheers,
David.
dpierron is offline   Reply With Quote
Old 07-07-2009, 01:04 PM   #5
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Thanks David! I think I have it now! I use '#' for the title and '##' for the chapter headings for a text file. After Calibre converts the file to an interim html I bet the h1...hn heading styles would be pulled from custom style sheet. Should there be a blank space between the '=' and the filename? I'm off to experiment!



Paul
p3aul is offline   Reply With Quote
Old 07-07-2009, 01:55 PM   #6
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Ok here are the results:

This was the command line command:
any2epub -override-css="test.css" nighthorseman.txt

It spun along happily, finally producing this output:
verride-css=test.css
I changed the .css ext to zip and opened it it was a standard epub file so I changed ext to epub and loaded it into Calibre viewer. No changes so the external css didn't work. here is my css:

h1 {
font-size: 18pt;
}
h2 {
font-size: 16pt;
font-name: "Monotype Corsiva";
}
body {
font-size: 12pt;
font-name: "Times New Roman";
}

That's the content of my css was I supposed to put anything other than that in the CSS file? Some sort of header maybe?
Thanks,
Paul
p3aul is offline   Reply With Quote
Old 07-07-2009, 02:22 PM   #7
dpierron
calibre2opds guru
dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.
 
dpierron's Avatar
 
Posts: 532
Karma: 8792
Join Date: Aug 2005
Location: Metz, France
Device: iPhone, iPad, PRS-650
If I understood your message correctly, you made the mistake of typing '-override-css' instead of '--override-css' (note the double dash). So, the any2epubprogram mistook your input for a '-o' (which means 'specify output file') and tried to produce the output file verride-css="test.css" which is a very weird name for a file

You shall try again, my young padawan
dpierron is offline   Reply With Quote
Old 07-07-2009, 04:37 PM   #8
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
OK Tried again! This time I got the syntax right. File compiled into a epub file.
Loaded the file into calibre viewer. Title was larger than than the chapter heading which was what I specified, but not the point value specified so I guess there was some scaling. Not a biggie, I have read that css font values should be specified in em's.

The other problem is that the font name was *not* as specified "Monotype Corsiva".

Opening up the epub file revealed that file "index_calibre_2.css included my bit of css. at the bottom of the file. Monotype Corsiva was there as the body font-name. Why didn't it pick it up? here is the file inline.


body {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: 0
}
body {
margin-left: 5pt;
margin-right: 5pt
}
a {
color: inherit;
text-decoration: inherit;
cursor: default
}
a[href] {
color: blue;
text-decoration: underline;
cursor: pointer
}
body {
text-align: justify
}
h1 {
font-size: 18pt
}
h2 {
font-size: 24pt;
font-name: "Arial"
}
body {
font-size: 12pt;
font-name: "Monotype Corsiva"
}
Thanks,
Paul

*UPDATE*

Ok Seems any2epub didn't like "Monotype Corsiva", it did just fine with "Courier New"! So I guess I have it now.
Thanks,
Paul

Last edited by p3aul; 07-07-2009 at 06:21 PM.
p3aul is offline   Reply With Quote
Old 07-07-2009, 06:19 PM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 24,762
Karma: 4369667
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre doesn't (yet) support font embedding in EPUB. When it does the font will be picked up.
kovidgoyal is offline   Reply With Quote
Old 07-07-2009, 08:13 PM   #10
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Great kovid! meanwhile, will it embed fonts in lrf?
thanks,
Paul
p3aul is offline   Reply With Quote
Old 07-07-2009, 08:42 PM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 24,762
Karma: 4369667
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It might, LRF font embedding is a little iffy. Not all embedde fonts work and sometimes emedding results in a the main font becoming bold
kovidgoyal is offline   Reply With Quote
Old 07-08-2009, 12:35 AM   #12
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Well I have found a work-around.
(1) Load the HTML into OO Writer, change the inline styles of h1, h2, and p to what I want them to be.

(2) Export the file as PDF. this embeds the fonts.

(3) Import the file into Calibre and transfer it to my 505. Of course the fonts are scaled but with trial and error they are sized the way I want them to be.

Pictures are still somewhat of a problem. When converted to pdf, thumbnails are inserted that serve as links to the images on the website. This wont do of course, because the PRS 505 has no web access. I think this is because the original HTML used links to the pictures. I would have to go through the HTML and make the links local. Maybe that would work
Paul
p3aul is offline   Reply With Quote
Old 07-09-2009, 01:47 AM   #13
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
This is from the calibre manual: "calibre embeds fonts in ebook files it creates."

So far I have only had success in embedded fonts with prf files. Will the above statement be correct if I convert from GUI instead of command line? Is the manual in error here?
Thanks,
Paul
p3aul is offline   Reply With Quote
Old 07-09-2009, 04:27 AM   #14
dpierron
calibre2opds guru
dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.dpierron shines like a glazed doughnut.
 
dpierron's Avatar
 
Posts: 532
Karma: 8792
Join Date: Aug 2005
Location: Metz, France
Device: iPhone, iPad, PRS-650
Well, AFAIK, the manual is in error : Calibre is able to automatically embed fonts only in LRF files (sometimes ; some other times it just doesn't work).

To embed fonts in ePub files, you'll have to do it manually (you can look in the files I posted here for guidance).

Kovid, did I miss something ?
dpierron is offline   Reply With Quote
Old 07-09-2009, 08:37 AM   #15
p3aul
Captain Courageous
p3aul doesn't litterp3aul doesn't litter
 
p3aul's Avatar
 
Posts: 234
Karma: 102
Join Date: Apr 2009
Device: calibre, PRS 505
Thanks, dpierron, I think I'm getting somewhere now.

Well, I downloaded your font-test.zip and I'm a little confused. For example, Say I had three fonts, one each for h1, h2, and p. what would I put in each folder and where would the epub file go? Forgive an old man, I'm not as sharp as I used to be!
Thanks,
Paul

Last edited by p3aul; 07-09-2009 at 08:41 AM.
p3aul is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining font styles into single ttf file sherman Sony Reader Dev Corner 4 04-24-2009 09:21 PM
feed to lrf, how do I change font (or have default font) lovemov Calibre 3 03-16-2009 10:57 PM
Changing default font in Mobipocket? smp_iliad iRex 1 02-12-2009 09:46 PM
iLiad Changing the default sound ericshliao iRex Developer's Corner 4 12-21-2008 12:05 PM
Font changing sizes... rixte Bookeen 5 12-19-2007 05:58 PM


All times are GMT -4. The time now is 12:49 PM.


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