hex_font: Read and write hex bitmap font files

read_hexR Documentation

Read and write hex bitmap font files

Description

read_hex() reads in hex format bitmap font files as a bm_font() object while write_hex() writes a bm_font() object as a hex format bitmap font file.

Usage

read_hex(con, ucp = NULL)

write_hex(font, con = stdout())

Arguments

con

A connection object or a character string of a filename. See base::readLines() or base::writeLines() for more info. If it is a connection it will be explicitly closed.

ucp

Character vector of Unicode Code Points: glyphs not in this vector won't be read in. If NULL (default) read every glyph in the font.

font

A bm_font() object.

Value

read_hex() returns a bm_font() object. write_hex() returns invisibly a character vector of the contents of the hex font file it wrote to con as a side effect.

See Also

bm_font()

Examples

 font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
 font <- read_hex(font_file)
 capital_r <- font[[str2ucp("R")]]
 print(capital_r, px = px_ascii)

 filename <- tempfile(fileext = ".hex.gz")
 write_hex(font, gzfile(filename))

 font <- read_hex(font_file, ucp = block2ucp("Basic Latin"))
 capital_r <- font[[str2ucp("R")]]
 print(capital_r, px = px_ascii)

bittermelon documentation built on Feb. 16, 2023, 8:08 p.m.