This is a convenience function that helps in creating rasterGrob with the
correct settings for the glyph. It takes inot account the sizing and offset
returned by glyph_raster() and allows you to only consider the baseline
position of the glyph.
Arguments
- glyph
The nativeRaster object returned as one of the elements by
glyph_raster()- x, y
The baseline location of the glyph
- ...
Arguments passed on to
grid::rasterGrobimageAny R object that can be coerced to a raster object.
widthA numeric vector or unit object specifying width.
heightA numeric vector or unit object specifying height.
justThe justification of the rectangle relative to its (x, y) location. If there are two values, the first value specifies horizontal justification and the second value specifies vertical justification. Possible string values are:
"left","right","centre","center","bottom", and"top". For numeric values, 0 means left alignment and 1 means right alignment.hjustA numeric vector specifying horizontal justification. If specified, overrides the
justsetting.vjustA numeric vector specifying vertical justification. If specified, overrides the
justsetting.nameA character identifier.
gpAn object of class
"gpar", typically the output from a call to the functiongpar. This is basically a list of graphical parameter settings.vpA Grid viewport object (or NULL).
interpolateA logical value indicating whether to linearly interpolate the image (the alternative is to use nearest-neighbour interpolation, which gives a more blocky result).
- default.units
A string indicating the default units to use if
x,y,width, orheightare only given as numeric vectors.
Examples
font <- font_info()
glyph <- glyph_info("R", path = font$path, index = font$index)
R <- glyph_raster(glyph$index, font$path, font$index, size = 150)
grob <- glyph_raster_grob(R[[1]], 50, 50)
grid::grid.newpage()
# Mark the baseline location
grid::grid.points(50, 50, default.units = "bigpts")
# Draw the glyph
grid::grid.draw(grob)
