10-06-2014, 03:26 AM | #91 | |
Curmudgeon
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
|
Quote:
If you want something that catches *every* instance of a font override, you have to approach it similarly, but with different CSS:
A conforming reader that isn't overriding the font will display an empty paragraph instead of that second paragraph. A reader that is overriding the font in any way will display the contents. |
|
10-11-2014, 09:26 PM | #92 | |
Enthusiast
Posts: 39
Karma: 25000
Join Date: Dec 2009
Device: Kindle 3
|
Quote:
@font-face { font-family: marg; /* named after person writing */ font-style: normal; font-weight: normal; src:url(AlexBrush-Regular.ttf); } .marg {font-family: marg, serif; font-size: 150%; font-weight: normal; line-height: 100%; margin-top: 0%; margin-bottom: 0.5%; text-align: left; text-indent: 0%;} .margindent {font-family: marg, serif; font-size: 150%; font-weight: normal; line-height: 100%; margin-top: 0%; margin-bottom: 0%; text-align: left; text-indent: 50%;} div.letter /* For handwritten font script used in personal letters */ {margin-top: 1%; margin-bottom: 1%; margin-left: 1%; margin-right: 1%;} <div class="letter"> <br /> <p class="margindent">London,</p> <p class="margindent">October 29, 1898.</p> <p class="marg">Dear Raymond,</p> <p class="marg"> How horrible it must have been to have your leg amputated and become a crippled invalid. However, our lives must go on, and as you well know I abhor imperfection of person and therefore regret to inform you that I have engaged Messrs. Radford and Wilson to seek a divorce. I'm sure you will find solace in your desire to maintain my personal happiness. </p> <p class="marg">Margaret</p> </div> I found I could not get the font to work if I tried to declare the font as: <div class="letter marg">. I had to set the font class on every paragraph. As well, I could not get the font to indent unless I used a separate declaration and repeated all the selectors used in the "marg" class. I was expecting something like this would work: .marg (selectors as above) .margindent {text-indent: 50%;} <div class="letter marg"> <br /> <div class="margindent> <p>London,</p> <p>October 29, 1898.</p> </div> <p >Dear Raymond,</p> <p> How horrible … </p> <p>Margaret</p> </div> So, what do you think I did wrong? Tony Last edited by Tony_A20; 10-11-2014 at 09:37 PM. |
|
Advert | |
|
10-13-2014, 08:12 PM | #93 | |
Bookmaker & Cat Slave
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Is that how you typed it?
Quote:
Hitch |
|
10-15-2014, 01:56 AM | #94 |
Enthusiast
Posts: 39
Karma: 25000
Join Date: Dec 2009
Device: Kindle 3
|
<div class="letter marg">
Hello Hitch,
Yes, that's how it's typed. As far as I know it's a standard method of applying multiple CSS declarations. I use it all the time. Here are a few examples from my latest e-book: <div class="breakbefore breakafter"> applies page breaks around chapters <div class="pullquote quote-bg"> applies a pull-quote text and background <p class="first greybx"> sets no indent for first line and puts para in a grey background box I've had no problems applying up to 5 CSS declarations to one tag. Anyway, what about my code? Should it have worked the way I thought or is it necessary to repeat the whole font declaration just to add another selector? Should the <div class="letter marg"> have worked? Tony |
10-15-2014, 09:34 AM | #95 | |
Addict
Posts: 398
Karma: 96448
Join Date: Dec 2013
Device: iPad
|
If you run your code through Calibre's "Check Book" tool you should get the following error:
Quote:
|
|
Advert | |
|
10-15-2014, 12:26 PM | #96 |
Enthusiast
Posts: 39
Karma: 25000
Join Date: Dec 2009
Device: Kindle 3
|
The cause is found, now Why?
Hello odedta, Thanks for your reply.
I tried changing the @font-face to font-family: AlexBrush; and replacing "marg" with "AlexBush" and despite what Calbre may think, it doesn't make any difference. The family-name can be anything provided the src: is correctly identified. From MDN @font-face { [ font-family: <family-name>; ]? ... } family-name Specifies a name that will be used as the font face value for font properties. ( i.e. font-family: <family-name>; ) An online example is: @font-face { font-family: MyHelvetica; src: url(MgOpenModernaBold.ttf); } So, Calibre's error message is incorrect. What is happening is this: This works, <div class="letter"> <p class="marg">This is a test.</p> </div> This doesn't, <div class="letter marg"> <p >This is a test.</p> </div> The problem seems to be combining the font class with anything else. Multiple classes cause the font to fall back to the default/inherited font BUT, the other properties are correctly applied. However if this CSS declaration is made: p.inherit { font-family: inherit; } then this works: <div class="letter marg"> <p class="inherit">This is a test.</p> <p class="inherit">This is a second line.</p> </div> So, the font "marg" is being correctly applied by the division tag, but the para tag is nevertheless inheriting the font-family from somewhere else. Forcing the paragraph tag to inherit the font-family from the division tag declaration corrects the inheritance, but only for one para tag at a time. So the situation is: state the "inherit" class on every tag, or state the "marg" tag on every tag, because the font-family property is not inherited. And that's the case with changing the font indent—nothing about the embedded font is inherited, any change/use must repeat the full CSS description. The next question is: Why doesn't an embedded font become the new default after use? Tony |
10-15-2014, 01:22 PM | #97 |
Enthusiast
Posts: 39
Karma: 25000
Join Date: Dec 2009
Device: Kindle 3
|
The Answer!
I found this on the web.
"The font-family property is special in the sense that the initial value is not fixed in the specification but defined to be browser-dependent. This means that the browser’s default font family is used. This value can be set by the user." I believe the above is the underlying cause of the font-family application problems I experienced. An embedded font is dependent on a CSS or styling description and the font family cannot become a default. Therefore the font-family description must be applied to each individual use either by repeating the font-family class or by forcing the font-family use by means of the "inherit" property. End of story. Tony |
10-15-2014, 04:23 PM | #98 | |
Bookmaker & Cat Slave
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
FWIW. Hitch |
|
10-15-2014, 06:46 PM | #99 | |
Grand Sorcerer
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
I've created a simple test file with two html files that contain exactly the same code and two stylesheets with exactly the same styles. The only difference is that in the second stylesheet the first style was moved to the end of the stylesheet. HTML code Code:
<body> <h3>Chapter 1</h3> <div class="first third"> <p class="third first">It was a dark and stormy night.</p> <p class="first second">And so it began...</p> <p>The End.</p> </div> </body> Code:
.first {
text-align: left;
color: green;
font-weight: bold;
font-family: sans-serif;
font-size: 1.5em;
}
.second {
text-align: right;
color: blue;
font-family: monospace;
font-style: oblique;
font-size: 1em;
}
.third {
color: red;
font-variant: small-caps;
text-align: center;
}
Code:
.second {
text-align: right;
color: blue;
font-family: monospace;
font-style: oblique;
font-size: 1em;
}
.third {
color: red;
font-variant: small-caps;
text-align: center;
}
.first {
text-align: left;
color: green;
font-weight: bold;
font-family: sans-serif;
font-size: 1.5em;
}
|
|
10-16-2014, 06:17 AM | #100 | |
Bookmaker & Cat Slave
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
How'd you build that mobi? I mean, I see an azw3 file. Did you build that with Calibre or KG? Vis-a-vis multiple classes: if memory serves, yes, we use them, but I think it's a matter of, KG is so "fragile," and the end-results so irrationally unpredictable at KDP, that we tend to stick to "simpler," in terms of coding, because if you have anything even slightly out of line, you either get the inverse of what you're expecting or as you say, unpredictable results. I am not really sure why there's a problem with stating the class for each p, however. Sure, it would be nice to just do a div dec, and not have to style the p classes therein, but other things don't carry over p tags, so...why would fonts? And, yes, sure, order *would* matter, when no other method of determining precedence, for inheritance, is specified--wouldn't you think? Hitch |
|
10-16-2014, 08:50 AM | #101 | ||
Grand Sorcerer
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Hitch:
Quote:
Quote:
Order always matters. |
||
10-16-2014, 04:02 PM | #102 |
Enthusiast
Posts: 39
Karma: 25000
Join Date: Dec 2009
Device: Kindle 3
|
Multiple Classes
Hitch,
I've used the multiple class notation without any problems whatsoever. I design the classes I use to provide incremental styling, and I don't worry about conflicting properties because I try to make sure there are none, but if there were, I would expect the last property applied would replace any previous, conflicting property, and that might be a problem when listing multiple classes. The thing I didn't know about, was the specification status of an embedded font-family not being inheritable. I understand why such a decision was made, but I don't understand why the special status of the font-family is not better known. I couldn't find anything specific about it in the CSS or HTML spec. Kindlegen doesn't seem to mind, nor KDP. In fact, I've found the latest release of Kindlegen to be surprisingly forgiving and tolerant, and not at all concerned about many errors. On the other hand, it manages to mention warnings and errors for things (absolute and relative positioning) that the Kindle Publishing Guidelines say are supported—and work. Errors have to be pretty bad nowadays before Kindlegen refuses to produce a .mobi e-book. I think your doubts about using multiple classes are unfounded. Give it a try. Tony |
10-16-2014, 08:37 PM | #103 | |
Bookmaker & Cat Slave
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
It's highly likely that our experience with mobi format, over the last 5 years, has indeed made us overcautious, but one thing you should be aware of: what works today won't necessarily work tomorrow, at the KDP. And it changes pretty abruptly, sans warning and with EXCEEDINGLY little forgiveness (I mean...are you testing on K4iOS, in a live environment? With incremental inheriteds?). I don't mean to be so retro that I go "old school" prc, and we don't, but...I know that some of the reading apps, iOS particularly, ARE fragile. That one breaks when you look at it, so...yes, I am probably overcautious. Hitch |
|
10-17-2014, 02:15 PM | #104 |
Connoisseur
Posts: 75
Karma: 500000
Join Date: Oct 2011
Location: Utah
Device: iPad
|
I had a weird error with KDP and font embedding yesterday. KDP reencoded the fonts (that I was using for headings) and stripped out unused letters—except some of the "unused" letters were actually used on an html file toward the end of the ebook, and viewing the Paperwhite view in Kindle Previewer had those letters replaced with a default font. It looked terrible. (On the Kindle Fire preview pages, it was loading the font from my computer, so the error wasn't visible.)
I fixed this by making a "display:hidden" paragraph on the title page of the book that used all of those letters. Now the previously missing letters are embedded correctly and displayed fine on that late html file. The only letters that are missing from the embedded fonts now are the ones that are actually not used in the book. Before I got this error, my fonts were refusing to embed at all (after running through KDP; kindlegen embedded them fine). I fixed that error by following the advice earlier in this thread: explicitly classing any tag that used an embedded font and getting rid of multiple-classed tags. |
10-17-2014, 04:14 PM | #105 | |
Bookmaker & Cat Slave
Posts: 11,460
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Have you checked the post-KDP book on an iOS device? With an .azk file? Our experience with :hidden on the iOS K4iPad app has been murky and unpredictable, at best. And, yes: that's what happens, along with a host of other, undefined, unexplained and inexplicable font weirdnesses at the KDP. That's why I'm a big believer in, no matter how fancy the layout LOOKS, keep the coding as simple as possible, even if it's more work. It's just wildly unpredictable in terms of what will work. We're at the point that if a book has fonts, we test-load it at the KDP to see the post-upload mobi--just to be sure. Hitch |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Font Embedding? | teh603 | Writer2ePub | 75 | 01-08-2013 07:57 PM |
Font embedding | sachin | Sigil | 36 | 03-30-2012 03:26 AM |
Font embedding | sachin | Sigil | 3 | 03-21-2012 09:19 AM |
Do I need a font license if all I'm doing is referring to the font (not embedding)? | Stodder | Workshop | 21 | 04-21-2011 04:19 AM |
Special chararcters on the iPad or why does Apple not support Font-embedding? | georg3200 | ePub | 13 | 10-06-2010 10:32 AM |