Skip to content

A simple python package converts font file to images

Notifications You must be signed in to change notification settings

imhuwq/font2png

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

font2png


Convert characters in a font file to png pictures.

This project is inited from fontforge, and simply does the two modifications:

  • delete code unrelated to font-image conversion
  • make it installable by python3 setup.py install

Great thanks to fontforge and all it's authors.

1. How to install

1.1 first prepare system dependencies:

sudo apt install libjpeg-dev && \
  libtiff5-dev && \
  libpng-dev && \
  libfreetype6-dev && \
  libgif-dev && \
  libxml2-dev && \
  libpango1.0-dev  && \
  python3-dev && \
  cmake && \
  build-essential

1.2 then install this package by python3:

python3 setup.py install

2. How to use it

# example.py
from font2png import font2png

font_file = "data/fontscn_3jqwe90k.ttf"


def main():
    font_mapping = font2png(font_file)
    for character, data in font_mapping.items():
        print(character, data)

if __name__ == "__main__":
    main()

About

A simple python package converts font file to images

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages