Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

str_split_emoji

Split a string into emoji and non-emoji glyph runs


Description

In order to do correct text rendering, the font needed must be figured out. A common case is rendering of emojis within a string where the system emoji font is used rather than the requested font. This function will inspect the provided strings and split them up in runs that must be rendered with the emoji font, and the rest. Arguments are recycled to the length of the string vector.

Usage

str_split_emoji(
  string,
  family = "",
  italic = FALSE,
  bold = FALSE,
  path = NULL,
  index = 0
)

Arguments

string

A character vector of strings that should be splitted.

family

The name of the font family

italic

logicals indicating the font style

bold

logicals indicating the font style

path, index

path an index of a font file to circumvent lookup based on family and style

Value

A data.frame containing the following columns:

string

The substring containing a consecutive run of glyphs

id

The index into the original string vector that the substring is part of

emoji

A logical vector giving if the substring is a run of emojis or not

Examples

emoji_string <- "This is a joke\U0001f642. It should be obvious from the smiley"
str_split_emoji(emoji_string)

systemfonts

System Native Font Finding

v1.0.2
MIT + file LICENSE
Authors
Thomas Lin Pedersen [aut, cre] (<https://orcid.org/0000-0002-5147-4711>), Jeroen Ooms [aut] (<https://orcid.org/0000-0002-4035-0289>), Devon Govett [aut] (Author of font-manager), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.