View Single Post
Old 06-26-2010, 02:38 AM   #2204
rty
Zealot
rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.rty got an A in P-Chem.
 
Posts: 108
Karma: 6066
Join Date: Apr 2010
Location: Singapore
Device: iPad Air, Kindle DXG, Kindle Paperwhite
@Kovid,

If you open the STYLESHEET.CSS of the news EPUB generated by Calibre, you will see that the section called ".articledescription", always has a fixed "Font-family: sans" and for some reason, I cannot replace it through the Extra_CSS in my recipe.

Code:
.articledescription {
    display: block;
    font-family: sans;
    font-size: 0.7em;
    text-indent: 0
    }
I need to get the FONT-FAMILY replaced with the line below
Code:
    font-family: "DroidFont", serif;
Calibre seems to ignore the Extra_CSS in my recipe to replace the FONT-FAMILY from the default "SANS" to "DROIDFONT" in this ".articledescription" section. Is this a bug?

Here is my recipe written for BBC Chinese. Please look at the Extra_css with which I try to overwrite the font-family of ".articledescription".

Spoiler:
Code:
class AdvancedUserRecipe1277443634(BasicNewsRecipe):
    title          = u'BBC Chinese'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [
	(u'\u4e3b\u9875', u'http://www.bbc.co.uk/zhongwen/simp/index.xml'), 
	(u'\u56fd\u9645\u65b0\u95fb', u'http://www.bbc.co.uk/zhongwen/simp/world/index.xml'), 
	(u'\u4e24\u5cb8\u4e09\u5730', u'http://www.bbc.co.uk/zhongwen/simp/china/index.xml'), 
	(u'\u91d1\u878d\u8d22\u7ecf', u'http://www.bbc.co.uk/zhongwen/simp/business/index.xml'), 
	(u'\u7f51\u4e0a\u4e92\u52a8', u'http://www.bbc.co.uk/zhongwen/simp/interactive/index.xml'), 
	(u'\u97f3\u89c6\u56fe\u7247', u'http://www.bbc.co.uk/zhongwen/simp/multimedia/index.xml'), 
	(u'\u5206\u6790\u8bc4\u8bba', u'http://www.bbc.co.uk/zhongwen/simp/indepth/index.xml')
	]
    extra_css = '''
    	@font-face {font-family: "DroidFont", serif, sans-serif; src: url(res:///system/fonts/DroidSansFallback.ttf); }\n
	body {margin-right: 8pt; font-family: 'DroidFont', serif;}\n
                    h1 {font-family: 'DroidFont', serif;}\n
                    .articledescription {font-family: 'DroidFont', serif;}
            '''
    __author__            = 'rty'
    __version__            = '1.0'
    language = 'zh-HANS'
    pubisher  = 'British Broadcasting Corporation'
    description           = 'BBC news in Chinese'
    category              = 'News, Chinese'
    remove_javascript = True
    use_embedded_content   = False
    no_stylesheets = True
    encoding               = 'UTF-8'
    conversion_options = {'linearize_tables':True} 
    masthead_url = 'http://wscdn.bbc.co.uk/zhongwen/simp/images/1024/brand.jpg'
    keep_only_tags = [
                              dict(name='h1'),
                              dict(name='p', attrs={'class':['primary-topic','summary']}),
                              dict(name='div', attrs={'class':['bodytext','datestamp']}), 
                            ]


If only this works, all the XML feeds of websites encoded in UTF-8 Chinese will display well on Nook (and most probably Sony etc)

Thanks.

ps. I have already opened a bug ticket for this (Ticket #5982). Is there really such a font name called "SANS"?

Related discussion: https://www.mobileread.com/forums/sho...925#post979925

Update: @Kovid, if it is too hard to fix, can you please simply remove the line "Font-Family: Sans" from ".articledescription" of the stylesheet.css?


Last edited by rty; 07-03-2010 at 03:00 AM.
rty is offline