Giter Club home page Giter Club logo

handwrite's Introduction

Tests PyPI version Gitter chat License: MIT Code style: black CodeQL Language grade: Python

Handwrite - Type in your Handwriting!

Ever had those long-winded assignments, that the teacher always wants handwritten? Is your written work messy, cos you think faster than you can write? Now, you can finish them with the ease of typing in your own font!

Handwrite makes typing written assignments efficient, convenient and authentic.

Handwrite generates a custom font based on your handwriting sample, which can easily be used in text editors and word processors like Microsoft Word & Libre Office Word!

Handwrite is also helpful for those with dysgraphia.

You can get started with Handwrite here.

Sample

You just need to fill up a form:

Here's the end result!

Credits and Reference

  1. Potrace algorithm and package has been immensely helpful.

  2. Fontforge for packaging and adjusting font parameters.

  3. Sacha Chua's project proved to be a great reference for fontforge python.

  4. All credit for svgtottf converter goes to this project by pteromys. We made a quite a lot of modifications of our own, but the base script idea was derived from here.

handwrite's People

Contributors

equinox avatar gabeguz avatar sakshamarora1 avatar vaibhav-chopra-gt avatar withoutwaxaryan avatar yashlamba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

handwrite's Issues

Add requirements.txt

Realized after ec476e4 that we should explicitly pin dependencies, we were depending on setup.py which isn't good.

IndexError: list index out of range

Hello, I was making font file and got following error

Command I used

handwrite Handwrite.jpg ./

Error I got

Traceback (most recent call last):
File "/home/ganesh314159/.local/bin/handwrite", line 8, in <module>
sys.exit(main())
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 56, in main
converters(
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 34, in converters
run(sheet, output_directory, directory, config, metadata)
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/cli.py", line 12, in run
SHEETtoPNG().convert(sheet, characters_dir, config)
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/sheettopng.py", line 44, in convert
characters = self.detect_characters(
File "/home/ganesh314159/.local/lib/python3.9/site-packages/handwrite/sheettopng.py", line 116, in detect_characters
x, y, w, h = cv2.boundingRect(contours[i])
IndexError: list index out of range

This is my Handwrite jpg
Handwrite

FileNotFoundError: [WinError 2] The system cannot find the file specified

PS C:\Users\Gayashan\Desktop\hand> handwrite .\sample.jpg .\asd.ttf Traceback (most recent call last): File "C:\Users\Gayashan\miniconda3\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Gayashan\miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\Gayashan\miniconda3\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 56, in main converters( File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 34, in converters run(sheet, output_directory, directory, config, metadata) File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\cli.py", line 14, in run SVGtoTTF().convert(characters_dir, output_directory, config, metadata) File "C:\Users\Gayashan\miniconda3\lib\site-packages\handwrite\svgtottf.py", line 28, in convert subprocess.run( File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 505, in run with Popen(*popenargs, **kwargs) as process: File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 951, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Gayashan\miniconda3\lib\subprocess.py", line 1420, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

FileNotFoundError: [WinError 2] The system cannot find the file specified

(Running at Windows x64)
I followed the installation guide from the documentation and confirmed each install. But somehow, when I run
handwrite ./handwrite.jpg ./
in the terminal I get this error:
Traceback (most recent call last): File "c:\users\acer\anaconda3\envs\resnet\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\acer\anaconda3\envs\resnet\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\acer\Anaconda3\envs\Resnet\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "c:\users\acer\anaconda3\envs\resnet\lib\site-packages\handwrite\cli.py", line 28, in main SVGtoTTF().convert(directory, args.output, args.config) File "c:\users\acer\anaconda3\envs\resnet\lib\site-packages\handwrite\svgtottf.py", line 23, in convert outfile, File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 423, in run with Popen(*popenargs, **kwargs) as process: File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 729, in __init__ restore_signals, start_new_session) File "c:\users\acer\anaconda3\envs\resnet\lib\subprocess.py", line 1017, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

README: Add basic details

  • Instructions to setup on Windows.
  • Instructions to setup on Linux.
  • Credits for svgtottf, potrace, fontforge, sachac-hand.
  • Basic description.

pngtosvg: Merge thresholding part in pngToBmp to sheettopng.py code to accommodate variable lighting in inputs

Related: #3

We should do this thresholding in sheettopng during the cropping process.

# Threshold image to convert each pixel to either black or white
threshold = 200
data = []
for pix in list(img.getdata()):
if pix[0] >= threshold and pix[1] >= threshold and pix[3] >= threshold:
data.append((255, 255, 255, 0))
else:
data.append((0, 0, 0, 1))

OpenCV error while using the handwrite.exe on windows 10

Hi,

Thanks for this wonderful tool.
I am trying to use it on Windows Home 10.
I have installed fontforge in usual program files (x86) folder by download the installer.
Potrace is downloaded as zip and added the path to it in PATH env var.
Then from cmd I am running handwrite --directory "temp" "inputscan.jpg" "outputfont/"
In temp dir it creates all the folders per char.png (folder 59 is empty)
Then program throws error in sheettopng.py > cv2.inwrite() as below:

File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\Scripts\handwrite.exe\__main__.py", line 7, in <module> File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 56, in main converters( File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 34, in converters run(sheet, output_directory, directory, config, metadata) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\cli.py", line 12, in run SHEETtoPNG().convert(sheet, characters_dir, config) File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\sheettopng.py", line 47, in convert self.save_images( File "C:\Users\tushar\AppData\Local\Programs\Python\Python39\lib\site-packages\handwrite\sheettopng.py", line 158, in save_images cv2.imwrite( cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:801: error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite'

I am new to python, please let me know if I am missing anything.

Thanks,
Tushar

BUG: Unable to create font using jpg

  • Traceback:
❯ handwrite Downloads/sa\ handwrite\ font_1\ \(1\).jpg .
Traceback (most recent call last):
  File "/home/saahil/anaconda3/envs/handwrite/bin/handwrite", line 8, in <module>
    sys.exit(main())
  File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 57, in main
    args.input_path, args.output_directory, args.directory, args.config, metadata
  File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 34, in converters
    run(sheet, output_directory, directory, config, metadata)
  File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/cli.py", line 12, in run
    SHEETtoPNG().convert(sheet, characters_dir, config)
  File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/sheettopng.py", line 49, in convert
    characters_dir,
  File "/home/saahil/anaconda3/envs/handwrite/lib/python3.7/site-packages/handwrite/sheettopng.py", line 160, in save_images
    images[0],
cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-3129w7z7/opencv/modules/imgcodecs/src/loadsave.cpp:799: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
  • Dependencies:
❯ fontforge -v
Copyright (c) 2000-2021. See AUTHORS for Contributors.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 with many parts BSD <http://fontforge.org/license.html>. Please read LICENSE.
 Version: 20201107
 Based on sources from 2021-11-27 12:18 UTC-ML-D-GDK3.
 Based on source from git with hash: 58238cc173c80379d0d4616971fc793da26c6aa4
fontforge 20201107
build date: 2021-11-27 12:18 UTC
❯ potrace -v
potrace 1.16. Copyright (C) 2001-2019 Peter Selinger.
Library version: potracelib 1.16
Default unit: inches
Default page size: letter
❯ conda list
# packages in environment at /home/saahil/anaconda3/envs/handwrite:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             4.5                       1_gnu  
ca-certificates           2021.10.26           h06a4308_2  
certifi                   2021.10.8        py37h06a4308_0  
handwrite                 0.3.0                    pypi_0    pypi
ld_impl_linux-64          2.35.1               h7274673_9  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 9.3.0               h5101ec6_17  
libgomp                   9.3.0               h5101ec6_17  
libstdcxx-ng              9.3.0               hd4cf53a_17  
ncurses                   6.3                  h7f8727e_2  
numpy                     1.21.4                   pypi_0    pypi
opencv-python             4.5.4.60                 pypi_0    pypi
openssl                   1.1.1l               h7f8727e_0  
pillow                    8.4.0                    pypi_0    pypi
pip                       21.2.2           py37h06a4308_0  
python                    3.7.11               h12debd9_0  
readline                  8.1                  h27cfd23_0  
setuptools                58.0.4           py37h06a4308_0  
sqlite                    3.36.0               hc218d9a_0  
tk                        8.6.11               h1ccaba5_0  
wheel                     0.37.0             pyhd3eb1b0_1  
xz                        5.2.5                h7b6447c_0  
zlib                      1.2.11               h7b6447c_3  
  • Images used:

sa handwrite font_1 (1)
Fitted to A4 size using Adobe Scan

sa_handwrite_font_1
Original image scanned using Adobe Scan

  • Operating system used:
❯ neofetch 
██████████████████  ████████   saahil@saahil-gl638rd 
██████████████████  ████████   --------------------- 
██████████████████  ████████   OS: Manjaro Linux x86_64 
██████████████████  ████████   Host: GL63 8RD REV:1.0 
████████            ████████   Kernel: 5.10.79-1-MANJARO 
████████  ████████  ████████   Uptime: 4 hours, 59 mins 
████████  ████████  ████████   Packages: 1564 (pacman) 
████████  ████████  ████████   Shell: bash 5.1.8 
████████  ████████  ████████   Resolution: 1920x1080 
████████  ████████  ████████   WM: i3 
████████  ████████  ████████   Theme: Matcha-dark-sea [GTK2], Numix [G 
████████  ████████  ████████   Icons: Papirus-Dark [GTK2/3] 
████████  ████████  ████████   Terminal: kitty 
████████  ████████  ████████   CPU: Intel i7-8750H (12) @ 4.100GHz 
                               GPU: NVIDIA GeForce GTX 1050 Ti Mobile 
                               GPU: Intel CoffeeLake-H GT2 [UHD Graphi 
                               Memory: 3189MiB / 15850MiB
  • Tried both conda and python venv environments, but it failed in both with the same error shared above.
  • Python version 3.7

README: Update fontforge installation instructions

If the packaging isn't done till 0.2.0, we need to update users to install fontforge from the AppImage rather than the PPA.

PPA would work for Ubuntu >= 19.04 but since official support is gone, we should drop it too.

pngtosvg: Explore trim

We had given up on trimming the PNG file after converting to BMP, we need explore this more if this would be helpful now.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.