- In 'recent' times the fonts started to carry the design feature as well. Conventional fonts, like Computer Modern, Times, Palatino, Book Antiqua, are derived from roman engraved fonts - serifs make the line end look smooth - and improved to be easy to read and not to disturb the screen when in large paragraphs.
- The font Zhongyi Songti (中易宋体), better known by its English name SimSun, and its predecessor, New Songti (NSimsun - 新宋体) is the Times New Roman of Simplified Chinese, made popular due to its out-of-the-box inclusion in Windows XP. The Simsun love affair continued until very recently: it was still the default Simplified Chinese.
If none of the given fonts are installed, then it will display the default font face Times New Roman. Note − Check a complete list of HTML Standard Fonts. Setting Font Color. Source: R/font.R. Change the appearance of the main title, subtitle, caption, axis labels and text, as well as the legend title and texts.
2021-02-18
svglite produces SVG files containing plain text but fonts are still important for plot generation and rendering. Fonts are used during SVG generation to figure out the metrics of graphical elements. The font name is then recorded in the font-family
property of text anchors so that SVG renderers know what fonts to use. svglite does try to ensure a consistent figure rendering even when fonts are not available at the time of rendering (by supplying the textLength SVG text attribute). However, the text may look slightly distorted when a fallback font is used. This means that for optimal display, the font must be available on both the computer used to create the svg, and the computer used to render the svg. The defaults are fonts that are available on almost all systems: there may be small differences between them, but they are unlikely to cause problems in most causes.
R family | Font on Windows | Font on Unix |
---|---|---|
sans | Arial | Arial |
serif | Times New Roman | Times |
mono | Courier | Courier |
symbol | Standard Symbols L | Symbol |
One downside to these default fonts is that they do not have good coverage of characters for non-latin alphabets. This can be fixed by using the arguments system_fonts
and user_fonts
which provide control over which fonts to use during SVG generation and rendering.
System font aliases
system_fonts
takes a named list of font families as argument. The names typically correspond to standard R faces but they can also alias non-standard families (though this is less useful):
If you need support for non-latin characters, choose fonts with good Unicode coverage. 'Arial Unicode MS' is a sans serif font with good coverage that is available on macOS and Windows systems (on the latter, only if MS Office is installed). Note that this font does not support kerning and has no bold or italic faces.
The Noto fontset provided by Google as well as the Han Sans family by Adobe have excellent coverage but may not be available at the time of rendering. This can be a concern if you distribute the SVG files on the Internet.
User font aliases
In addition to system fonts, you can also provide fonts that are not necessarily installed on the system (i.e., fonts that live in user space). The main reason to do this is to generate reproducible SVG files as different platforms can have different versions of a font and thus produce different text metrics. The user_fonts
arguments takes either paths to font files, fonts from the fontquiver
package, or a list that specifies the alias. Whereas system_fonts
gets a named list of families as argument, user_fonts
takes a named tree of lists of families (sans
, serif
, mono
and symbol
) and faces (plain
, italic
, bold
, bolditalic
, symbol
):
You can also control which font gets written in the font-family
fields of SVGs by supplying a list containing alias
and file
elements:
fontquiver
fonts are particularly useful for creating reproducible SVG files. The vdiffr
package uses svglite with fontquiver fonts to create visual unit tests reliably across platforms. The Liberation fontset is appropriate for this usage because it features all 12 combinations of standard R families and faces. In addition fontquiver provides Symbola for the symbol font. The function fontquiver::font_families()
produces a list with the appropriate structure and can be directly supplied to svglite:
Change Font To Times New Roman
Debugging font matching
Debugging font matching
Changing Font To Times New Roman In R Studio 3.5
The systemfonts package is used to match font family names to fonts installed on the system. systemfonts will always return a valid font, but if the requested font is badly misspelled or missing, a default will be returned. To test if the expected font is matched you can use the match_font()
and font_info()
functions from systemfonts: