Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 12-31-2024, 03:17 AM   #1
xtraktor
Enthusiast
xtraktor began at the beginning.
 
Posts: 29
Karma: 10
Join Date: Mar 2017
Device: Kindle Voyage
calibre_generated_inline_toc

Hi!

How can I keep - or add - font type in Calibre generated inline TOC in epub?

<body id="calibre_generated_inline_toc">
<h2 style="text-align: center;">Content</h2>

Actually I want the content title to appear in the same font tpye as the chapter title in the Book.

Thx in advance
xtraktor is offline   Reply With Quote
Old 12-31-2024, 05:22 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 31,062
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
just add the font-family: "xyz, serif"; to the style= list

I always consider these kinds of hacks, to be fragile.
They probably will NOT get updated correctly if the TOC is regenerated automatically.
theducks is offline   Reply With Quote
Advert
Old 12-31-2024, 07:59 AM   #3
xtraktor
Enthusiast
xtraktor began at the beginning.
 
Posts: 29
Karma: 10
Join Date: Mar 2017
Device: Kindle Voyage
Quote:
Originally Posted by theducks View Post
just add the font-family: "xyz, serif"; to the style= list

I always consider these kinds of hacks, to be fragile.
They probably will NOT get updated correctly if the TOC is regenerated automatically.
If I add to the h2 style this way:

<?xml version='1.0' encoding='utf-8'?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Content</title>
<style type="text/css">
li { list-style-type: none }
a { text-decoration: none }
a:hover { color: red }


</style>
</head>
<body id="calibre_generated_inline_toc">
<h2 style="text-align: center; font-family: Gabriel Weiss' Friends Font, sans-serif;">Content</h2>

indicates this error: Parsing failed: attributes construct error, line 14, column 73 [contents.xhtml:14]

What's the correct syntax?
xtraktor is offline   Reply With Quote
Old 12-31-2024, 03:32 PM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,220
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
added code tags

Using a font name with spaces in a inline style requires wrapping the name in 's. The single ' in the font name also needs to be wrapped in 's.

In a stylesheet, you would use " but an inline style mandates the '.

Code:
<h2 style="text-align: center; font-family: 'Gabriel Weiss''' Friends Font', sans-serif;">Content</h2>
I would suggest simply using <h2> and the following in a CSS stylesheet linked to your text file (the 4em font size is simply to allow easily seeing the difference between the CSS and inline style):
Code:
<h2>Content</h2>
<h2 style="text-align: center; font-size: 2.5em; font-family: 'Gabriel Weiss''' Friends Font', sans-serif;">Content</h2>


h2 {
  text-align: center;
  font-size: 4em;
  font-family: "Gabriel Weiss' Friends Font", sans-serif;
}

Last edited by DNSB; 12-31-2024 at 03:36 PM.
DNSB is offline   Reply With Quote
Old 01-01-2025, 12:37 AM   #5
xtraktor
Enthusiast
xtraktor began at the beginning.
 
Posts: 29
Karma: 10
Join Date: Mar 2017
Device: Kindle Voyage
Thanks for help!

Finally I got help from AI, here is the solution:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<title>Content</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<style>
li { list-style-type: none; }
a { text-decoration: none; }
a:hover { color: red; }
</style>
</head>
<body id="calibre_generated_inline_toc">
<h2 style="text-align: center" class="calibre11">Content</h2>
</body>
</html>

Where calibre11 is h2 style.
xtraktor is offline   Reply With Quote
Advert
Reply


Forum Jump


All times are GMT -4. The time now is 05:46 PM.


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