Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Modify a pragprog's epub archive to use more suitable fonts on Sony eBook Reader
@font-face {
font-family: "Inconsolata";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/Inconsolata.otf);
}
/* DejaVuSans */
@font-face {
font-family: "DejaVuSansMono";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/DejaVuSansMono.ttf);
}
@font-face {
font-family: "DejaVuSansMono";
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/DejaVuSansMono-Bold.ttf);
}
@font-face {
font-family: "DejaVuSansMono";
font-weight: normal;
font-style: italic;
src: url(res:///Data/fonts/DejaVuSansMono-Oblique.ttf);
}
@font-face {
font-family: "DejaVuSansMono";
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/DejaVuSansMono-BoldOblique.ttf);
}
/* Condensed */
@font-face {
font-family: "DejaVuSansCondensed";
font-weight: normal;
font-style: normal;
src: url(res:///Data/fonts/DejaVuSansCondensed.ttf);
}
@font-face {
font-family: "DejaVuSansCondensed";
font-weight: bold;
font-style: normal;
src: url(res:///Data/fonts/DejaVuSansCondensed-Bold.ttf);
}
@font-face {
font-family: "DejaVuSansCondensed";
font-weight: normal;
font-style: italic;
src: url(res:///Data/fonts/DejaVuSansCondensed-Oblique.ttf);
}
@font-face {
font-family: "DejaVuSansCondensed";
font-weight: bold;
font-style: italic;
src: url(res:///Data/fonts/DejaVuSansCondensed-BoldOblique.ttf);
}
/* code */
code {
font-family: "DejaVuSansCondensed";
font-size: 70%;
}
body {
/* font-family: "Trebuchet MS", Verdana, Arial, sans-serif; */
margin: 0pt 1em;
padding: 0pt;
}
h1.chapter-title {
margin-top: 2em;
text-align: right;
}
h1.chapter-title .chapter-number {
/* color: #999999;*/
font-weight: bold;
display: block;
font-size: 90%;
}
h1.chapter-title .chapter-name {
display: block;
/* color: #555555;*/
background: url(../images/h1-underline.gif) repeat-x bottom;
font-size: 120%;
font-weight: bold;
margin-bottom: 1ex;
}
h2 {
font-size: 140%;
font-weight: bold;
text-align: left !important;
color: #445;
margin-top: 1em;
margin-bottom: 1ex !important;
}
h3 {
font-size: 110%;
font-weight: bold;
color: #225555;
clear: both;
margin-top: 1em;
margin-bottom: 1ex;
}
p {
line-height: 130%;
margin-top: 0pt;
}
.contribution {
font-size: smaller;
color: #888;
padding-left: 10%;
padding-right: 10%;
}
.acronym {
font-weight: bold;
font-variant: small-caps;
color: #333333;
}
.author {
margin-top: 1em;
text-align: right
}
.authorname {
}
.authoraffiliation {
font-style: italic;
}
.authors {
margin-top: 3em;
font-size: 18;
color: #666666;
}
/* authorq is the author asking the beta-book reader */
div.authorq {
margin: 1em 0;
padding: 1em;
background: #dddddd;
font-size: smaller;
}
div.authorq .the-author-asks {
font-weight: bold;
display: inline;
}
.b {
font-weight: bold;
}
.bad-xref {
color: red;
}
.bibliography {
margin-top: 2em;
border-width: 2px 0 0 0;
border-style: solid none none none;
border-color: #888888;
}
.unused-bookinfo {
margin-top: 2em;
margin-bottom: 4em;
padding: 3em;
border-width: 8px;
border-style: dotted;
border-color: #dddddd;
}
.titlepage
{
margin-left: 10%;
margin-right: 10%;
text-align: center;
}
.tp-title {
display: block;
margin-top: 50px;
padding-top: 10px;
padding-bottom: 10px;
color: #777777;
border-width: 3px;
border-style: solid none;
border-color: #888888;
}
.tp-subtitle {
display: block;
margin-top: 10px;
color: #777777;
}
.tp-authors
{
display: block;
color: #777;
margin-top: 20px;
}
.tp-copyright
{
margin-top: 5px;
font-size: x-small;
border-top: 1px solid #bbb;
color: #444;
}
.tp-docinfo
{
margin-top: 30px;
font-size: small;
color: #777;
}
.booksectname {
font-style: italic;
}
.cf {
font-family: "Courier";
}
.classname {
font-family: "Courier";
}
.commandname {
font-family: "Courier";
}
.sqlcolumn, .sqltable {
font-family: "Courier";
}
.stringinfile {
font-style: italic;
}
.dirname {
font-family: "Courier";
}
.emph {
font-style: italic;
}
.epigraph {
width: 60%;
position: relative;
left: 30%;
padding-top: 0px;
padding-top: 0px;
padding-left: 8px;
padding-right: 8px;
border-style: solid;
text-align: left;
border-width: 6px;
border-color: #dddddd;
font-size: small;
font-style: italic;
margin-bottom: 0.7em;
}
.episign {
padding: 2px;
border-style: solid;
text-align: right;
border-width: 2px 0px 0px 0px;
border-color: #dddddd;
font-size: small;
}
.episignname {
}
.episigntitle {
font-style: italic;
}
.episigndate {
}
.figure {
padding: 7px;
border-style: dotted;
text-align: center;
border-width: 3px;
border-color: #dddddd;
margin-top: 1em;
margin-bottom: 1em;
}
.firstuseinline {
font-style:italic;
}
.firstusemargin {
position: absolute;
top:auto;
left: 1em;
font-style:italic;
font-size: x-small;
float: left;
width: 1in;
text-align: right;
}
.flag {
color: red;
}
.flagadvanced {
float: left;
margin-right: 1em;
}
.footnotes {
margin-top: 2em;
border-width: 2px 0 0 0;
border-style: solid none none none;
border-color: #888888;
}
div.highlight {
border-top: 3px solid #acc;
border-bottom: 3px solid #acc;
width: 20%;
float: left;
margin-right: 2em;
}
div.highlight p {
margin-bottom: 0.2em;
}
.keystroke {
font-family: "Courier New";
}
.fileextension {
font-family: "Courier New";
}
.filename {
font-family: "Courier New";
}
.initials {
font-weight: bold;
font-variant: small-caps;
color: #333333;
}
.inlinecode {
font-family: "Courier";
}
.marginnote {
position: absolute;
top:auto;
left: 1em;
font-weight: bold;
font-size: x-small;
float: left;
width: 1in;
text-align: right;
line-height: 100%;
}
.methodname {
font-family: "Courier";
}
.missing {
position: absolute;
top:auto;
left: 1em;
font-weight: bold;
font-size: x-small;
float: left;
width: 1in;
text-align: right;
line-height: 100%;
}
.prefacesignoff a {
font-style: italic;
}
.prefacesignoffdate {
font-size: small;
}
table.processedcode {
margin: 0.7em 0px;
}
.processedcode tr {
margin-top: 0px;
margin-bottom: 0px;
}
.processedcode tr td {
padding-top: 0px;
padding-bottom: 0px;
}
.codeprefix {
font-weight: bold;
font-size: 70%;
}
.codeline {
}
.codeline pre {
margin-top: 0px;
margin-bottom: 0px;
font-weight: bold;
}
.codecalloutnumber {
font-size: 80%;
}
tr.livecodelozenge {
}
tr.livecodelozenge td a {
color: #eee8f0;
}
tr.livecodelozenge td {
font-size: 70%;
padding-left: 1em;
padding-top: 0.2em;
padding-bottom: 0.2em;
background: #98a0a8;
}
span.callout-number {
font-size: 80%;
color: green;
}
/*
dl {
}
dl dt.force-newline {
clear: left;
width: 100%;
display: block;
}
dl dt {
float: left;
clear: left;
width: 3em;
display: block;
}
dl dd {
margin-left: 3.5em;
padding-left: 5px;
margin-bottom: 5px;
}
*/
.simpletable {
margin-top: 1em;
margin-bottom: 2em;
border-width: 3px 0 2px 0;
border-style: solid none solid none;
border-color: #888888;
}
.standin {
font-style: italic;
font-weight: bold;
color: #444444;
}
.tabletitle {
font-weight: bold;
padding: 2px;
border-width: 0px 0 2px 0;
border-style: none none solid none;
border-color: #888888;
}
.xmltag {
font-weight: bold;
/* color: #444444;*/
}
.comment {
/* color: #115511; */
font-family: DejaVuSansCondensed;
/* font-style: italic; */
}
.kw {
/* color: #111199; */
font-weight: bold;
}
.string {
/* color: #555511;*/
font-style: italic;
}
.sidebar {
margin-top: 2em;
margin-bottom: 2em;
padding: 1em;
font-size: 90%;
font-family: sans;
border: 3px solid #aaa;
}
.sidebar .sidebar-title {
text-align: center;
font-weight: bold;
border-bottom: 1px solid #aaa
}
.underline {
text-decoration: underline;
}
div.webresources .title {
font-weight: bold;
margin-bottom: 0pt;
}
div.webresources .url {
font-weight: bold;
margin-top: 0pt;
margin-bottom: 0pt;
}
div.webresources .desc {
margin-top: 0px;
margin-left: 2em;
}
div.webresources .desc p {
margin-top: 0px;
}
.xref-title {
font-style: italic;
}
div.xxxsays {
font-size: small;
margin: 1em 0;
padding: 1em;
border: 2px #aaaaaa solid;
}
div.xxxsays .heading {
padding-bottom: 0.5em;
margin-bottom: 1em;
border-bottom: 2px #aaaaaa solid;
}
div.xxxsays .heading .persons-picture {
float: left;
margin-right: 2em
}
div.xxxsays .heading .label {
font-weight: bold;
color: #999999;
margin-bottom: 0.2em;
}
div.xxxsays .heading .title {
font-weight: bold;
font-size: larger;
color: #555555;
}
.copyright {
font-size: x-small;
color: #335555;
background: #aabbbb;
margin-top: 3em;
padding-top: 3px;
padding-bottom: 3px;
text-align: center;
border-top: 1px #335555 solid;
}
# Modifies a pragprog's epub archive to use more suitable fonts on Sony
# PRS-505 eBook Reader.
task :default => :help
def in_filename
ENV['input']
end
def out_filename
File.basename(in_filename, '.epub')+'-refont.epub'
end
def working_folder
File.basename(in_filename, '.epub')
end
verbose true
task :clear do
rm_rf working_folder
end
directory working_folder if in_filename
desc %{Modifies a pragprog's epub archive to use more suitable fonts on Sony
PRS-505 eBook Reader. Please provide the file to modify on the command line
like `rake input=a_book.epub`. The file a_book-refont.epub will be created.}
task :refont => [:clear, :unzip, :change_content, :zip, :copy]
desc 'Shows usage information'
task :help do
puts <<EOS
Important: first please go through the source of this Rakefile and adjust the paths as needed.
Please provide the input file name as environment variable, e.g. run as following:
input='/D/media/new_books/language-design-patterns_b6_0.epub' rake refont
run `rake -T` to show all the rake tasks.
EOS
end
task :unzip do
sh "unzip #{in_filename} -d #{working_folder}/"
end
task :zip do
cd working_folder
sh "zip -r #{out_filename} *"
cd '..'
end
task :copy do
cp File.join(working_folder, out_filename), '/media/EBOOK_CARD/pragprogs/'
end
task :change_content do
# It would be better to modify the existing stylesheet.
# But since pragprogs use the same stylesheet for all their books
# just replace the existing CSS with my custom one.
#css_path = File.join(working_folder, 'css', 'bookshelf.css')
#content = IO.read(css_path)
#File.open(css_path,'w') do |output_file|
#output_file.puts content.gsub()
#end
cp File.join(File.dirname(__FILE__), 'geek_bookshelf.css'),
File.join(working_folder, 'css', 'bookshelf.css')
end
task :unmount do
sh 'umount Sony*'
end
desc "Copies free fonts suitabe for source code from Ubuntu to Sony eBook reader"
task :copy_fonts do
sh 'cd /usr/share/fonts/truetype'
sh 'cp ttf-dejavu/DejaVuSansCondensed* "/media/Sony Reader Main Memory/fonts"'
sh 'cp ttf-dejavu/DejaVuSansMono* "/media/Sony Reader Main Memory/fonts"'
sh 'cp ttf-inconsolata/Inconsolata.otf "/media/Sony Reader Main Memory/fonts"'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment