12-19-2022, 11:31 PM | #1 |
Junior Member
Posts: 9
Karma: 10
Join Date: Dec 2022
Device: Galaxy Tab SM-T500
|
Using custom embeded font, and improve embedded image quality
I'm trying to use a different font for my ebook. I want to use Alagard font rather than the default font most systems come with. I've embedded the ttf file I need. Also, how do I stop Sigil from over compressing embedded images so that when they are displayed they aren't a pixelated mess.
Code:
/* This defines styles and classes used in the book */ body { margin: 5%; text-align: justify; font-size: medium; background-color: #FCF5E5; } } code { font-family: "monospace"; } h1 { text-align: left; } h2 { text-align: left; } h3 { text-align: left; } h4 { text-align: left; } h5 { text-align: left; } h6 { text-align: left; } h1.title { } h2.author { } h3.date { } nav#toc ol, nav#landmarks ol { padding: 0; margin-left: 1em; } nav#toc ol li, nav#landmarks ol li { list-style-type: none; margin: 0; padding: 0; } a.footnote-ref { vertical-align: super; } em, em em em, em em em em em { font-style: italic;} em em, em em em em { font-style: normal; } code{ white-space: pre-wrap; } span.smallcaps{ font-variant: small-caps; } span.underline{ text-decoration: underline; } q { quotes: "“" "”" "‘" "’"; } div.column{ display: inline-block; vertical-align: top; width: 50%; } div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} |
12-19-2022, 11:58 PM | #2 |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Hi aknight2015 - welcome to MR!
For the font, you have to tell the css to use it and where it is located with something like: Code:
@font-face { font-family: 'My Italic'; font-weight: bold; font-style: italic; src: url('../Fonts/My_Italic_Bold_Italic.ttf'); } Code:
h1 {font-family: 'My Italic', serif} Code:
img {max-height:100%; max-width:100%}
div.image {margin:2em}
div.image img {width:100%; max-width:1200px}
<div class="image"><img alt="" src="../Images/yourimage.jpg"/></div>
|
Advert | |
|
12-20-2022, 08:11 PM | #3 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Dec 2022
Device: Galaxy Tab SM-T500
|
I don't know if I'm doing something wrong or what, but it's not working, at all. Could you actually show what the code looks like inside the CSS? That might help me understand.
Quote:
|
|
12-20-2022, 08:15 PM | #4 | |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
You need to make sure you link the css sheet to all the html sheets that you want the css to apply... Select/highlight all the html files, then right-click and select 'Link Stylesheets...' |
|
12-20-2022, 08:22 PM | #5 |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
CSS:
Code:
@font-face {
font-family: 'My Italic';
font-weight: bold;
font-style: italic;
src: url('../Fonts/My_Italic_Bold_Italic.ttf');
}
h1 {font-family: 'My Italic', serif}
img {max-height:100%; max-width:100%}
div.image {margin:2em}
div.image img {width:100%; max-width:1200px}
Code:
<h1>Heading Level 1 with your specific font</h1> <div class="image"><img alt="" src="../Images/yourimage.jpg"/></div> |
Advert | |
|
12-20-2022, 08:50 PM | #6 |
Junior Member
Posts: 9
Karma: 10
Join Date: Dec 2022
Device: Galaxy Tab SM-T500
|
This is what my CSS looks like
Code:
/* This defines styles and classes used in the book */ body { margin: 5%; text-align: justify; font-size: medium; background-color: #FCF5E5; } } { font-family: 'ChomskyRegular'; font-weight: normal; font-style: normal; src: url('../Fonts/Chomsky.otf'); } code { font-family: "ChomskyRegular"; } h1 { text-align: left; } h2 { text-align: left; } h3 { text-align: left; } h4 { text-align: left; } h5 { text-align: left; } h6 { text-align: left; } h1.title { } h2.author { } h3.date { } nav#toc ol, nav#landmarks ol { padding: 0; margin-left: 1em; } nav#toc ol li, nav#landmarks ol li { list-style-type: none; margin: 0; padding: 0; } a.footnote-ref { vertical-align: super; } em, em em em, em em em em em { font-style: italic;} em em, em em em em { font-style: normal; } code{ white-space: pre-wrap; } span.smallcaps{ font-variant: small-caps; } span.underline{ text-decoration: underline; } q { quotes: "“" "”" "‘" "’"; } div.column{ display: inline-block; vertical-align: top; width: 50%; } div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} |
12-20-2022, 09:08 PM | #7 |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Did you use “@font-face”….
|
12-20-2022, 09:32 PM | #8 |
Junior Member
Posts: 9
Karma: 10
Join Date: Dec 2022
Device: Galaxy Tab SM-T500
|
Still refuses to work. I've included the attached file to show what I'm dealing with.
|
12-20-2022, 09:40 PM | #9 |
Connoisseur
Posts: 61
Karma: 221034
Join Date: May 2021
Device: None
|
Your ../Fonts/ needs to be lowercase ../fonts/
|
12-20-2022, 11:20 PM | #10 |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
so....you have set the html tag <code> to have the font...but you don't have any <code> tags in the epub you posted.
Your src reference needs to be the exact same as your epub...capitalization matters.... so, as Foozle mentioned, /fonts/ is not the same as /Fonts/. I used Sigil menu 'Tools/Restructure Epub to Sigil Norm" - although that isn't strictly necessary, it makes the structure and naming of the ePub something I can rely on - and am familiar with. In this case, I cleaned up some of the duplicate css and moved the font to the header tags. Code:
@font-face {
font-family:'Chomsky';
font-weight:normal;
font-style:normal;
src:url('../Fonts/Chomsky.otf')
}
body{margin:5%; text-align:justify; font-size:medium; background-color:#FCF5E5}
h1,h2,h3,h4,h5,h6{font-family:"Chomsky"; text-align:left}
nav#toc ol,nav#landmarks ol{padding:0; margin-left:1em}
nav#toc ol li,nav#landmarks ol li{list-style-type:none; margin:0; padding:0}
a.footnote-ref{vertical-align:super}
em{font-style:italic}
em em{font-style:normal}
code{white-space:pre-wrap}
span.smallcaps{font-variant:small-caps}
span.underline{text-decoration:underline}
q{quotes:"“" "”" "‘" "’"}
div.column{display:inline-block; vertical-align:top; width:50%}
div.hanging-indent{margin-left:1.5em; text-indent:-1.5em}
|
12-20-2022, 11:24 PM | #11 |
A Hairy Wizard
Posts: 3,228
Karma: 19001261
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
OBTW, your cover image was HUGE! It was 11MB!! I changed it to a jpg and reduced the size slightly...now it is only 230KB
Last edited by Turtle91; 12-20-2022 at 11:26 PM. |
12-20-2022, 11:42 PM | #12 |
Bibliophagist
Posts: 40,631
Karma: 157444382
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Looking at your CSS, where are you associating the font with the displayed text. The only item I see is associating it with <code> which would generally be used for a monospaced font. Perhaps adding a 'font-family: "ChomskyRegular";' to the body selector might help.
You also have an egregious error in your CSS where you have an stray } after the body selector. In several renderers, this will have your entire stylesheet unused. Code:
body { margin: 5%; text-align: justify; font-size: medium; background-color: #FCF5E5; } } There are several other errors. You have an anchor in the nav.xhtml that has no content: Code:
<li id="toc-li-1"><a href="text/ch001.xhtml#section"></a> Code:
<center><p><em>For a more complete record, please see Great Crusade Chronology .</em></p></center> And, in my personal opinion, Chomsky is an ugly and unreadable font for body text. There's a reason that newpapers did not use that style of font in the body. Anyhow, I've attached my corrected version of the epub to this message. Note that what I've done to it is strictly my personal choices other than correcting the errors that epubcheck popped up with. I very strongly recommend that you install the Sigil's epubcheck plugin and make use of it. Last edited by DNSB; 12-20-2022 at 11:50 PM. Reason: Uploaded wrong version without the cover image converted to jpeg |
12-21-2022, 04:34 PM | #13 |
Junior Member
Posts: 9
Karma: 10
Join Date: Dec 2022
Device: Galaxy Tab SM-T500
|
I just want to say thank you for all your help. I'm going to download this thread for future reference.
|
12-21-2022, 11:41 PM | #14 | ||
Grand Sorcerer
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Quote:
|
||
12-22-2022, 12:34 AM | #15 | |
Bibliophagist
Posts: 40,631
Karma: 157444382
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
I'm still trying to wrap my mind around what was being attempted with the em, em em em, em em em em em { trying to set italic while em em, em em em em { were trying to set normal. An attempt to toggle nested em tags between italic and normal? |
|
Tags |
embed, font, image quality |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing embeded font in ebook using Sigil 1.9.20 | aknight2015 | Sigil | 1 | 12-20-2022 01:39 AM |
Embedded Style and Embedded Font labels truncated in KA1 | sladflob | KOReader | 2 | 06-25-2020 09:43 PM |
Embeded Italic font not rendered | theducks | Sigil | 6 | 11-07-2012 08:25 AM |
embedded font - now line with embedded font not re-flowing | Kaylee Skylyn | ePub | 23 | 08-09-2012 08:30 PM |
How can we embeded font in Fetch news? | attapol | Calibre | 0 | 01-03-2010 11:40 AM |