Skip to contents

bm_bytepad() pads the width of bitmaps to the nearest multiple of 8 by padding with pixels on the right.

Usage

bm_bytepad(x, ...)

Arguments

x

Either a bm_bitmap(), bm_font(), bm_list(), "magick-image", "nativeRaster", bm_pixmap(), or "raster" object.

...

Passed to bm_extend() along with hjust = "left" and width_multiples_of = 8L.

Value

Depending on x either a bm_bitmap(), bm_font(), bm_list(), magick-image, "nativeRaster", bm_pixmap(), or raster object.

Details

This is required by the BDF font format, which specifies that each row of bitmap data must be padded with zero bits on the right to the nearest byte.

See also

Examples

font_file <- system.file("fonts/spleen/spleen-8x16.hex.gz", package = "bittermelon")
font <- read_hex(font_file)
capital_r <- font[[str2ucp("R")]]
ncol(capital_r) # already 8 pixels wide
#> [1] 8
capital_r_7 <- bm_trim(capital_r, right = 1L)
ncol(capital_r_7) # trimmed to 7 pixels wide
#> [1] 7
capital_r_8 <- bm_bytepad(capital_r_7)
ncol(capital_r_8) # padded back to 8 pixels wide
#> [1] 8
all.equal(capital_r, capital_r_8)
#> [1] TRUE