A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos.

Overview

font2png

A little Python tool to convert a TrueType (ttf/otf) font into a PNG for use in demos.

To use from command line it expects python3 to be at /usr/bin, it also expects that Pillow is installed and available to Python.

font2png -f  -o  -w 
     
       -l -s 
      
               (-f) - font to use (ttf or otf)
  --output=
        (-o) - PNG file to be output --width=
        
          (-w) - width in pixels of output (minimum 8 pixels) --left-align (-l) - left align the font (default centred) --scale (-s) - font scale relative to width (defult 1.0) --mono (-m) - output as monochrome --defines (-d) - output letter widths to stdout --quantise=
         
           (-q) - quantise colours to number specified --help (-h) - show usage 
         
        
      
     

After exporting to PNG use your favourite tool to convert to a format suitable for your demo.

The output is one giant tall image where each sized box contains a character, in ASCII order, starting with SPACE (32) and ending with ~ (126).

I will gladly accept pull requests for any improvements that can be made.

You might also like...
An API that renders HTML/CSS content to PNG using Chromium

html_png An API that renders HTML/CSS content to PNG using Chromium Disclaimer I am not responsible if you happen to make your own instance of this AP

Fast batch image resizer and rotator for JPEG and PNG images.
Fast batch image resizer and rotator for JPEG and PNG images.

imgp is a command line image resizer and rotator for JPEG and PNG images.

A proof-of-concept implementation of a parallel-decodable PNG format
A proof-of-concept implementation of a parallel-decodable PNG format

mtpng A parallelized PNG encoder in Rust by Brion Vibber [email protected] Background Compressing PNG files is a relatively slow operation at large imag

With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen

Oraxen-item-to-yml With this simple py script you will be able to get all the .png from a folder and generate a yml for Oraxen How to use Install the

👾 Python project to help you convert any image into a pixel art.
👾 Python project to help you convert any image into a pixel art.

👾 Pixel Art Generator Python project to help you convert any image into a pixel art. ⚙️ Developer's Guide Things you need to get started with this co

Simple Python package to convert an image into a quantized image using a customizable palette
Simple Python package to convert an image into a quantized image using a customizable palette

Simple Python package to convert an image into a quantized image using a customizable palette. Resulting image can be displayed by ePaper displays such as Waveshare displays.

A Icon Maker GUI Made - Convert your image into icon ( .ico format ).
A Icon Maker GUI Made - Convert your image into icon ( .ico format ).

Icon-Maker-GUI A Icon Maker GUI Made Using Python 3.9.0 . It will take any image and convert it to ICO file, for web site favicon or Windows applicati

Convert any image into greyscale ASCII art.
Convert any image into greyscale ASCII art.

Image-to-ASCII Convert any image into greyscale ASCII art.

pix2tex: Using a ViT to convert images of equations into LaTeX code.
pix2tex: Using a ViT to convert images of equations into LaTeX code.

The goal of this project is to create a learning based system that takes an image of a math formula and returns corresponding LaTeX code.

Comments
  • Decouple font size from tile width/height

    Decouple font size from tile width/height

    First of all thanks for this tool! it's really useful and I'd been considering something similar for a while. I have a suggestion which I wanted to run past you before implementing.

    Currently the width option dictates both the font size and height of the tile. There is an implied assumption that a glyph for font size 'x' will fit inside an x*x pixel bounding box. This is somewhat true for height (although some fonts do extend beyond this) but point size has no relationship to glyph width in proportional fonts. What's more, a common requirement would be for the image width to be a multiple of 16 for blitting. For example I might want a 16x14 tile for a 14px font.

    I can see that you introduced the scale option to somewhat address this need but to me it makes sense to allow the user to specify the width, height and font size separately. They can still default to a single value if not specified. I'm happy to create a PR to add these options if you agree with the approach.

    opened by grahambates 3
  • Add separate width/height/size options

    Add separate width/height/size options

    As discussed in #4

    • I made the derived value of width just round up to mutliples of 8 for simplicity.
    • Short option for height is -y because -h is taken. Maybe width should be -x to match.
    opened by grahambates 0
  • Fix short options

    Fix short options

    • Quantise short option -q was not accepting args and was throwing an error
    • I forgot to add the short option -i for --index
    • Updated options docs in README to match the help text
    • Fixed a typo :-)
    opened by grahambates 0
Owner
Rich Elmes
Programmer / Electronic Musician, since 1983.
Rich Elmes
A Python Script to convert Normal PNG Image to Apple iDOT PNG Image.

idot-png-encoder A Python Script to convert Normal PNG Image to Apple iDOT PNG Image (Multi-threaded Decoding PNG). Usage idotpngencoder.py -i <inputf

Lrdcq 2 Feb 17, 2022
Png-to-stl - Converts PNG and text to SVG, and then extrudes that based on parameters

have ansible installed locally run ansible-playbook setup_application.yml this sets up directories, installs system packages, and sets up python envir

null 1 Jan 3, 2022
Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

Pyconvert is a python script that you can use to convert image files to another image format! (eg. PNG to ICO)

null 1 Jan 16, 2022
Png2Jpg tool will help you convert from png image format to jpg images format.

PNG 2 JPG All codes assume running from root directory. Please update the sys path at the beginning of the codes before running. Over View Png2Jpg too

Nguyễn Trường Lâu 2 Dec 27, 2021
Convert the SVG code to PNG and replace the line by a call to the image in markdown

Convert the SVG code to PNG and replace the line by a call to the image in markdown

null 6 Sep 6, 2022
A simple programme for converting url into a qr code (.png file)

QrTk A simple lightweight programme for converting url into a qr code (.png file) Pre-Requisites Before installing the programme , you need to run the

Juss Patel 4 Nov 8, 2021
Glyphtracer is an app for converting images of letters to a font

Glyphtracer takes an image that contains pictures of several letters. It recognizes all them and lets the user tag each letter to a Unicode code point. It then converts the images to vector form and writes them to a FontForge's data format. The font can then be finalized with FontForge.

Jussi Pakkanen 38 Dec 24, 2022
This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character.

Room Formatter This tool allows the user to convert a 16 by 16 image into a list with numbers representing an object/character. There is cur

Thomas Landstra 1 Nov 13, 2021
Xmas-Tree-GIF-Tool - Convert any given animated gif file into an animation in GIFT CSV format

This repo is made to participate in Matt Parker's XmasTree 2021 event. Convert a

Aven Zitzelberger 2 Dec 30, 2021
Transfers a image file(.png) to an Excel file(.xlsx)

Transfers a image file(.png) to an Excel file(.xlsx)

Junu Kwon 7 Feb 11, 2022