diff --git a/src/library/grDevices/R/glyph.R b/src/library/grDevices/R/glyph.R index 4be8dabbba8..078c3141677 100644 --- a/src/library/grDevices/R/glyph.R +++ b/src/library/grDevices/R/glyph.R @@ -5,7 +5,7 @@ mapCharWeight <- function(x) { if (is.na(x)) x - else + else switch(as.character(x), normal=400, bold=700, @@ -19,7 +19,7 @@ mapWeight <- function(x) { x } else { sapply(x, mapCharWeight, USE.NAMES=FALSE) - } + } } fontStyles <- c("normal", "italic", "oblique") @@ -120,14 +120,14 @@ glyphFont <- function(file, index, nafile <- is.na(file) if (any(nchar(file[!nafile], "bytes") > 500)) warning("Font file longer than 500 will be truncated") - index <- as.integer(index) - family <- as.character(family) + index <- as.integer(index)[1] + family <- as.character(family)[1] nafamily <- is.na(family) if (any(nchar(family[!nafamily], "bytes") > 200)) warning("Font family longer than 200 will be truncated") - weight <- mapWeight(weight) - style <- mapStyle(style) - PSname <- as.character(PSname) + weight <- mapWeight(weight)[1] + style <- mapStyle(style)[1] + PSname <- as.character(PSname)[1] ## Missing PSname values are "estimated" naPS <- is.na(PSname) if (any(naPS)) { @@ -151,7 +151,7 @@ glyphFont <- function(file, index, names <- rle(PSname)$lengths if (!(all(families == files) && all(files == names))) stop("Font information is inconsistent") - + font <- list(file=file, index=index, family=family, weight=weight, style=style, PSname=PSname) diff --git a/src/library/grDevices/man/glyphInfo.Rd b/src/library/grDevices/man/glyphInfo.Rd index 9c57a6db616..4ef51058c3e 100644 --- a/src/library/grDevices/man/glyphInfo.Rd +++ b/src/library/grDevices/man/glyphInfo.Rd @@ -25,7 +25,7 @@ } \usage{ -glyphInfo(id, x, y, font, size, fontList, +glyphInfo(id, x, y, font, size, fontList, width, height, hAnchor, vAnchor, col=NA, rot=0) @@ -42,30 +42,34 @@ glyphJust(just, ...) \method{glyphJust}{numeric}(just, which=NULL, ...) } \arguments{ - \item{id}{Numeric vector of glyph identifiers (index of glyph within - font file).} + \item{id}{Numeric glyph identifier (index of glyph within + font file). Vectors with length > 1 are truncated.} \item{x, y}{Numeric locations of glyphs in (big) points (1/72 inches).} \item{font}{Integer index into \code{fontList}.} - \item{size}{Numeric size of glyphs (in points).} - \item{fontList}{List of glyph fonts, as generated by \code{glyphFont()}.} + \item{size}{Numeric size of glyph (in points). Vectors with length > 1 are truncated.} + \item{fontList}{List of glyph fonts, as generated by \code{glyphFontList()}.} \item{width}{Overall width of glyphs. Can be a single numeric value, but can also be the result from a call to \code{glyphWidth()}.} \item{height}{Overall height of glyphs. Can be a single numeric value, but can also be the result from a call to \code{glyphHeight()}.} \item{hAnchor}{Horizontal anchors for justifying glyphs relative to the - (\code{x}, \code{y}) location. Can be a + (\code{x}, \code{y}) location. Can be a single numeric value (against which to \code{"left"} justify), but can also be result from a call to \code{glyphAnchor()}.} - \item{vAnchor}{Vertical anchors for justifying glyphs relative to the + \item{vAnchor}{Vertical anchors for justifying glyphs relative to the (\code{x}, \code{y}) location. Can be a single numeric value - (against which to \code{"bottom"} justify), + (against which to \code{"bottom"} justify), but can also be result from a call to \code{glyphAnchor()}.} \item{col}{An R colour value for each glyph. Can be \code{NA}.} +<<<<<<< glyph2 + \item{file}{Character path to a font file.} +======= \item{rot}{The angle to rotate each glyph.} \item{file}{Character path to font file.} +>>>>>>> main \item{index}{Numeric index of font within font file.} - \item{family}{Character name of font family.} + \item{family}{Character name of a font family.} \item{weight}{Numeric weight of glyphs (400 is normal, 700 is bold).} \item{style}{Character style of glyphs (\code{"normal"}, \code{"italic"}, or \code{"oblique"}).} @@ -89,6 +93,11 @@ glyphJust(just, ...) return values that can be used to specify \code{width}, \code{height}, \code{hAnchor}, and \code{vAnchor} values to \code{glyphInfo()}. } + + \code{glyphFont()} returns a single glyph font object. + + \code{glyphFontList()} returns a list of glyph fonts. + \details{ Multiple anchors can be specified so as to allow different character-based justifications of the glyphs relative to the @@ -114,7 +123,7 @@ glyphJust(just, ...) numeric-based justifications of the glyphs relative to the (\code{x}, \code{y}) location, e.g., \code{0} for left-justification and \code{1} for right-justification, but with any value in between - or even outside those limits also possible. + or even outside those limits also possible. A width with label \code{"width"}, relative to the \code{"left"} horizontal anchor, is required, but if a single numeric value is given, that is assumed to be the required width.