Giter VIP home page Giter VIP logo

tigrfont's Introduction

tigrfont - bitmap font sheet generator for TIGR

tigrfont is a commandline tool for creating bitmap font sheets for TIGR from TTF/OTF or BDF font files.

TIGR font sheets are simply PNG files with rows of white characters on a transparent background, separated by single-colored borders:

This is the default font included in TIGR, and has a black drop shadow. The font sheets created by tigrfont don't have shadows.

Installation

Get pre-built binaries for Linux, Windows or OSX or install using your local golang setup:

$ go install github.com/erkkah/tigrfont

BDF to TIGR

Creating font sheets from BDF files is straightforward, since they are bitmap fonts already:

$ tigrfont 5x7.bdf 5x7.png

TTF to TIGR

Converting from TTF files often requires a bit more testing and tweaking, depending on the specifics of the font.

Since TTF fonts are vector fonts, they are rendered to a bitmap before being exported as the final font sheet.

The rendering uses anti-aliasing, which will cause visible semi-transparent smudges at the low resolutions typically used with TIGR.

YMMV ๐Ÿš—

Font resolution and size

The font is rendered at a given dpi, by default 72.

The font size is specified in points, by default 18.

Since apparent character height for a given point size varies a lot between fonts, tigrfont can measure the height of an 'X' and adjust the effective point size to make the 'X' render with a height of the given point size.

For example, running

$ tigrfont -mx -size 20 myfont.ttf myfont.png

will render a font sheet at a size where a capital 'X' is 20 pixels high, since pixels equal points at 72 DPI.

You can also use -m <char> to measure using any character.

Unicode and codepages

TIGR, and tigrfont traditionally support two codepages, ASCII (code points 32 to 127) and CP-1252 (code points 32 to 255). Font sheets created using CP-1252 (the default) are loaded like this:

Tigr* fontImage = tigrLoadImage("font.png");
TigrFont* font = tigrLoadFont(fontImage, TCP_1252);

Unicode sheets

Since version 1.0, tigrfont supports sparse unicode-encoded font sheets. Note that TIGR version 3.1 is needed to use these font sheets.

Instead of simply enumerating code points, as in the ASCII and CP-1252 cases, the set of code points to include is specified using either the -encoding or the -sample option.

The -encoding argument accepts an HTML5 encoding name and tries to extract the set of code points covered by that encoding. This often generates a superset of code points. For example, specifying "gbk" or "gb3212" results in the same large set of code points.

Using the -sample option, you can specify a UTF-8 encoded text file containing the code points you want in the font sheet. Since duplicates are allowed, you can simply specify a sample text file with the code points needed.

If you look at the generated unicode font sheets, you might notice that there are semi-transparent sections in the borders around the characters. This is since the alpha channel is used to store code point info. ๐Ÿง 

tigrfont's People

Contributors

erkkah 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

Watchers

 avatar  avatar  avatar

tigrfont's Issues

Invalid code page 1251

When try to make cyrillic font (cp 1251), returns error message:

tigrfont -mx -size 20 -cp 1251 arialbd.ttf arialbd.png

invalid TIGR codepage: invalid

Seems that -cp option accepts only 0 and the default 1252.

Thank you!

Thank you very much, the tool is awesome!

Problems installing it...

I don't know the minimum requirements regarding the go version, I tried with the latest and then the first previous versions and from both I get the following message:

go: downloading github.com/erkkah/tigrfont v1.0.1
go: github.com/erkkah/tigrfont@latest (in github.com/erkkah/[email protected]):
The go.mod file for the module providing named packages contains one or
more replace directives. It must not contain directives that would cause
it to be interpreted differently than if it were the main module.

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.