Skip to contents

Write kanji to a graphics device.

Usage

plotkanji(
  kanji,
  device = "default",
  family = NULL,
  factor = 10,
  width = NULL,
  height = NULL,
  ...
)

Arguments

kanji

a vector of class character specifying one or several kanji to be plotted.

device

the type of graphics device where the kanji is plotted. Defaults to the user's default type according to getOption("device").

family

the font family or families used for writing the kanji. Make sure to add the font(s) first by using font_add; see details. If family is a vector of several font families they are matched to the characters in kanji (and possibly recycled).

factor

a maginification factor applied to the font size (typically 12 points).

width, height

the dimensions of the device.

...

further parameters passed to the function opening the device (such as a file name for devices that create a file).

Value

No return value, called for side effects.

Details

This function writes one or several kanji to a graphics device in an arbitrary font that has been registered, i.e., added to the database in package sysfonts. For the latter say font_add or font_families to verify what fonts are available.

For further information see Working with Japanese fonts in vignette("kanjistat", package = "kanjistat"). plotkanji uses the package showtext to write the kanji in a large font at the center of a new device of the specified type. specify device = "current" to write the kanji to the current device. It is now recommended to simply use graphics::text in combination with showtext::showtext_auto instead.

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

plotkanji("滝")   
plotkanji("犬猫魚")