ttfsample

command module
v0.0.0-...-26cdbce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 20 Imported by: 0

README

GoDoc Go Report Card GH Action Status OpenSSF Scorecard

ttfsample

Creates a sample image of a Truetype TTF font or Opentype OTF font.

ttfsample will take a font file as an input and create a PNG-image with a sample of the font.

For the License see LICENSE.

The program comes with a GNU Free Sans and Serif Bold True Type font which are under the GNU Free Font license.

https://www.gnu.org/software/freefont/license.html

There are a couple of options, primary being, that you can supply the text to be printed as an argument. But there is also a sensible default (see image).

When run with the font Arial Narrow, the result will look like this:

Sample

The name of the font will always be included, printed with a boring font, GNU FreeSansBold, that is always readable even if the font has only symbols.

Author: Stefan Schröder, 2019, 2023

Install and quickstart

go install github.com/StefanSchroeder/ttfsample/ttfsample@latest

ttfsample -fontfile somefont.ttf

will create a PNG image in the newly created directory png/.

Build

go build . 

will do the trick if your Go development environment is setup properly.

Options

-fontfile path/to/font.ttf

This is a mandatory option. Provide the path to the font, TTF or OTF. You can only process one font unless using the -walk option.

-hinting <none|full>

Set hinting to none to disable hinting. Default is full.

-dpi INTEGER

Default is 72. Set dots per inch.

-outdir STRING

The output directory where the image will be stored.

-size INTEGER

Font size in points. Default is 100. Use responsibly.

-spacing FLOAT

Defaults to 1.5. Distance between two lines.

- walk PATH

Recursively search the directory tree for fonts to print starting from PATH and not following symlinks.

Testing

Tested on Windows and Linux.

Run

go test

Documentation

Overview

Take a TTF or OTF font file and write a PNG image that contains a sample of that font.

SPDX: MIT

Written by Stefan Schröder. 2019, 2023

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL