Package 'lofifonts'

Title: Text Rendering with Bitmap and Vector Fonts
Description: Alternate font rendering is useful when rendering to novel graphics outputs where modern font rendering is not available or not appropriate. Bitmap and vector fonts allow for bespoke rendering using pixel coordinates and line drawing. A selection of fonts is included and all can be rendered to a matrix of pixel locations or returned as pixel coordinates and collections of stroke endpoints.
Authors: Mike Cheng [aut, cre, cph], Frederic Cambus [aut, cph] (Creator of 'spleen' font), GNU Unifont authors [cph] (Creators of 'unifont'), Anders Hoff [aut, cph] (Creator of 'gridfont' font)
Maintainer: Mike Cheng <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0.9000
Built: 2024-10-29 13:26:42 UTC
Source: https://github.com/coolbutuseless/lofifonts

Help Index


Create a data.frame of pixel coordinate information of the rendered text

Description

Create a data.frame of pixel coordinate information of the rendered text

Usage

bitmap_text_coords(text, font = "unifont", line_height = NULL, missing = NULL)

Arguments

text

Single text string. Can include carriage returns.

font

Name of bitmap font. One of the following:

  • spleen: "spleen-12x24", "spleen-16x32", "spleen-32x64", "spleen-5x8", "spleen-6x12", "spleen-8x16"

  • tamzen: "Tamzen10x20b", "Tamzen10x20r", "Tamzen5x9b", "Tamzen5x9r", "Tamzen6x12b", "Tamzen6x12r", "Tamzen7x13b", "Tamzen7x13r", "Tamzen7x14b", "Tamzen7x14r", "Tamzen8x15b", "Tamzen8x15r", "Tamzen8x16b", "Tamzen8x16r"

  • "unifomt" (the default)

  • unscii: "unscii-8", "unscii-8-thin"

line_height

Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight.

missing

Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?'

Value

data.frame of coordinate information

char_idx

The index of the character within the provided text string

codepoint

Unicode codepoint (integer)

x

Pixel coordinate x value for display

y

Pixel coordinate y value for display

line

Line number within input text where this character appears

x0

Original untransformed x-coordinate

y0

Original untransformed y-coordinate

See Also

Other bitmap text functions: bitmap_text_matrix(), bitmap_text_raster()

Examples

bitmap_text_coords('Hi')

Create a binary matrix of the rendered text

Description

Create a binary matrix of the rendered text

Usage

bitmap_text_matrix(
  text,
  font = "unifont",
  line_height = NULL,
  scale = 1,
  missing = NULL
)

Arguments

text

Single text string. Can include carriage returns.

font

Name of bitmap font. One of the following:

  • spleen: "spleen-12x24", "spleen-16x32", "spleen-32x64", "spleen-5x8", "spleen-6x12", "spleen-8x16"

  • tamzen: "Tamzen10x20b", "Tamzen10x20r", "Tamzen5x9b", "Tamzen5x9r", "Tamzen6x12b", "Tamzen6x12r", "Tamzen7x13b", "Tamzen7x13r", "Tamzen7x14b", "Tamzen7x14r", "Tamzen8x15b", "Tamzen8x15r", "Tamzen8x16b", "Tamzen8x16r"

  • "unifomt" (the default)

  • unscii: "unscii-8", "unscii-8-thin"

line_height

Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight.

scale

Integer size scale factor. Default: 1. Must be an integer value >= 1. Scale up the matrix or raster result by this factor

missing

Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?'

Value

Binary matrix representation of the rendered text

See Also

Other bitmap text functions: bitmap_text_coords(), bitmap_text_raster()

Examples

bitmap_text_matrix('Hi')

Create a raster image of the rendered text

Description

Create a raster image of the rendered text

Usage

bitmap_text_raster(
  text,
  font = "unifont",
  line_height = NULL,
  scale = 1,
  missing = NULL
)

Arguments

text

Single text string. Can include carriage returns.

font

Name of bitmap font. One of the following:

  • spleen: "spleen-12x24", "spleen-16x32", "spleen-32x64", "spleen-5x8", "spleen-6x12", "spleen-8x16"

  • tamzen: "Tamzen10x20b", "Tamzen10x20r", "Tamzen5x9b", "Tamzen5x9r", "Tamzen6x12b", "Tamzen6x12r", "Tamzen7x13b", "Tamzen7x13r", "Tamzen7x14b", "Tamzen7x14r", "Tamzen8x15b", "Tamzen8x15r", "Tamzen8x16b", "Tamzen8x16r"

  • "unifomt" (the default)

  • unscii: "unscii-8", "unscii-8-thin"

line_height

Integer value for the vertical distance between multiple lines of text. Use this to override the font's lineheight. Default: NULL means to use the font's built-in lineheight.

scale

Integer size scale factor. Default: 1. Must be an integer value >= 1. Scale up the matrix or raster result by this factor

missing

Codepoint (integer) to use if glyph not found in font. Default: NULL means to use the default specified by the font internally. Otherwise it will default to the codepoint for '?'

Value

Raster image representation of the rendered text

See Also

Other bitmap text functions: bitmap_text_coords(), bitmap_text_matrix()

Examples

ras <- bitmap_text_raster('Hi')
plot(ras, interpolate = FALSE)

Font information

Description

Currently on includes font names and unicode codepoints available within each font

Usage

font_info

Format

An object of class list of length 2.


Font names

Description

Font names

Usage

font_names

Format

An object of class list of length 2.


Create data.frame of glyph information for the given text.

Description

Text input can contain multiple lines separated by carriage returns

Usage

vector_text_coords(
  text,
  font = c("gridfont", "gridfont_smooth", "arcade"),
  dx = 0,
  dy = 0,
  missing = utf8ToInt("?"),
  line_height = NULL
)

Arguments

text

Single text string. Can include carriage returns.

font

Name of vector font. One of c("arcade", "gridfont", "gridfont_smooth")

dx

Additional character spacing in the horizontal direction. Default: 0

dy

Additional character spacing in the vertical direction. Default: 0

missing

Codepoint to use if glyph not available in font. default: Codepoint for '?'

line_height

line height

Value

data.frame of stroke information

char_idx

The index of the character within the provided text string

codepoint

Unicode codepoint (integer)

stroke_idx

Index of the stroke within each character

point_idx

Index of the point within each stroke

x

Pixel coordinate x value for display

y

Pixel coordinate y value for display

width

Width of vector character

height

Height of vector character

x0

Original untransformed x-coordinate

y0

Original untransformed y-coordinate

line

Line number within input text where this character appears

See Also

Other vector text functions: vector_text_matrix(), vector_text_raster()

Examples

vector_text_coords('Hi')

Create a binary matrix of the rendered text

Description

Create a binary matrix of the rendered text

Usage

vector_text_matrix(
  text,
  font = c("gridfont", "gridfont_smooth", "arcade"),
  scale = 1,
  dx = NULL,
  dy = NULL,
  missing = utf8ToInt("?")
)

Arguments

text

Single text string. Can include carriage returns.

font

Name of vector font. One of c("arcade", "gridfont", "gridfont_smooth")

scale

Scale factor for text rendering. Numeric value greater than zero. Default: 1

dx

Additional character spacing in the horizontal direction. Default: 0

dy

Additional character spacing in the vertical direction. Default: 0

missing

Codepoint to use if glyph not available in font. default: Codepoint for '?'

Value

Binary matrix rendering of the font

See Also

Other vector text functions: vector_text_coords(), vector_text_raster()

Examples

vector_text_matrix("Hi")

Create a raster image of the rendered text

Description

Create a raster image of the rendered text

Usage

vector_text_raster(
  text,
  font = c("gridfont", "gridfont_smooth", "arcade"),
  scale = 10,
  dx = NULL,
  dy = NULL,
  missing = utf8ToInt("?")
)

Arguments

text

Single text string. Can include carriage returns.

font

Name of vector font. One of c("arcade", "gridfont", "gridfont_smooth")

scale

Scale factor for text rendering. Numeric value greater than zero. Default: 1

dx

Additional character spacing in the horizontal direction. Default: 0

dy

Additional character spacing in the vertical direction. Default: 0

missing

Codepoint to use if glyph not available in font. default: Codepoint for '?'

Value

Raster image of rendered text

See Also

Other vector text functions: vector_text_coords(), vector_text_matrix()

Examples

ras <- vector_text_raster("Hi")
plot(ras, interpolate = FALSE)