Learn R Programming

grDevices (version 3.4.0)

windowsFonts: Windows Fonts

Description

These functions handle the translation of a device-independent R graphics font family name to a windows font description.

Usage

windowsFont(family)

windowsFonts(...)

Arguments

family
a character vector containing the font family name ("TT" as the first two characters indicates a TrueType font).
either character strings naming mappings to display, or new (named) mappings to define.

Details

A windows device is created with a default font (see the documentation for windows), but it is also possible to specify a font family when drawing to the device (for example, see the documentation for "family" in par and for "fontfamily" in gpar in the grid package). The font family sent to the device is a simple string name, which must be mapped to something more specific to windows fonts. A list of mappings is maintained and can be modified by the user. The windowsFonts function can be used to list existing mappings and to define new mappings. The windowsFont function can be used to create a new mapping. Default mappings are provided for three device-independent font family names: "sans" for a sans-serif font, "serif" for a serif font and "mono" for a monospaced font. These mappings will only be used if the current font face is 1 (plain), 2 (bold), 3 (italic), or 4 (bolditalic).

See Also

windows

Examples

Run this code
windowsFonts()
windowsFonts("mono")

## Not run: ------------------------------------
# ## set up for Japanese: needs the fonts installed
# windows()  # make sure we have the right device type
# Sys.setlocale("LC_ALL", "ja")
# windowsFonts(JP1 = windowsFont("MS Mincho"),
#              JP2 = windowsFont("MS Gothic"),
#              JP3 = windowsFont("Arial Unicode MS"))
# plot(1:10)
# text(5, 2, "\u{4E10}\u{4E00}\u{4E01}", family = "JP1")
# text(7, 2, "\u{4E10}\u{4E00}\u{4E01}", family = "JP1", font = 2)
# text(5, 1.5, "\u{4E10}\u{4E00}\u{4E01}", family = "JP2")
# text(9, 2, "\u{5100}", family = "JP3")
## ---------------------------------------------

Run the code above in your browser using DataLab