readme update and chinese support

This commit is contained in:
siusoon 2024-03-10 16:36:20 +00:00
parent 91962a4d01
commit 5a45aed544
39 changed files with 327 additions and 368 deletions

View file

@ -5,12 +5,12 @@ This tutorial helps in navigating the zine_maker code, a small software tool der
# Get the code
## Download the source code
As of 2021-2022, the code is under active development by the author and can be cloned and/or downloaded from https://git.systerserver.net/mara/zine_maker.
As of 2021-2022, the code is under active development by the author and can be cloned and/or downloaded from https://git.systerserver.net/mara/zine_maker.
To download the project, near the top of the gitlab page, click on the download icon next to "Find file".
You can choose which type of archived folder you want, and then open it in your filesystem, by right clicking the archived folder, or from the terminal:
```
tar -xvf zine_maker.tar -C /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
```
## OR use git clone:
@ -21,17 +21,45 @@ cd zine_maker
# Requirements
Basic requirements are listed here.
Basic requirements are listed here.
Python3 should be installed on the computer
https://www.python.org/downloads/
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:
`pip install -r requirements.txt`
# Run the code!
## Parameters
The python scripts `cover.py`, `body.py` and `colophon.py` take a text file as input, and a path for the output. If we give no input and not output, the default input comes from the files under the `input` folder and is saved in the output folder as cover.pdf, body.pdf and colophon.pdf respectively.
## Make the zine in 3 steps
1. Generate a cover pdf
from the root of the folder run:
`python cover.py`
2. Generate the body (the content) pdf
from the root of the folder run:
`python body.py`
3. Generate the colophon (the back cover) pdf
from the root of the folder run:
`python colophon.py`
The pdf is saved in the `output` 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:
for example run:
`python body.py <path>/<your-input-file>.txt <path>/<your-output-file>.pdf`
## Add images in the zine
`python doc_pdf.py text/images.txt body/images.pdf`
# Miscellaneous
## Fonts
@ -63,44 +91,25 @@ 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
existing rules, directly in the zine_maker code.
## Parameters
The python scripts cover.py, colophon.py and doc_pdf.py take a text input and an output filename. If we give no input/output, the default input is the related readme files under covers/body/colophons/
## Merge
## 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
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
## Images
For making use of images in the script
image magick needs to be installed
http://www.imagemagick.org/
# Run the code!
## Make the content of the pdf
The default parameters included in the script would create a zine from this
readme:
`python doc_pdf.py `
OR you can experiment with the other sample text found in this repository.
`python doc_pdf.py text/images.txt body/images.pdf`
OR get real and add your own text file and replace respectively the input and
output filenames.
`python doc_pdf.py text/<your_file>.txt body/<output-name>.pdf`
## Make the cover of the pdf
## 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:
OR try-out the other cover samples:
`python cover.py text/cover.txt covers/cover.pdf`
@ -108,11 +117,11 @@ 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
## 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:
OR try-out the other colophon samples:
`python colophon.py text/colophon.txt colophons/colophon.pdf`
@ -127,7 +136,7 @@ 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
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
@ -138,7 +147,7 @@ open the file zines/zinemaker.pdf
<img>./thumbs/printer_settings.png<img>
Default parameters: as input "zines/zinemaker_screen.pdf" and as output "zinemaker{random_number}.pdf"
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`

View file

@ -21,19 +21,21 @@ def make(inputfile, output):
# text font
zine.add_font(
'Kpalter', '',
r"fonts/KpProgrammerAlternatesNbp-Zg1q.ttf", uni=True
'chinese', '',
r"fonts/tinming.ttf"
)
zine.add_font('CasaleNBP', '', r"./fonts/CasaletwoNbp-Bp4V.ttf", uni=True)
zine.add_font('english', '', r"./fonts/CasaletwoNbp-Bp4V.ttf")
header_font = 'CasaleNBP'
#header_font = 'Kpalter'
text_font = 'helvetica'
zine.set_font(text_font, '', size=text_font_size)
english_font = 'english'
chinese_font = 'chinese'
zine.set_font(english_font, '', size=text_font_size)
zine.set_text_shaping(True)
zine.create_pages(inputfile, max_height, left_margin,
left_max_margin, top_margin, right_margin,
cell_width, cell_height, cell_header_height,
header_font, text_font, text_font_size)
header_font, english_font, chinese_font, text_font_size)
zine.output(output)
print("PDF saved as {}".format(output))
@ -43,12 +45,12 @@ if __name__ == '__main__':
# input text and output pdf
if len(sys.argv) > 1:
if len(sys.argv) == 2:
output = "./body/readme.pdf"
output = "./output/body.pdf"
if len(sys.argv) == 3:
output = sys.argv[2]
inputfile = sys.argv[1]
else:
inputfile = "./text/readme"
output = "./body/readme.pdf"
inputfile = "./input/body.txt"
output = "./output/body.pdf"
make(inputfile, output)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -22,7 +22,7 @@ if __name__ == '__main__':
output = sys.argv[2]
inputfile = sys.argv[1]
else:
inputfile = "./text/cover_readme.txt"
output = "./covers/cover_readme.pdf"
inputfile = "./input/cover.txt"
output = "./output/cover.pdf"
make_cover(inputfile, output)

Binary file not shown.

BIN
fonts/fireflysung.ttf Normal file

Binary file not shown.

BIN
fonts/tinming.ttf Normal file

Binary file not shown.

80
input/body.txt Normal file
View file

@ -0,0 +1,80 @@
## Content:
刪你好嗎
p.1: front cover
p.2: Blank
p.3: introduction
### The idea of hiding, and why need to hide?
p.4: ### Quote from Yung Au (2023) ref: https://datarelations.acca.melbourne/?entry=erasure-by-any-other-name
+++
Delete:
刪 (remove; erase)
除 (eliminate; divide)
Censor:
審 (examine; caution; interrogate)
查 (inspect; consult)
Disappear; Fade Away:
消 (vanish; disperse)
失 (mistake; omit; neglect)
Obscure; veil; make ambiguous:
隱 (hide; cover up; latent)
晦 (dark; night)
+++
p.5: Index
p.6: Context
### about the artwork series
p.7: Hiding text in Unerasable Characters III
<!show image-->
p.8: ### HTML and CSS (and view source code)
p.9: ### Black Out technique
p.10: ### Blurring technique
p.11: Hiding text in Unerasable Characters II
<!show image-->
p.12: ### Javascript and parsing simple data
p.13: ### Displaying text otherwise
# TEST
p.14: Hiding text in Unerasable Characters I
<!show image-->
p.15: ### Destroying text with Machine Learning
<!show graphviz diagram: digitized data > input > training > output-->
p.16: ### Producing gabbage text
p.17: ### Making a hidden book
p.18:Quotes
### from Yung Au (2023) again
+++
All of us have lived through some form of erasure. That is the experience of having our sentences cut short. Or the experience of being the subject of the moderation that occurs across communication infrastructures. It is having information curated for you, whether by machine, by hand or by something else entirely. Forgetting, too, is inherently a part of human memory. But, of course, as varied as our experiences of erasure, is our experiences of storage, of memory deposits, of keeping less tangible things in safe places.
The Chinese term for forget (忘記) is made up of the individual characters to forget/overlook and to remember/keep in mind. Likewise, the term for amnesia (失憶) is created by the individual characters to omit/lose and to recall.
What, then, are your architectures of forgetting and remembering? What, for you, will never be erased?
+++
p.19: Blank page
p.20: Back cover
### licencing, acknowlegements (e.g zine maker)
```
tar -xvf zine_maker.tar -C /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
```
刪你好嗎
TEST:
# show image
<img>./images/exhibition.jpg<img>
刪你好嗎

69
input/body_2.txt Normal file
View file

@ -0,0 +1,69 @@
## Content:
p.1: front cover
p.2: Blank
p.3: introduction
### The idea of hiding, and why need to hide?
p.4: ### Quote from Yung Au (2023) ref: https://datarelations.acca.melbourne/?entry=erasure-by-any-other-name
+++
Delete:
刪 (remove; erase)
除 (eliminate; divide)
Censor:
審 (examine; caution; interrogate)
查 (inspect; consult)
Disappear; Fade Away:
消 (vanish; disperse)
失 (mistake; omit; neglect)
Obscure; veil; make ambiguous:
隱 (hide; cover up; latent)
晦 (dark; night)
+++
p.5: Index
p.6: Context
### about the artwork series
p.7: Hiding text in Unerasable Characters III
<!show image-->
p.8: ### HTML and CSS (and view source code)
p.9: ### Black Out technique
p.10: ### Blurring technique
p.11: Hiding text in Unerasable Characters II
<!show image-->
p.12: ### Javascript and parsing simple data
p.13: ### Displaying text otherwise
p.14: Hiding text in Unerasable Characters I
<!show image-->
p.15: ### Destroying text with Machine Learning
<!show graphviz diagram: digitized data > input > training > output-->
p.16: ### Producing gabbage text
p.17: ### Making a hidden book
p.18:Quotes
### from Yung Au (2023) again
+++
All of us have lived through some form of erasure. That is the experience of having our sentences cut short. Or the experience of being the subject of the moderation that occurs across communication infrastructures. It is having information curated for you, whether by machine, by hand or by something else entirely. Forgetting, too, is inherently a part of human memory. But, of course, as varied as our experiences of erasure, is our experiences of storage, of memory deposits, of keeping less tangible things in safe places.
The Chinese term for forget (忘記) is made up of the individual characters to forget/overlook and to remember/keep in mind. Likewise, the term for amnesia (失憶) is created by the individual characters to omit/lose and to recall.
What, then, are your architectures of forgetting and remembering? What, for you, will never be erased?
+++
p.19: Blank page
p.20: Back cover
### licencing, acknowlegements (e.g zine maker)
```
tar -xvf zine_maker.tar -C /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
```
TEST:
# show image
<img>./thumbs/exhibition.jpg<img>

62
input/bodyclean.txt Normal file
View file

@ -0,0 +1,62 @@
Delete:
(remove; erase)
(eliminate; divide)
Censor:
(examine; caution; interrogate)
(inspect; consult)
Disappear; Fade Away:
(vanish; disperse)
(mistake; omit; neglect)
Obscure; veil; make ambiguous:
(hide; cover up; latent)
(dark; night)
+++
p.5: Index
p.6: Context
### about the artwork series
p.7: Hiding text in Unerasable Characters III
<!show image-->
p.8: ### HTML and CSS (and view source code)
p.9: ### Black Out technique
p.10: ### Blurring technique
p.11: Hiding text in Unerasable Characters II
<!show image-->
p.12: ### Javascript and parsing simple data
p.13: ### Displaying text otherwise
p.14: Hiding text in Unerasable Characters I
<!show image-->
p.15: ### Destroying text with Machine Learning
<!show graphviz diagram: digitized data > input > training > output-->
p.16: ### Producing gabbage text
p.17: ### Making a hidden book
p.18:Quotes
### from Yung Au (2023) again
+++
All of us have lived through some form of erasure. That is the experience of having our sentences cut short. Or the experience of being the subject of the moderation that occurs across communication infrastructures. It is having information curated for you, whether by machine, by hand or by something else entirely. Forgetting, too, is inherently a part of human memory. But, of course, as varied as our experiences of erasure, is our experiences of storage, of memory deposits, of keeping less tangible things in safe places.
The Chinese term for forget (忘記) is made up of the individual characters to forget/overlook and to remember/keep in mind. Likewise, the term for amnesia (失憶) is created by the individual characters to omit/lose and to recall.
What, then, are your architectures of forgetting and remembering? What, for you, will never be erased?
+++
p.19: Blank page
p.20: Back cover
### licencing, acknowlegements (e.g zine maker)
```
tar -xvf zine_maker.tar -C /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
```
TEST:
# show image
<img>./thumbs/exhibition.jpg<img>

1
input/cover.txt Normal file
View file

@ -0,0 +1 @@
Hiding Characters with Code

BIN
output/body.pdf Normal file

Binary file not shown.

BIN
output/cover.pdf Normal file

Binary file not shown.

BIN
output/print_zine.pdf Normal file

Binary file not shown.

BIN
output/zine.pdf Normal file

Binary file not shown.

View file

@ -1,2 +1,3 @@
fpdf==1.7.2
fpdf2
Werkzeug==2.0.1
uharfbuzz

View file

@ -1 +0,0 @@
oulipo poems

View file

@ -1 +0,0 @@
ZINE MAKER

View file

@ -1,26 +0,0 @@
Bold Nassan quits his
<i>caravan,</i>
A hazy mountain grot to
<i>scan;</i>
Climis jaggy rocks to find his
<i>way,</i>
Doth tax his sight, iut far doth
<i>stray.</i>
Not work of man, nor sport of
<i>child</i>
Finds Nassan on this mazy
<i>wild;</i>
Lax grow his joints, limis toil in
<i>vain-</i>
Poor wight! why didst thou quit that
<i>plain?</i>
Vainly for succour Nassan
<i>calls;</i>
Know, Zillah, that thy Nassan
<i>falls;</i>
But prowling wolf and fox may
<i>joy</i>
To quarry on thy Arai
<i>ioy.</i>

View file

@ -1,11 +0,0 @@
<h2> If Youth, </h2>
throughout all history, had had a champion to stand up for it;
to show a doubting world that a child can think;
and, possibly, do it practically;
you wouldn't constantly run across folks today who claim that "a child don't know anything."
A child's brain starts functioning at birth; and has, amongst its many infant convolutions, thousands of dormant atoms, into which God has put a mystic possibility for noticing an adult's act, and figuring out its purport.
# Up to about its primary school days a child thinks, naturally, only of play.
But many a form of play contains disciplinary factors. "You can't do this," or "that puts you out," shows a child that it must think, practically, or fail.
Now, if, throughout childhood, a brain has no opposition, it is plain that it will attain a position of "status quo," as with our ordinary animals. Man knows not why a cow, dog or lion was not born with a brain on a par with ours; why such animals cannot add, subtract, or obtain from books and schooling, that paramount position which Man holds today.

View file

@ -1,157 +0,0 @@
# Introduction
This tutorial helps in navigating the zine_maker code, a small software tool derived from pyFPDF library. The code is written in Python, and provides a few scripts for creating covers, colophons, content, and also signatures for preparing a PDF for the printer. The scripts run with python version 3.x.x and we can feed to the scripts inputs and outputs. As an input, we give the path to a text file, which shall create the text and images content of the zine, and as an output we give a the path/filename of our choice. We can also run the scripts with no input nor output, in which case, they take as default parameters the readme text from the 'text/' folder and produce an output to either of the folders 'covers', 'colophons', 'body', or 'zines', depending on which script we are running each time.
# Get the code
## Download the source code
The code is under development by the author and can be cloned or downloaded from https://git.systerserver.net/mara/zine_maker.
To download the project, near the top of the gitlab page, click on the download icon next to "Find file". Once downloaded, right-click to extract the files, or from terminal run:
```
tar -xvf zine_maker.tar -C /home/user/destination
unzip zinme_maker.zip -d /home/user/destination
```
Or with git clone:
```
export username=zine
export token=DskM_8XxtKt-Wym1xHd1
export repo=git.systerserver.net/mara/zine_maker.git
git clone https://$username:$token@$repo
cd zine_maker
```
# Requirements
Basic requirements are listed here.
Python3 should be installed on the computer
https://www.python.org/downloads/
And also the pip command if it didn't get installed with Python
https://pip.pypa.io/en/stable/installation/
Once these are installed, from within zine_maker folder run:
`pip install -r requirements.txt`
# Miscellaneous
## Fonts
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 files cover.py, colophon.py and doc_pdf.py to give the new names. Or add your absolute font path directly to the python scripts.
## Text
The input texts should be clean from characters added by some text editors or Operating Systems. Use the cat command to check your text is ready as input
with:
`cat --show-nonprinting input.txt`
Characters such as M-oM-;M or ^M (carriage Return / line feed) need to be removed. A cool tool for that is dos2unix, which is available as command line, but needs to be installed:
`dos2unix filename`
Or with the sed command:
`sed -e "s/\r//g" file > newfile`
Extensive info can be find at:
https://www.cyberciti.biz/faq/sed-remove-m-and-line-feeds-under-unix-linux-bsd-appleosx/
## Layout
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 and changes to the font color and size happen accordingly. We can add more or edit existing rules, directly in the zine_maker code.
## Parameters
The python scripts cover.py, colophon.py and doc_pdf.py take a text input and an output filename. If we give no input/output, the default input is the related readme files under 'covers/', 'body/', 'colophons/' folders.
## 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/)
# Run the code!
## Make the content of the pdf
The default parameters included in the script would create a zine from this readme:
`python doc_pdf.py `
OR you can experiment with the other sample text found in this repository under the 'text' folder.
`python doc_pdf.py text/images.txt body/images.pdf`
OR get real and add your own text file and replace respectively the input and output filenames.
`python doc_pdf.py text/<your_file>.txt body/<output-name>.pdf`
## 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 a zine:
open the file zines/zinemaker.pdf
# Make a zine
## Prepare signatures for printing
<img>./thumbs/printer_settings.png<img>
The script shuffle.py creates signatures for printing and folding the A4 in two, to create a zine. 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` zines/<input_file>.pdf zines/<output_file>.pdf`
Note: your input file needs to have an even number of pages, divisible by 4, which is the number of pages needed for one signature. We can add blank pages in the begining and end of the body pdf file we created before if we need to make the total page number divisible by 4.
In the printer settings opt-in for the following:
- A4 Landscape
- Two pages per side
- Double side - short edge
# References
code repository:
https://git.systerserver.net/mara/zine_maker
install python:
https://www.python.org/downloads/
install pip:
https://pip.pypa.io/en/stable/installation/
clean the text file for parsing:
https://www.cyberciti.biz/faq/sed-remove-m-and-line-feeds-under-unix-linux-bsd-appleosx/
merge and split pdf files:
http://linux-commands-examples.com/pdfunite
http://www.linux-commands-examples.com/pdfseparate
process images:
http://www.imagemagick.org/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

View file

@ -84,11 +84,12 @@ class Zine(FPDF):
left_max_margin, top_margin, right_margin, *args):
if args:
cell_width = args[0]
cell_height = args[1]
cell_default_height = args[1]
cell_header_height = args[2]
header_font = args[3]
text_font = args[4]
text_font_size = args[5]
english_font = args[4]
chinese_font = args[5]
default_font_size = args[6]
f = open(filename, 'rt')
lines = f.readlines()
@ -98,17 +99,16 @@ class Zine(FPDF):
self.set_margins(left_margin, top_margin, right_margin)
self.set_xy(left_margin, top_margin)
self.add_page()
text_font = None
text_font_size = None
for line in lines:
if ">>" in line:
self.set_font(text_font, '', size=16)
self.cell(cell_width, cell_height, line,
0, ln=1, align='L')
self.set_font(text_font, '', size=text_font_size)
if re.search(u'[\u4e00-\u9fff]', line):
text_font = chinese_font
else:
text_font = english_font
# check if we have an image
elif line.startswith("<img>"):
if line.startswith("<img>"):
img_filename = line.split("<img>")[1]
kwargs = {
"max_height": max_height,
@ -117,123 +117,46 @@ class Zine(FPDF):
}
self.position_img(
img_filename, self.get_x(), self.get_y(), **kwargs)
# check if we have a title
elif line.startswith("<h2>"):
line = re.sub('((<h2>)|(</h2>$))', '', line)
purple_shades = random.randrange(100, 180, 20)
#self.set_text_color(130, 50, 250)
self.set_text_color(purple_shades, 0, 200)
self.set_font(header_font, size=22)
if self.get_y() > top_margin:
self.set_xy(left_margin, top_margin+9)
self.add_page()
self.cell(cell_width, cell_header_height, line,
0, ln=1, align='C')
left_x = self.get_x()
top_y = self.get_y()
# self.dashed_line(
# left_x, top_y, left_x+cell_width, top_y,
# dash_length=3, space_length=3)
self.set_text_color(0, 0, 0)
self.set_font(text_font, size=text_font_size)
elif line.startswith("<i>"):
line = re.sub('((<i>)|(</i>$))', '', line)
self.set_font('helvetica', 'I', size=19)
self.multi_cell(cell_width, cell_height, line,
0, align='L')
self.set_font(text_font, '', size=text_font_size)
elif line.startswith("<b>"):
line = re.sub('((<b>)|(</b>$))', '', line)
font_size = 14
self.set_font(header_font, '', font_size)
bold_header_height = font_size
self.cell(cell_width, bold_header_height, line,
0, ln=1, align='C')
self.set_font(text_font, '', size=text_font_size)
line = re.sub('<img>./images/', 'caption: ', line)
line = re.sub('<img>', '', line)
elif line.startswith("# "):
#insert a new page in the zine
if self.get_y() > top_margin:
self.set_xy(left_margin, top_margin+9)
self.add_page()
self.set_font(header_font, size=25)
text_font_size = 32
pink_shades = random.randrange(60, 150, 20)
self.set_text_color(255, pink_shades, pink_shades)
self.cell(cell_width, cell_header_height, line,
0, ln=1, align='L')
# go back to text font
self.set_text_color(0, 0, 0)
self.set_font(text_font, '', size=text_font_size)
print('1#', text_font_size)
elif line.startswith("##"):
elif line.startswith("## "):
line = re.sub('()', '', line)
subheader_font = "helvetica"
cell_subheader_height = 10
text_font_size = 20
#gray_shades = random.randrange(0, 256, 60)
self.set_font(subheader_font, size=18)
self.set_text_color(0, 0, 0)
self.multi_cell(cell_width, cell_subheader_height, line,
0, align='L')
# go back to text font
self.set_font(text_font, '', size=text_font_size)
self.set_text_color(0, 255, 0)
print('two #', text_font_size)
elif line.startswith("### "):
line = re.sub('()', '', line)
text_font_size = 13
self.set_text_color(255, 0, 0)
print('three #', text_font_size)
elif line.startswith("`") or line.startswith("```"):
self.set_font('helvetica', '', size=11)
self.set_text_color(0, 30, 255)
line = re.sub('((`)|(```))', '', line)
self.multi_cell(cell_width, cell_height, line,
0, align='L')
elif len(line.strip()) == 0:
# go back to text font
self.set_text_color(0, 0, 0)
self.set_font(text_font, '', size=text_font_size)
elif line.startswith("$") or line.startswith("(venv)"):
self.set_font('helvetica', 'B', size=9)
self.set_text_color(0, 30, 255)
self.multi_cell(cell_width, cell_height, line,
0, align='L')
# go back to text font
self.set_text_color(0, 0, 0)
self.set_font(text_font, '', size=text_font_size)
elif line.startswith("<quote>"):
line = re.sub('(<quote>$)', '', line)
self.set_font(text_font, '', size=13)
self.set_text_color(150, 0, 205)
self.multi_cell(cell_width, cell_height, line,
0, align='C')
elif line.startswith("</quote>"):
line = re.sub('(</quote>$)', '', line)
self.multi_cell(cell_width, cell_height, line,
0, align='L')
self.set_font(text_font, '', text_font_size)
self.set_text_color(0, 0, 0)
elif "<index>" in line:
line = re.sub('(<index>$)', '', line)
self.set_font(text_font, '', size=18)
self.set_text_color(0, 0, 0)
self.set_text_color(41, 98, 255)
self.cell(cell_width/8, cell_height, line, 0, align='C')
elif "</index>" in line:
line = re.sub('(</index>$)', '', line)
self.set_font(text_font, '', size=text_font_size)
self.set_text_color(0, 0, 0)
self.multi_cell(cell_width, cell_height, line,
0, align='L')
else:
# check if we need the following
variable_x = self.get_x()
self.multi_cell(cell_width, cell_height, line, 0, align='L')
self.set_xy(variable_x, self.get_y())
text_font_size = default_font_size
variable_x = self.get_x()
self.set_font(text_font, '', size=text_font_size)
self.multi_cell(cell_width, cell_default_height, line, 0, align='L')
self.set_xy(variable_x, self.get_y())
# go back to text font
self.set_text_color(0, 0, 0)
self.set_font(size=default_font_size)
# close file
f.close()
@ -251,32 +174,40 @@ class Zine(FPDF):
else:
for line in title.readlines():
for letter in line:
if letter.isspace():
col += 40
self.set_xy(margin+col, margin)
if self.get_y() >= max_height:
self.set_xy(margin+col, margin)
col += 40
size = random.randrange(15, 30, 10)
size = random.randrange(16, 30, 5)
print(size)
self.set_font(cover_font, '', size)
self.set_text_color(255, 0, 0)
variable_x = margin+col
print(
"LETTER {}, POSITION Y {}".format(letter, self.get_y())
)
print("VAR X {}".format(variable_x))
self.set_xy(variable_x, self.get_y())
self.cell(size, size, letter)
self.line(size, size, self.get_x(), self.get_y())
if(size % 2 == 0):
var = "DF"
R = random.randrange(30, 255, 40)
G = random.randrange(0, 55, 55)
#self.line(size, size, self.get_x(), self.get_y())
if (size % 2 == 0):
var = "D"
else:
var = "DF" # fills with color the shapes
R = random.randrange(0, 255, 40)
G = random.randrange(0, 255, 55)
B = random.randrange(0, 155, 50)
self.set_fill_color(R, G, B)
else:
var = "D"
print(var)
self.rect(
self.rect( # draw boxes
float(self.get_x()), float(self.get_y()),
float(size/2), float(size*4), style=var)
float(size/2), float(size/2), style=var)
self.circle( # draw circles
float(self.get_x()+ size/2), float(self.get_y()+ size/2),
float(size), style=var)
self.ln(size/2)
# close the file

Binary file not shown.