Check systemfonts family for freetype compatibility
Source:R/venndir-systemfonts.R
check_systemfonts_family.RdCheck systemfonts family for freetype compatibility
Arguments
- family
charactervector with font family names.- path
character, default NULL, with optional file path to one or more specific font files. When provided, the 'family' argument is ignored.- debug
logicalwhether to print any error message, default is FALSE.- ...
additional arguments are passed to
systemfonts::font_info(), which may be useful to specify arguments such as:italic=TRUE,weight="bold", orwidth="condensed"for example. Alternatively, argumentpathcan be used to point to a specific font file, thereby circumventing family and style.
Value
integer vector with the number of valid font info rows
returned by systemfonts::font_info(), for each entry provided
in family.
Details
This function simply checks whether the systemfonts API for freetype recognizes a font file being valid, given a font family value. The main purpose is to avoid trying to use a font family which would may produce an error, since it may terminate the R session.
It is thin a wrapper for systemfonts::font_info().
When a font 'fails' it causes an error that can be reviewed with argument
debug=TRUE. The error is usually this format:
"Failed to open font file (/font/path/family.ttf) with freetype error 6"
The error originates from the freetype API, and means the file is not usable by that API. It sometimes happens when a font file has a newer format than is recognized by the freetype API.
See also
Other venndir internal:
assemble_venndir_label(),
assign_degree_groups(),
expand_range(),
get_venn_polygon_shapes(),
make_degrees_clockwise(),
make_venn_combn_df(),
match_list(),
print_color_df(),
render_venndir_footnotes(),
shrink_df(),
simple_ellipse(),
subset_systemfonts(),
venndir_label_style(),
venndir_to_df()
Examples
check_systemfonts_family(c("Noto Sans Syriac", "Skia", "PingFang TC", "Arial"))
#> Noto Sans Syriac Skia PingFang TC Arial
#> 0 0 1 1
check_systemfonts_family(c("Arial", "Arial"))
#> Arial Arial
#> 1 1
xpaths <- subset_systemfonts(grepl("Helvetica", family), trim_path=FALSE)$path
check_systemfonts_family(xpaths[1])
#> /System/Library/Fonts/Helvetica.ttc
#> 1