Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use first value when creating glyphFont. #184

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/library/grDevices/R/glyph.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mapCharWeight <- function(x) {
if (is.na(x))
x
else
else
switch(as.character(x),
normal=400,
bold=700,
Expand All @@ -19,7 +19,7 @@ mapWeight <- function(x) {
x
} else {
sapply(x, mapCharWeight, USE.NAMES=FALSE)
}
}
}

fontStyles <- c("normal", "italic", "oblique")
Expand Down Expand Up @@ -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)) {
Expand All @@ -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)
Expand Down
29 changes: 19 additions & 10 deletions src/library/grDevices/man/glyphInfo.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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"}).}
Expand All @@ -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
Expand All @@ -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.
Expand Down
Loading