diff --git a/README.md b/README.md index 9c0fdff..0b21f34 100644 --- a/README.md +++ b/README.md @@ -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 /.txt /.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/.txt body/.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/.txt covers/.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 ./thumbs/printer_settings.png -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` .pdf .pdf` diff --git a/doc_pdf.py b/body.py similarity index 68% rename from doc_pdf.py rename to body.py index 7585730..b9c9eef 100644 --- a/doc_pdf.py +++ b/body.py @@ -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) diff --git a/body/blank_page.pdf b/body/blank_page.pdf deleted file mode 100644 index 94e0ebf..0000000 Binary files a/body/blank_page.pdf and /dev/null differ diff --git a/body/images.pdf b/body/images.pdf deleted file mode 100644 index 350dfae..0000000 Binary files a/body/images.pdf and /dev/null differ diff --git a/body/oulipo.pdf b/body/oulipo.pdf deleted file mode 100644 index 41ab4f9..0000000 Binary files a/body/oulipo.pdf and /dev/null differ diff --git a/body/oulipo1.pdf b/body/oulipo1.pdf deleted file mode 100644 index 4265ecb..0000000 Binary files a/body/oulipo1.pdf and /dev/null differ diff --git a/body/readme.pdf b/body/readme.pdf deleted file mode 100644 index 5996c6b..0000000 Binary files a/body/readme.pdf and /dev/null differ diff --git a/body/readme_screen.pdf b/body/readme_screen.pdf deleted file mode 100644 index 56baf9e..0000000 Binary files a/body/readme_screen.pdf and /dev/null differ diff --git a/colophons/colophon.pdf b/colophons/colophon.pdf deleted file mode 100644 index 4639fde..0000000 Binary files a/colophons/colophon.pdf and /dev/null differ diff --git a/colophons/colophon_readme.pdf b/colophons/colophon_readme.pdf deleted file mode 100644 index 8776851..0000000 Binary files a/colophons/colophon_readme.pdf and /dev/null differ diff --git a/cover.py b/cover.py index dde6498..b49a3e5 100644 --- a/cover.py +++ b/cover.py @@ -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) diff --git a/covers/cover.pdf b/covers/cover.pdf deleted file mode 100644 index 4b89e4c..0000000 Binary files a/covers/cover.pdf and /dev/null differ diff --git a/fonts/fireflysung.ttf b/fonts/fireflysung.ttf new file mode 100644 index 0000000..1484f5a Binary files /dev/null and b/fonts/fireflysung.ttf differ diff --git a/fonts/tinming.ttf b/fonts/tinming.ttf new file mode 100644 index 0000000..e425aa5 Binary files /dev/null and b/fonts/tinming.ttf differ diff --git a/input/body.txt b/input/body.txt new file mode 100644 index 0000000..5420e82 --- /dev/null +++ b/input/body.txt @@ -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 + +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 + +p.12: ### Javascript and parsing simple data +p.13: ### Displaying text otherwise + +# TEST + +p.14: Hiding text in Unerasable Characters I + +p.15: ### Destroying text with Machine Learning + 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 + +./images/exhibition.jpg + +刪你好嗎 diff --git a/input/body_2.txt b/input/body_2.txt new file mode 100644 index 0000000..a5b5fa9 --- /dev/null +++ b/input/body_2.txt @@ -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 + +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 + +p.12: ### Javascript and parsing simple data +p.13: ### Displaying text otherwise + +p.14: Hiding text in Unerasable Characters I + +p.15: ### Destroying text with Machine Learning + 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 +./thumbs/exhibition.jpg diff --git a/input/bodyclean.txt b/input/bodyclean.txt new file mode 100644 index 0000000..16aa71a --- /dev/null +++ b/input/bodyclean.txt @@ -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 + +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 + +p.12: ### Javascript and parsing simple data +p.13: ### Displaying text otherwise + +p.14: Hiding text in Unerasable Characters I + +p.15: ### Destroying text with Machine Learning + 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 +./thumbs/exhibition.jpg diff --git a/text/colophon.txt b/input/colophon.txt similarity index 100% rename from text/colophon.txt rename to input/colophon.txt diff --git a/input/cover.txt b/input/cover.txt new file mode 100644 index 0000000..cec6b55 --- /dev/null +++ b/input/cover.txt @@ -0,0 +1 @@ +Hiding Characters with Code diff --git a/text/images.txt b/input/images.txt similarity index 100% rename from text/images.txt rename to input/images.txt diff --git a/output/body.pdf b/output/body.pdf new file mode 100644 index 0000000..6683539 Binary files /dev/null and b/output/body.pdf differ diff --git a/output/cover.pdf b/output/cover.pdf new file mode 100644 index 0000000..fc95638 Binary files /dev/null and b/output/cover.pdf differ diff --git a/output/print_zine.pdf b/output/print_zine.pdf new file mode 100644 index 0000000..02044d5 Binary files /dev/null and b/output/print_zine.pdf differ diff --git a/output/zine.pdf b/output/zine.pdf new file mode 100644 index 0000000..e78391c Binary files /dev/null and b/output/zine.pdf differ diff --git a/requirements.txt b/requirements.txt index a995611..cdacef1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ -fpdf==1.7.2 +fpdf2 Werkzeug==2.0.1 +uharfbuzz diff --git a/text/cover.txt b/text/cover.txt deleted file mode 100644 index 986aff3..0000000 --- a/text/cover.txt +++ /dev/null @@ -1 +0,0 @@ -oulipo poems diff --git a/text/cover_readme.txt b/text/cover_readme.txt deleted file mode 100644 index dd9c178..0000000 --- a/text/cover_readme.txt +++ /dev/null @@ -1 +0,0 @@ -ZINE MAKER diff --git a/text/oulipo.txt b/text/oulipo.txt deleted file mode 100644 index 9e35e2d..0000000 --- a/text/oulipo.txt +++ /dev/null @@ -1,26 +0,0 @@ -Bold Nassan quits his -caravan, -A hazy mountain grot to -scan; -Climis jaggy rocks to find his -way, -Doth tax his sight, iut far doth -stray. - -Not work of man, nor sport of -child -Finds Nassan on this mazy -wild; -Lax grow his joints, limis toil in -vain- -Poor wight! why didst thou quit that -plain? - -Vainly for succour Nassan -calls; -Know, Zillah, that thy Nassan -falls; -But prowling wolf and fox may -joy -To quarry on thy Arai -ioy. diff --git a/text/oulipo1.txt b/text/oulipo1.txt deleted file mode 100644 index c1a0e16..0000000 --- a/text/oulipo1.txt +++ /dev/null @@ -1,11 +0,0 @@ -

If Youth,

- -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. diff --git a/text/readme b/text/readme deleted file mode 100644 index a118f4c..0000000 --- a/text/readme +++ /dev/null @@ -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/.txt body/.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/.txt covers/.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/.txt colophons/.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 - -./thumbs/printer_settings.png - -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/.pdf zines/.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/ diff --git a/thumbs/compiler.png b/thumbs/compiler.png deleted file mode 100644 index 7802f84..0000000 Binary files a/thumbs/compiler.png and /dev/null differ diff --git a/thumbs/libs-black.png b/thumbs/libs-black.png deleted file mode 100644 index 7a7e178..0000000 Binary files a/thumbs/libs-black.png and /dev/null differ diff --git a/thumbs/libs-green.png b/thumbs/libs-green.png deleted file mode 100644 index de44294..0000000 Binary files a/thumbs/libs-green.png and /dev/null differ diff --git a/thumbs/mailman-config.png b/thumbs/mailman-config.png deleted file mode 100644 index cae5177..0000000 Binary files a/thumbs/mailman-config.png and /dev/null differ diff --git a/thumbs/printer_settings.png b/thumbs/printer_settings.png deleted file mode 100644 index 8a07bff..0000000 Binary files a/thumbs/printer_settings.png and /dev/null differ diff --git a/thumbs/system-config.png b/thumbs/system-config.png deleted file mode 100644 index 1bb962e..0000000 Binary files a/thumbs/system-config.png and /dev/null differ diff --git a/thumbs/venv.png b/thumbs/venv.png deleted file mode 100644 index 882d076..0000000 Binary files a/thumbs/venv.png and /dev/null differ diff --git a/zine_maker.py b/zine_maker.py index 68bb141..d101f17 100644 --- a/zine_maker.py +++ b/zine_maker.py @@ -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(""): + if line.startswith(""): img_filename = line.split("")[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("

"): - line = re.sub('((

)|(

$))', '', 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(""): - line = re.sub('(()|($))', '', 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(""): - line = re.sub('(()|($))', '', 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('./images/', 'caption: ', line) + line = re.sub('', '', 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(""): - line = re.sub('($)', '', 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(""): - line = re.sub('($)', '', 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 "" in line: - line = re.sub('($)', '', 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 "" in line: - line = re.sub('($)', '', 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 diff --git a/zines/zinemaker.pdf b/zines/zinemaker.pdf deleted file mode 100644 index 3bd7353..0000000 Binary files a/zines/zinemaker.pdf and /dev/null differ