nr_text_mono: Draw text on a native raster image using the built-in...

View source: R/nr-draw.R

nr_text_monoR Documentation

Draw text on a native raster image using the built-in monospaced bitmapped font.

Description

The only font currently available is 'spleen' - a monospace bitmap font from: https://github.com/fcambus/spleen

Usage

nr_text_mono(
  nr,
  x,
  y,
  str,
  color = "black",
  fontsize = 8L,
  hjust = 0.5,
  vjust = 0.5,
  use_alpha = TRUE
)

Arguments

nr

native raster image

x, y

coordinates of lower-left corner of text

str

character string

color

Color as a character string. Either a standard R color (e.g. 'blue', 'white') or a hex color of the form #rrggbbaa, #rrggbb, #rgba or #rgb

fontsize

height of font in pizels. Only valid values are 8, 12 and 16. Default: 8.

hjust, vjust

Justification of text relative to its (x,y) location. Default (0.5, 0.5) to centre the text at (x, y)

use_alpha

Use alpha channel when drawing? Logical. Default: TRUE

Details

The 'spleen' font is licensed under BSD and the license is included in this package as "LICENSE-spleen.txt". To view LICENSE:

cat(readLines(system.file('LICENSE-spleen.txt', package = 'nara')), sep = "\n")

Value

Invisibly return the supplied native raster image which was been modified in-place

Examples

w <- 150
h <- 30
nr <- nr_new(w, h, 'grey80')

nr_text_mono(nr, x = w/2, y = h/2, str = "Hello RStats!", fontsize = 16)
plot(nr)

nr <- nr_new(w, h, 'grey80')
nr_text_mono(nr, x = 0, y = 0, str = "Hello RStats!", hjust = 0, vjust = 1, fontsize = 16)
plot(nr)

nara documentation built on May 28, 2026, 5:07 p.m.