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 kanji.
- family
the font-family to be used. For details see vignette.
- size
the sidelength of the (square) bitmap
- margin
numeric. Extra margin around the character. Defaults to 0 which leaves a relatively slim margin. Positive values increase this margin, negative values decrease it (which usually cuts off part of the kanji).
- 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="藤", size = 128)
#> Warning: No font family specified. Characters will be represented in the CJK font WenQuanYi Micro Hei
#> that is included in the package showtext. The font targets Chinese writing and some strokes will
#> therefore look odd for Japanese kanji. It is strongly advised that you register a Japanese font.
#> See the package vignette for details.
#> This warning is displayed once every 8 hours.