kanjimat {kanjistat}R Documentation

Create kanjimat objects

Description

Create a (list of) kanjimat object(s), i.e. bitmap representations of a kanji using a certain font-family and other typographical parameters.

Usage

kanjimat(
  kanji,
  family = NULL,
  size = NULL,
  margin = 0,
  antialias = TRUE,
  save = FALSE,
  overwrite = FALSE,
  simplify = TRUE,
  ...
)

Arguments

kanji

a (vector of) character string(s) containing kanjis.

family

the font-family to be used. For details see vignette.

size

the sidelength of the (square) bitmap

margin

extra margin to around the character. Defaults to 0 which leaves a relatively slim margin. Can be negative, but risks cutting off parts of the character. Units are relative to size in steps of 1/32.

antialias

logical. Shall antialiasing be performed?

save

logical or character. If FALSE return the (list of) kanjimat object(s). Otherwise save the result as an rds file in the working directory (as kmatsave.rds) or under the file path provided.

overwrite

logical. If FALSE return an error (before any computations are done) if the designated file path already exists. Otherwise an existing file is overwritten.

simplify

logical. Shall a single kanjimat object be returned (instead a list of one) if kanji is a single kanji?

...

futher arguments passed to png. This is for extensibility. The only argument that may currently be used is type. Trying to change sizes, units, colors or fonts by this argument results in an error or an undesirable output.

Value

A list of objects of class kanjimat or, if only one kanji was specified and simplify is TRUE, a single objects of class kanjimat. If save = TRUE, the same is (saved and) still returned invisibly.

Warning

If no font family is provided, the default Chinese font WenQuanYi Micro Hei that comes with the package showtext is used. This means that the characters will typically be recognizable, but quite often look odd as Japanese characters. We strongly advised that a Japanese font is used as detailed above.

Examples

res <- kanjimat(kanji="\u85e4", size = 128)


[Package kanjistat version 0.9.1 Index]