read_monobit() reads in bitmap font file as a bm_font() object while write_monobit()
writes a bm_font() object as a bitmap font file.
It uses the file extension to determine the appropriate bitmap font format to use.
Arguments
- file
A character string of a filename.
- ...
Further arguments passed to
read_yaff().- quietly
If
TRUEsuppress any standard output/error frommonobit-convert.- monobit_path
Path/name of
monobit-convertto use. Passed tobase::Sys.which().- font
A
bm_font()object.
Value
read_monobit() returns a bm_font() object. write_monobit() returns NULL invisibly and
as a side effect writes file.
Details
read_monobit()andwrite_monobit()require that themonobit-convertcommand is available on the system.read_monobit()andwrite_monobit()usesmonobit-convertto convert to/from the yaff font format which this package can natively read/write from/to.One may install
monobit-convertusingpip3 install monobit.For more information about
monobitsee https://github.com/robhagemans/monobit.
See also
bm_font() for more information about bitmap font objects.
read_hex(), write_hex(), read_yaff(), write_yaff() for pure R bitmap font readers and writers.
Examples
# May take more than 5 seconds on CRAN servers
if (nzchar(Sys.which("monobit-convert"))) {
try({
font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_monobit(font_file)
capital_r <- font[[str2ucp("R")]]
print(capital_r)
filename <- tempfile(fileext = ".yaff")
write_monobit(font, filename)
})
}
#> ░░░░░░░░
#> ░░░░░░░░
#> ██████░░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ██████░░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ██░░░██░
#> ░░░░░░░░
#> ░░░░░░░░
#> ░░░░░░░░
#> ░░░░░░░░