
Chinese personal handwriting font making tool
#Handwritten#font#Chinese#Calligraphy#art#Createment
For those who want to make their own handwritten fonts, this tool uses open source fontforge and you have full copyright of your fonts.
Install Homebrew , and then
brew install fontforge
brew install potrace
brew install zbar
Python packages is recommended to use conda installation
conda env create -f environment.yml
After that you may encounter the error ImportError: Unable to find zbar shared library , you need the following workaround
mkdir ~/lib
ln -s $(brew --prefix zbar)/lib/libzbar.dylib ~/lib/libzbar.dylib
Install FontForge according to http://designwithfontforge.com/en-US/Installing_Fontforge.html
apt-get install software-properties-common
add-apt-repository ppa:fontforge/fontforge
apt-get update
apt-get install fontforge
My second step was not successful, but it did not affect it, so I can skip it.
We need its Python module. Please note that this module currently only supports python 2.7 version on Linux.
apt-get python-fontforge
After this step is successful, install Potrace
apt install potrace
Then after installation, opencv needs
apt install libgl1-mesa-glx
Then we started installing Python package, which is also recommended to use conda installation. If your memory allows, you can get it in one step
conda env create -f environment.yml
If you have insufficient memory like me, you can also install it one by one
conda create --name wefont python=3.9
conda activate wefont
conda install -c conda-forge pyzbar
conda install numpy
conda install -c conda-forge opencv
conda install -c conda-forge matplotlib
conda install -c conda-forge fpdf
conda install -c conda-forge qrcode
If you have a grand goal and want to get the complete font, you need to write 6763 Chinese characters, and the template can be downloaded directly under template . At the same time, it also provides commonly used one thousand-word templates, two thousand-word templates, etc.
You can also customize your own template, your goal can be to first cover a book you love most, such as红楼梦.txt
sed 's/(.)/1n/g' 红楼梦.txt | sort | uniq -c | sort -nr | awk '{print $2}' > 红楼梦字集.txt
You can get all the different words in this book, arranged according to the frequency of occurrence. Use this file to generate your own template.
cd src
python generate_template.py 红楼梦字集.txt
You can get a pdf template file. You can also adjust the template font size, font, and output file name.
Single-word text of commonly used characters can be found in src/config , which can be used directly.
(wefont) ➜ src git:(master) python generate_template.py -h
usage: generate_template.py [-h] [-cs CELL_SIZE] [-f FONT] [-fs FONT_SIZE] [-o OUTPUT] [-rs] [-v] filename
generate template based on gb2312
positional arguments:
filename input file containing the characters
options:
-h, --help show this help message and exit
-cs CELL_SIZE, --cell_size CELL_SIZE
the size of cell, default is 20
-f FONT, --font FONT the Chinese font used, default is fireflysung
-fs FONT_SIZE, --font_size FONT_SIZE
the font size, default is based on cell size
-o OUTPUT, --output OUTPUT
output pdf file name
-rs, --remove_subscript
remove the subscript number of cell
-v, --verbose print more info
It is recommended to use a pen with heavier colors after scanning. If the output is pdf , it needs to be converted to jpg
convert -verbose -density 150 -quality 100 扫描文件.pdf input-%02d.jpg
ImageMagic may need to be installed
This step can be completed in one click
cd src
./forge_my_font.sh 字体名 扫描文件1.jpg 扫描文件2.jpg 扫描文件3.jpg ...
Before starting writing on a large scale, you can give it a try. There is测试模板(郭襄小诗).pdf in template. After writing and getting the font, you can use your font to preview the following poem to see the effect.
When I walked across the mountain, I didn't speak. When I passed through the sea, I didn't speak. The little donkey dripped with the sword of the sky and accompanied me through the world. Everyone said that I became a monk on Mount Emei because I loved Yang Guo. Actually, I just fell in love with the clouds and clouds on Mount Emei. It looked very similar to the fireworks when I was sixteen years old.
If there are any words in the template that are written incorrectly, you can ignore it first, and create a font normally, and then patch it. The way to patch is to write typos first into a file, such as "typos.txt", and then use
cd src
python generate_template.py 错字集.txt
Generate templates, write, scan, and get jpg file
cd src
./patch_my_font.sh 现在的字体.ttf 扫描文件1.jpg 扫描文件2.jpg 扫描文件3.jpg ...
This way the characters in the new template will overwrite the characters in the old font, resulting in the new patched font. Moreover, the characters in the template can also be completely new characters, so that it is not overwritten, but added to the old font. In this way, you can write new words step by step and add them to the old fonts, thereby constantly getting more complete fonts.
Q: Why can't my pictures be processed?
Answer: It is found that the screenshot image cannot be processed correctly and the QR code cannot be recognized, so please do not use screenshots at present.

