bitsweetfont

package module
v0.0.0-...-2e6ac9b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 9 Imported by: 1

README

bitsweetfont

Font preview

Overview

A bitmap font for Go, made with bitfontier. It's designed to be used in pixel art games.

Currently, it only supports two "languages" and some extra symbols:

  • English
  • Russian
  • Extra misc symbols

It has two base sizes: 1 and 1.3. If you take Scale() function into account, we get many sizes to choose from:

  • 1
  • 1.3
  • 2
  • 2.6
  • 3
  • 3.9
  • 4

If you want to contribute new images for this pack, please keep in mind that I want to keep the license as open as possible to make this font easy plug-and-play without any multi-level attribution paperwork.

This is a simple font and by no means universal (look at the tiny number of languages it supports!) At the same time, it should be a good example on how to make bitmap fonts for your games using bitfontier. Good luck!

See fontinfo.md to see a full list of runes supported.

Installation

$ go get github.com/quasilyte/bitsweetfont

Usage

// import "github.com/quasilyte/bitsweetfont"

// ff is a font.Face of a base size 1.
ff := bitsweetfont.New1()

// It's possible to create programmatically scaled versions
// of the base fonts.
// Only whole scaling factors are available (2, 3, 4, ...)
ff2 := bitsweetfont.Scale(ff, 2)
ff3 := bitsweetfont.Scale(ff, 3)

Building Font

This repository already contains a built font for you to use.

But if you want to re-generate it with some other bitfontier options, it's also possible.

Take a look at Makefile's font target.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New1

func New1() font.Face

New1 allocates a font of size=1.

Allocating several instances of the same-sized font is unadvised as they would not share the resources.

func New1_3

func New1_3() font.Face

New1_3 allocates a font of size=1.3.

Allocating several instances of the same-sized font is unadvised as they would not share the resources.

func Scale

func Scale(f font.Face, scaling uint) font.Face

Scale takes the bitmap font and returns its scaled version. Scaling the font is efficient and doesn't extra memory.

A scaling factor of 1 is a no-op. A scaling factor of 2 makes the pixels twice as big.

This function will only work with fonts created by this package. Any other font will make it panic.

Types

This section is empty.

Jump to

Keyboard shortcuts

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