From 4a3cd5ce6e951427da4dba5ef3507acb28015f6d Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Sun, 11 Feb 2024 14:19:24 +0100 Subject: [PATCH] Add weight, cross reference in docs --- R/paint.R | 3 ++- man/painting.Rd | 5 +++-- src/options.cpp | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/R/paint.R b/R/paint.R index d93e4d6..f418f39 100644 --- a/R/paint.R +++ b/R/paint.R @@ -55,8 +55,9 @@ image_fill <- function(image, color, point = "+1+1", fuzz = 0, refcolor = NULL){ #' for background color that annotation text is rendered on. #' @param font string with font family such as `"sans"`, `"mono"`, `"serif"`, #' `"Times"`, `"Helvetica"`, `"Trebuchet"`, `"Georgia"`, `"Palatino"` or `"Comic Sans"`. +#' See [magick_fonts()] for what is available. #' @param style value of [style_types][style_types] for example `"italic"` -#' @param weight thickness of the font, 400 is normal and 700 is bold. +#' @param weight thickness of the font, 400 is normal and 700 is bold, see [magick_fonts()]. #' @param kerning increases or decreases whitespace between letters #' @param decoration value of [decoration_types][decoration_types] for example `"underline"` #' @examples # Add some text to an image diff --git a/man/painting.Rd b/man/painting.Rd index 868d49f..5699fe8 100644 --- a/man/painting.Rd +++ b/man/painting.Rd @@ -56,11 +56,12 @@ value from \link{gravity_types}.} \item{size}{font-size in pixels} \item{font}{string with font family such as \code{"sans"}, \code{"mono"}, \code{"serif"}, -\code{"Times"}, \code{"Helvetica"}, \code{"Trebuchet"}, \code{"Georgia"}, \code{"Palatino"} or \code{"Comic Sans"}.} +\code{"Times"}, \code{"Helvetica"}, \code{"Trebuchet"}, \code{"Georgia"}, \code{"Palatino"} or \code{"Comic Sans"}. +See \code{\link[=magick_fonts]{magick_fonts()}} for what is available.} \item{style}{value of \link{style_types} for example \code{"italic"}} -\item{weight}{thickness of the font, 400 is normal and 700 is bold.} +\item{weight}{thickness of the font, 400 is normal and 700 is bold, see \code{\link[=magick_fonts]{magick_fonts()}}.} \item{kerning}{increases or decreases whitespace between letters} diff --git a/src/options.cpp b/src/options.cpp index 4e30ad1..7a1dfe7 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -33,6 +33,7 @@ Rcpp::DataFrame list_font_info(){ Rcpp::CharacterVector name(number_fonts); Rcpp::CharacterVector family(number_fonts); Rcpp::CharacterVector glyphs(number_fonts); + Rcpp::IntegerVector weight(number_fonts); for (int i = 0; i < number_fonts; i++){ if(type_info[i]->name) name[i] = type_info[i]->name; @@ -40,11 +41,14 @@ Rcpp::DataFrame list_font_info(){ family[i] = type_info[i]->family; if(type_info[i]->glyphs) glyphs[i] = type_info[i]->glyphs; + if(type_info[i]->weight) + weight[i] = type_info[i]->weight; } MagickCore::RelinquishMagickMemory((void *) type_info); return Rcpp::DataFrame::create( Rcpp::_["name"] = name, Rcpp::_["family"] = family, + Rcpp::_["weight"] = weight, Rcpp::_["glyphs"] = glyphs, Rcpp::_["stringsAsFactors"] = false );