Setting Options for 'showtext' package

Share:

Description

This function sets parameters that will affect the apprearance of the graphs created with showtext.

Usage

1

Arguments

...

Options to be set, expressed in name = value pairs. It can also be a list containing these pairs (for example, the list returned by a previous call of showtext.opts()). Currently accepted parameters are nseg and dpi. See the Options Used section.

Options Used

nseg

Parameter to control the smoothness of the outlines of glyphs, typically used in vector graphics devices such as pdf() and svg(). It is the number of line segments to approximate a piece of curve in the glyph. The larger nseg is, the smoother text outlines would be, but also with larger file size for vector graphics. Usually a value between 5~20 would be enough.

dpi

An integer that gives the resolution of the device. This parameter is only used in bitmap and on-screen graphics devices such as png() and x11(), to determine the pixel size of text from point size. For example, if dpi is set to 96, then a character with 12 point size will have a pixel size of 12 * 96 / 72 = 16.

Author(s)

Yixuan Qiu <http://statr.me/>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 
## Set dpi to 200
op = showtext.opts(dpi = 200)

png("dpi_200.png", 800, 800, res = 200)
par(family = "sans")
showtext.begin()

set.seed(123)
plot(density(rnorm(100)))

showtext.end()
dev.off()

## Restore old options
showtext.opts(op)

png("dpi_96.png", 800, 800, res = 96)
par(family = "sans")
showtext.begin()

set.seed(123)
plot(density(rnorm(100)))

showtext.end()
dev.off()

## End(Not run)