mirror of
https://github.com/ciromattia/kcc
synced 2026-07-05 20:45:34 +00:00
Added primary-writing-mode metatag (fixes #19)
This commit is contained in:
+7
-2
@@ -83,11 +83,15 @@ def buildNCX(dstdir, title, chapters):
|
|||||||
f.close()
|
f.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
def buildOPF(profile, dstdir, title, filelist, cover=None):
|
def buildOPF(profile, dstdir, title, filelist, cover=None, righttoleft=False):
|
||||||
opffile = os.path.join(dstdir,'OEBPS','content.opf')
|
opffile = os.path.join(dstdir,'OEBPS','content.opf')
|
||||||
# read the first file resolution
|
# read the first file resolution
|
||||||
profilelabel, deviceres, palette = image.ProfileData.Profiles[profile]
|
profilelabel, deviceres, palette = image.ProfileData.Profiles[profile]
|
||||||
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
imgres = str(deviceres[0]) + "x" + str(deviceres[1])
|
||||||
|
if righttoleft:
|
||||||
|
writingmode = "horizontal-rl"
|
||||||
|
else:
|
||||||
|
writingmode = "horizontal-lr"
|
||||||
f = open(opffile, "w")
|
f = open(opffile, "w")
|
||||||
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
||||||
"<package version=\"2.0\" unique-identifier=\"BookID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
"<package version=\"2.0\" unique-identifier=\"BookID\" xmlns=\"http://www.idpf.org/2007/opf\">\n",
|
||||||
@@ -102,6 +106,7 @@ def buildOPF(profile, dstdir, title, filelist, cover=None):
|
|||||||
"<meta name=\"fixed-layout\" content=\"true\"/>\n",
|
"<meta name=\"fixed-layout\" content=\"true\"/>\n",
|
||||||
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n",
|
"<meta name=\"orientation-lock\" content=\"portrait\"/>\n",
|
||||||
"<meta name=\"original-resolution\" content=\"" + imgres + "\"/>\n",
|
"<meta name=\"original-resolution\" content=\"" + imgres + "\"/>\n",
|
||||||
|
"<meta name=\"primary-writing-mode\" content=\"" + writingmode + "\"/>\n",
|
||||||
"</metadata>\n<manifest>\n<item id=\"ncx\" href=\"toc.ncx\" media-type=\"application/x-dtbncx+xml\"/>\n"
|
"</metadata>\n<manifest>\n<item id=\"ncx\" href=\"toc.ncx\" media-type=\"application/x-dtbncx+xml\"/>\n"
|
||||||
])
|
])
|
||||||
# set cover
|
# set cover
|
||||||
@@ -222,7 +227,7 @@ def genEpubStruct(path):
|
|||||||
buildNCX(path,options.title,chapterlist)
|
buildNCX(path,options.title,chapterlist)
|
||||||
# ensure we're sorting files alphabetically
|
# ensure we're sorting files alphabetically
|
||||||
filelist = sorted(filelist, key=lambda name: (name[0].lower(), name[1].lower()))
|
filelist = sorted(filelist, key=lambda name: (name[0].lower(), name[1].lower()))
|
||||||
buildOPF(options.profile,path,options.title,filelist,cover)
|
buildOPF(options.profile,path,options.title,filelist,cover,options.righttoleft)
|
||||||
|
|
||||||
def getWorkFolder(file):
|
def getWorkFolder(file):
|
||||||
workdir = tempfile.mkdtemp()
|
workdir = tempfile.mkdtemp()
|
||||||
|
|||||||
Reference in New Issue
Block a user