Add Korean and update README
This commit is contained in:
parent
5a45aed544
commit
9b9ba78bcb
12 changed files with 72 additions and 83 deletions
133
README.md
133
README.md
|
|
@ -22,16 +22,30 @@ cd zine_maker
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
Basic requirements are listed here.
|
Basic requirements are listed here.
|
||||||
Python3 should be installed on the computer
|
- Terminal
|
||||||
https://www.python.org/downloads/
|
- for MacOS and Linux, it comes together with the system, we can find the application by searching for terminal
|
||||||
|
- for Windows 10 and 11 follow the steps here (can you find a howto in Korean?)
|
||||||
And also the pip command if it didn't get installed with Python
|
- command line tool pdftk
|
||||||
|
- for MacOS we can download it from https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg
|
||||||
|
- for Linux we can install with sudo apt install poppler-utils
|
||||||
|
- for windows we can download it from https://pdftk.en.softonic.com/?ex=RAMP-1768.1
|
||||||
|
- Python3 should be installed in the computer
|
||||||
|
Check by opening the terminal and run `python -i`
|
||||||
|
- And also the pip command if it didn't get installed with Python
|
||||||
https://pip.pypa.io/en/stable/installation/
|
https://pip.pypa.io/en/stable/installation/
|
||||||
|
|
||||||
Once these are installed, from within zine_maker folder run:
|
Once these are installed, from within zine_maker folder run:
|
||||||
|
|
||||||
`pip install -r requirements.txt`
|
`pip install -r requirements.txt`
|
||||||
|
|
||||||
|
## Language
|
||||||
|
for non latin languages, you need to add language specific fonts in the `fonts` folder. At the moment there are Chinese and Korean fonts.
|
||||||
|
|
||||||
|
## Images
|
||||||
|
For making use of images in the script
|
||||||
|
image magick needs to be installed
|
||||||
|
http://www.imagemagick.org/
|
||||||
|
|
||||||
# Run the code!
|
# Run the code!
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
@ -50,7 +64,38 @@ The python scripts `cover.py`, `body.py` and `colophon.py` take a text file as i
|
||||||
from the root of the folder run:
|
from the root of the folder run:
|
||||||
`python colophon.py`
|
`python colophon.py`
|
||||||
|
|
||||||
The pdf is saved in the `output` folder.
|
The pdf documents are saved in the `output` folder.
|
||||||
|
|
||||||
|
## Final PDF
|
||||||
|
For merging the cover, body and colophon pdf files, there are many pdf merger tools. One that is command line based and is used in this tutorial is pdfunite
|
||||||
|
http://linux-commands-examples.com/pdfunite
|
||||||
|
|
||||||
|
from the root directory run:
|
||||||
|
`pdfunite covers/cover.pdf body/body.pdf colophons/colophon.pdf output/final.pdf`
|
||||||
|
You shall substitute the file paths to your own corresponding /path/filenames
|
||||||
|
|
||||||
|
## See this readme as the generated pdf zine:
|
||||||
|
open the file output/zinemaker.pdf
|
||||||
|
|
||||||
|
## Print
|
||||||
|
For preparing the final pdf for printing you need the pdfseparate command
|
||||||
|
http://www.linux-commands-examples.com/pdfseparate
|
||||||
|
|
||||||
|
Run from the root directory:
|
||||||
|
```
|
||||||
|
python book.py `output/final.pdf` `output/print_final.pdf`
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prepare pages for printing
|
||||||
|
|
||||||
|
<img>./images/printer_settings.png<img>
|
||||||
|
|
||||||
|
In the printer settings opt-in for the following settings:
|
||||||
|
```
|
||||||
|
- A4 Landscape
|
||||||
|
- Two pages per side
|
||||||
|
- Double side - short edge
|
||||||
|
```
|
||||||
|
|
||||||
To make your own zine modify the text files for the cover, for the body and for the colophon in the input folder.
|
To make your own zine modify the text files for the cover, for the body and for the colophon in the input folder.
|
||||||
Or provide your own files with the full pathname:
|
Or provide your own files with the full pathname:
|
||||||
|
|
@ -58,15 +103,17 @@ for example run:
|
||||||
`python body.py <path>/<your-input-file>.txt <path>/<your-output-file>.pdf`
|
`python body.py <path>/<your-input-file>.txt <path>/<your-output-file>.pdf`
|
||||||
|
|
||||||
## Add images in the zine
|
## Add images in the zine
|
||||||
`python doc_pdf.py text/images.txt body/images.pdf`
|
You need to add in your input text file the path of your image.
|
||||||
|
For example if you add images in the `image` folder you can add them in the `input/body.txt` as `<img>./images/<image-filename>.jpg<img>. You can also give the full path of your system font.
|
||||||
|
See the `input/images.txt` as an example of how to add images in your content.
|
||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
|
|
||||||
## Fonts
|
## Fonts
|
||||||
The source code comes with some fonts under the fonts folder. You can use your
|
The source code comes with some fonts under the fonts folder. You can use your
|
||||||
fonts of preference by adding them either in the fonts folder and edit the
|
fonts of preference by adding them either in the fonts folder and edit the
|
||||||
files cover.py, colophon.py and doc_pdf.py to give the new names. Or add your
|
files cover.py, colophon.py and body.py to give the new names. Or add your
|
||||||
absolute font path directly to the python scripts.
|
absolute font path directly in the python scripts.
|
||||||
|
|
||||||
## Text
|
## Text
|
||||||
The input texts should be clean from characters added by some text editors or
|
The input texts should be clean from characters added by some text editors or
|
||||||
|
|
@ -88,70 +135,6 @@ https://www.cyberciti.biz/faq/sed-remove-m-and-line-feeds-under-unix-linux-bsd-a
|
||||||
## Layout
|
## Layout
|
||||||
All the font styling happens in the zine_maker function create_pages(). The
|
All the font styling happens in the zine_maker function create_pages(). The
|
||||||
input text is parsed for specific tags or symbols in the begining of each line
|
input text is parsed for specific tags or symbols in the begining of each line
|
||||||
and changes to the font color and size happen accordingly. We can add more or edit
|
and changes to the font color and size happen accordingly. We can add more or edit existing rules, directly in the zine_maker code.
|
||||||
existing rules, directly in the zine_maker code.
|
To add new functions for text style visit the [fpdf2 text documentation](https://py-pdf.github.io/fpdf2/TextStyling.html)
|
||||||
|
To add new functions for drawing shapes visit the [fpdf2 drawing documentation](https://py-pdf.github.io/fpdf2/fpdf/drawing.html)
|
||||||
## Merge
|
|
||||||
For merging the cover, body and colophon pdf files, there are many pdf merger tools. One that is command line based and is used in this tutorial is pdfunite
|
|
||||||
http://linux-commands-examples.com/pdfunite
|
|
||||||
|
|
||||||
## Print
|
|
||||||
For shuffling the final pdf and prepare it for printing you need the pdfseparate command
|
|
||||||
http://www.linux-commands-examples.com/pdfseparate
|
|
||||||
it is used inside the shuffle_pdf.py file (see details at the end of this README).
|
|
||||||
|
|
||||||
## Images
|
|
||||||
For making use of images in the script
|
|
||||||
image magick needs to be installed
|
|
||||||
http://www.imagemagick.org/
|
|
||||||
|
|
||||||
## Make the cover of the pdf
|
|
||||||
Same, the default parameters included in the script would create the cover for the zine_maker:
|
|
||||||
`python cover.py`
|
|
||||||
|
|
||||||
OR try-out the other cover samples:
|
|
||||||
|
|
||||||
`python cover.py text/cover.txt covers/cover.pdf`
|
|
||||||
|
|
||||||
OR add your cover text file and replace respectively:
|
|
||||||
|
|
||||||
`python cover.py text/<your-cover>.txt covers/<cover-name>.pdf`
|
|
||||||
|
|
||||||
## Make the colophon of the pdf
|
|
||||||
Same, the default parameters included in the script would create the colophon for the zine_maker:
|
|
||||||
`python colophon.py `
|
|
||||||
|
|
||||||
OR try-out the other colophon samples:
|
|
||||||
|
|
||||||
`python colophon.py text/colophon.txt colophons/colophon.pdf`
|
|
||||||
|
|
||||||
OR add your own colophon text file and replace respectively:
|
|
||||||
|
|
||||||
`python colophon.py text/<your-colophon>.txt colophons/<output-colophon>.pdf`
|
|
||||||
|
|
||||||
# Make a screen PDF
|
|
||||||
|
|
||||||
## For the final screen version
|
|
||||||
from the terminal run:
|
|
||||||
|
|
||||||
`pdfunite covers/cover.pdf body/body.pdf colophons/colophon.pdf zines/final.pdf`
|
|
||||||
|
|
||||||
You shall substitute the file paths to your own corresponding /path/filenames
|
|
||||||
|
|
||||||
## See this readme as the generated screen version zine:
|
|
||||||
open the file zines/zinemaker.pdf
|
|
||||||
|
|
||||||
# Make a zine
|
|
||||||
|
|
||||||
## Prepare signatures for printing
|
|
||||||
|
|
||||||
<img>./thumbs/printer_settings.png<img>
|
|
||||||
|
|
||||||
Default parameters: as input "zines/zinemaker_screen.pdf" and as output "zinemaker{random_number}.pdf"
|
|
||||||
Run it for your own pdf files as following:
|
|
||||||
`python shuffle_pdf.py` <input_file>.pdf <output_file>.pdf`
|
|
||||||
|
|
||||||
In the printer settings opt-in for the following settings:
|
|
||||||
- A4 Landscape
|
|
||||||
- Two pages per side
|
|
||||||
- Double side - short edge
|
|
||||||
|
|
|
||||||
11
body.py
11
body.py
|
|
@ -20,22 +20,21 @@ def make(inputfile, output):
|
||||||
zine = Zine(orientation="P", unit="mm", format="A5")
|
zine = Zine(orientation="P", unit="mm", format="A5")
|
||||||
|
|
||||||
# text font
|
# text font
|
||||||
zine.add_font(
|
zine.add_font( 'chinese', '', r"fonts/tinming.ttf")
|
||||||
'chinese', '',
|
zine.add_font( 'korean', '', r"fonts/GmarketSansTTFMedium.ttf")
|
||||||
r"fonts/tinming.ttf"
|
|
||||||
)
|
|
||||||
zine.add_font('english', '', r"./fonts/CasaletwoNbp-Bp4V.ttf")
|
zine.add_font('english', '', r"./fonts/CasaletwoNbp-Bp4V.ttf")
|
||||||
header_font = 'CasaleNBP'
|
header_font = 'CasaleNBP'
|
||||||
#header_font = 'Kpalter'
|
|
||||||
english_font = 'english'
|
english_font = 'english'
|
||||||
chinese_font = 'chinese'
|
chinese_font = 'chinese'
|
||||||
|
korean_font = 'korean'
|
||||||
zine.set_font(english_font, '', size=text_font_size)
|
zine.set_font(english_font, '', size=text_font_size)
|
||||||
zine.set_text_shaping(True)
|
zine.set_text_shaping(True)
|
||||||
|
|
||||||
zine.create_pages(inputfile, max_height, left_margin,
|
zine.create_pages(inputfile, max_height, left_margin,
|
||||||
left_max_margin, top_margin, right_margin,
|
left_max_margin, top_margin, right_margin,
|
||||||
cell_width, cell_height, cell_header_height,
|
cell_width, cell_height, cell_header_height,
|
||||||
header_font, english_font, chinese_font, text_font_size)
|
header_font, english_font, chinese_font, korean_font,
|
||||||
|
text_font_size)
|
||||||
|
|
||||||
zine.output(output)
|
zine.output(output)
|
||||||
print("PDF saved as {}".format(output))
|
print("PDF saved as {}".format(output))
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ from zine_maker import Zine
|
||||||
|
|
||||||
|
|
||||||
def shuffle_zine(finput, foutput):
|
def shuffle_zine(finput, foutput):
|
||||||
# set font for all text
|
|
||||||
zine = Zine(orientation="P", unit="mm", format="A5")
|
zine = Zine(orientation="P", unit="mm", format="A5")
|
||||||
chapter_list = zine.shuffle_chapters(finput)
|
chapter_list = zine.shuffle_chapters(finput)
|
||||||
|
|
||||||
|
|
@ -36,6 +35,8 @@ def shuffle_zine(finput, foutput):
|
||||||
print("PDF saved as {}".format(foutput))
|
print("PDF saved as {}".format(foutput))
|
||||||
os.system("mv ./*_chapter.pdf ./.tmp")
|
os.system("mv ./*_chapter.pdf ./.tmp")
|
||||||
os.system("rm ./.tmp/*_chapter.pdf")
|
os.system("rm ./.tmp/*_chapter.pdf")
|
||||||
|
os.system("rm ./doc_data.txt")
|
||||||
|
os.system("rm ./chapters.txt")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BIN
fonts/GmarketSansTTFBold.ttf
Normal file
BIN
fonts/GmarketSansTTFBold.ttf
Normal file
Binary file not shown.
BIN
fonts/GmarketSansTTFLight.ttf
Normal file
BIN
fonts/GmarketSansTTFLight.ttf
Normal file
Binary file not shown.
BIN
fonts/GmarketSansTTFMedium.ttf
Normal file
BIN
fonts/GmarketSansTTFMedium.ttf
Normal file
Binary file not shown.
BIN
images/printer_settings.png
Normal file
BIN
images/printer_settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
BIN
input/blank.pdf
Normal file
BIN
input/blank.pdf
Normal file
Binary file not shown.
3
input/korean.txt
Normal file
3
input/korean.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# test korean
|
||||||
|
|
||||||
|
## 한국어
|
||||||
BIN
output/korean.pdf
Normal file
BIN
output/korean.pdf
Normal file
Binary file not shown.
BIN
output/print_korean.pdf
Normal file
BIN
output/print_korean.pdf
Normal file
Binary file not shown.
|
|
@ -89,7 +89,8 @@ class Zine(FPDF):
|
||||||
header_font = args[3]
|
header_font = args[3]
|
||||||
english_font = args[4]
|
english_font = args[4]
|
||||||
chinese_font = args[5]
|
chinese_font = args[5]
|
||||||
default_font_size = args[6]
|
korean_font = args[6]
|
||||||
|
default_font_size = args[7]
|
||||||
|
|
||||||
f = open(filename, 'rt')
|
f = open(filename, 'rt')
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
|
@ -105,6 +106,8 @@ class Zine(FPDF):
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if re.search(u'[\u4e00-\u9fff]', line):
|
if re.search(u'[\u4e00-\u9fff]', line):
|
||||||
text_font = chinese_font
|
text_font = chinese_font
|
||||||
|
if re.search(u'[\uac00-\ud7af]', line):
|
||||||
|
text_font = korean_font
|
||||||
else:
|
else:
|
||||||
text_font = english_font
|
text_font = english_font
|
||||||
# check if we have an image
|
# check if we have an image
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue