R: Find best family match with fontconfig

match_family {gdtools} | R Documentation

## Find best family match with fontconfig

### Description

`match_family()` returns the best font family match for the fontconfig pattern constructed from the `bold` and `italic` arguments. The default pattern is bold italic to make sure the matched font has enough features to be used in R graphics (plain, bold, italic, bold italic). `match_font()` returns the font file from the best family match, along with some metada in the attributes.

### Usage

    match_family(font = "sans", bold = TRUE, italic = TRUE, debug = NULL)

    match_font(font = "sans", bold = FALSE, italic = FALSE, debug = NULL)

### Arguments

`font` | family or face to match.
`bold` | Wheter to match a font featuring a `bold` face.
`italic` | Wheter to match a font featuring an `italic` face.
`debug` | Flag for debugging FontConfig. Can be one of `"config"`, `"match"`. Alternatively, can be an integer that is directly used as environment variable for `FC_DEBUG` (see FontConfig documentation).

### Details

Fontconfig matching is controlled via the `fonts.conf` file. Use `debug = "config"` to make sure what configuration file it is currently using (there can be several installations on one system, especially on Macs). See https://www.freedesktop.org/software/fontconfig/fontconfig-user.html for more information about debugging flags.

### Examples

    ## Not run:
    # The first run can be slow when font caches are missing
    # as font files are then being scanned to build those font caches.
    match_family("sans")
    match_family("serif", bold = FALSE, italic = TRUE)

    match_font("Helvetica", bold = FALSE, italic = TRUE)
    match_font("Helvetica", debug = "config")

    ## End(Not run)

[Package gdtools version 0.1.6 Index]