~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/oeb/polish/main.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2013-08-01 18:17:22 UTC
  • mfrom: (1.5.2)
  • Revision ID: package-import@ubuntu.com-20130801181722-rzupi33y7ut6qzat
Tags: 0.9.41+dfsg-1
* New upstream release.
* debian/local/calibre.desktop: Rename to calibre-gui.desktop to match its
  window class. (LP: #1206687)
* Add debian/local/ebook-viewer.desktop, so that one can directly open
  *.epub or *.mobi files in file browsers. Thanks Korey Lu!
  (Closes: #664182)
* Make it possible to auto-start calibre when connecting an e-book reader
  device:
  - Add debian/local/mime/calibre.xml MIME association, install in
    debian/calibre.install.
  - debian/local/calibre-gui.desktop: Add MIME type and file argument.
  - Thanks to Thanks Korey Lu! (Closes: #715246)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from calibre.ebooks.oeb.polish.container import get_container
15
15
from calibre.ebooks.oeb.polish.stats import StatsCollector
16
16
from calibre.ebooks.oeb.polish.subset import subset_all_fonts
 
17
from calibre.ebooks.oeb.polish.embed import embed_all_fonts
17
18
from calibre.ebooks.oeb.polish.cover import set_cover
18
19
from calibre.ebooks.oeb.polish.replace import smarten_punctuation
19
20
from calibre.ebooks.oeb.polish.jacket import (
21
22
from calibre.utils.logging import Log
22
23
 
23
24
ALL_OPTS = {
 
25
    'embed': False,
24
26
    'subset': False,
25
27
    'opf': None,
26
28
    'cover': None,
47
49
<p>Note that polishing only works on files in the %s formats.</p>\
48
50
''')%_(' or ').join('<b>%s</b>'%x for x in SUPPORTED),
49
51
 
 
52
'embed': _('''\
 
53
<p>Embed all fonts that are referenced in the document and are not already embedded.
 
54
This will scan your computer for the fonts, and if they are found, they will be
 
55
embedded into the document.</p>
 
56
<p>Please ensure that you have the proper license for embedding the fonts used in this document.</p>
 
57
'''),
 
58
 
50
59
'subset': _('''\
51
60
<p>Subsetting fonts means reducing an embedded font to contain
52
61
only the characters used from that font in the book. This
118
127
        ebook = get_container(inbook, log)
119
128
        jacket = None
120
129
 
121
 
        if opts.subset:
122
 
            stats = StatsCollector(ebook)
 
130
        if opts.subset or opts.embed:
 
131
            stats = StatsCollector(ebook, do_embed=opts.embed)
123
132
 
124
133
        if opts.opf:
125
134
            rt(_('Updating metadata'))
159
168
            smarten_punctuation(ebook, report)
160
169
            report('')
161
170
 
 
171
        if opts.embed:
 
172
            rt(_('Embedding referenced fonts'))
 
173
            embed_all_fonts(ebook, stats, report)
 
174
            report('')
 
175
 
162
176
        if opts.subset:
163
177
            rt(_('Subsetting embedded fonts'))
164
178
            subset_all_fonts(ebook, stats.font_stats, report)
197
211
    parser = OptionParser(usage=USAGE)
198
212
    a = parser.add_option
199
213
    o = partial(a, default=False, action='store_true')
 
214
    o('--embed-fonts', '-e', dest='embed', help=CLI_HELP['embed'])
200
215
    o('--subset-fonts', '-f', dest='subset', help=CLI_HELP['subset'])
201
216
    a('--cover', '-c', help=_(
202
217
        'Path to a cover image. Changes the cover specified in the ebook. '