Skip to contents

read_yaff() reads in yaff format bitmap font files as a bm_font() object while write_yaff() writes a bm_font() object as a yaff format bitmap font file.

Usage

read_yaff(con, ..., fg = "#000000FF")

write_yaff(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.

...

Currently ignored.

fg

Foreground color used when reading greyscale fonts (i.e. when the yaff levels property is greater than 2). An R color string in any format accepted by col2hex(). Its RGB values are used for the pixel color and its alpha is multiplied by the level fraction to determine pixel alpha. Default is "#000000FF" (opaque black).

font

A bm_font() object.

Value

read_yaff() returns a bm_font() object. write_yaff() returns invisibly a character vector of the contents of the yaff font file it wrote to con as a side effect.

See also

bm_font() for information about bitmap font objects. For more information about yaff font format see https://github.com/robhagemans/monobit#the-yaff-format.

Examples

 # May take more than 5 seconds on CRAN servers
 font_file <- system.file("fonts/fixed/4x6.yaff.gz", package = "bittermelon")
 font <- read_yaff(font_file)
 capital_r <- font[[str2ucp("R")]]
 print(capital_r)
#> ██░░
#> █░█░
#> ██░░
#> █░█░
#> █░█░
#> ░░░░

 filename <- tempfile(fileext = ".yaff")
 write_yaff(font, filename)