EVOLUTION-MANAGER
Edit File: shape_string.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Calculate glyph positions for strings</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for shape_string {systemfonts}"><tr><td>shape_string {systemfonts}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Calculate glyph positions for strings</h2> <h3>Description</h3> <p>Do basic text shaping of strings. This function will use freetype to calculate advances, doing kerning if possible. It will not perform any font substitution or ligature resolving and will thus be much in line with how the standard graphic devices does text shaping. Inputs are recycled to the length of <code>strings</code>. </p> <h3>Usage</h3> <pre> shape_string( strings, id = NULL, family = "", italic = FALSE, bold = FALSE, size = 12, res = 72, lineheight = 1, align = "left", hjust = 0, vjust = 0, width = NA, tracking = 0, indent = 0, hanging = 0, space_before = 0, space_after = 0, path = NULL, index = 0 ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>strings</code></td> <td> <p>A character vector of strings to shape</p> </td></tr> <tr valign="top"><td><code>id</code></td> <td> <p>A vector grouping the strings together. If strings share an id the shaping will continue between strings</p> </td></tr> <tr valign="top"><td><code>family</code></td> <td> <p>The name of the font family</p> </td></tr> <tr valign="top"><td><code>italic</code></td> <td> <p>logicals indicating the font style</p> </td></tr> <tr valign="top"><td><code>bold</code></td> <td> <p>logicals indicating the font style</p> </td></tr> <tr valign="top"><td><code>size</code></td> <td> <p>The pointsize of the font to use for size related measures</p> </td></tr> <tr valign="top"><td><code>res</code></td> <td> <p>The ppi of the size related mesures</p> </td></tr> <tr valign="top"><td><code>lineheight</code></td> <td> <p>A multiplier for the lineheight</p> </td></tr> <tr valign="top"><td><code>align</code></td> <td> <p>Within text box alignment, either <code>'left'</code>, <code>'center'</code>, or <code>'right'</code></p> </td></tr> <tr valign="top"><td><code>hjust, vjust</code></td> <td> <p>The justification of the textbox surrounding the text</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>The requested with of the string in inches. Setting this to something other than <code>NA</code> will turn on word wrapping.</p> </td></tr> <tr valign="top"><td><code>tracking</code></td> <td> <p>Tracking of the glyphs (space adjustment) measured in 1/1000 em.</p> </td></tr> <tr valign="top"><td><code>indent</code></td> <td> <p>The indent of the first line in a paragraph measured in inches.</p> </td></tr> <tr valign="top"><td><code>hanging</code></td> <td> <p>The indent of the remaining lines in a paragraph measured in inches.</p> </td></tr> <tr valign="top"><td><code>space_before, space_after</code></td> <td> <p>The spacing above and below a paragraph, measured in points</p> </td></tr> <tr valign="top"><td><code>path, index</code></td> <td> <p>path an index of a font file to circumvent lookup based on family and style</p> </td></tr> </table> <h3>Value</h3> <p>A list with two element: <code>shape</code> contains the position of each glyph, relative to the origin in the enclosing textbox. <code>metrics</code> contain metrics about the full strings. </p> <p><code>shape</code> is a data.frame with the following columns: </p> <dl> <dt>glyph</dt><dd><p>The glyph as a character</p> </dd> <dt>index</dt><dd><p>The index of the glyph in the font file</p> </dd> <dt>metric_id</dt><dd><p>The index of the string the glyph is part of (referencing a row in the <code>metrics</code> data.frame)</p> </dd> <dt>string_id</dt><dd><p>The index of the string the glyph came from (referencing an element in the <code>strings</code> input)</p> </dd> <dt>x_offset</dt><dd><p>The x offset in pixels from the origin of the textbox</p> </dd> <dt>y_offset</dt><dd><p>The y offset in pixels from the origin of the textbox</p> </dd> <dt>x_mid</dt><dd><p>The x offset in pixels to the middle of the glyph, measured from the origin of the glyph</p> </dd> </dl> <p><code>metrics</code> is a data.frame with the following columns: </p> <dl> <dt>string</dt><dd><p>The text the string consist of</p> </dd> <dt>width</dt><dd><p>The width of the string</p> </dd> <dt>height</dt><dd><p>The height of the string</p> </dd> <dt>left_bearing</dt><dd><p>The distance from the left edge of the textbox and the leftmost glyph</p> </dd> <dt>right_bearing</dt><dd><p>The distance from the right edge of the textbox and the rightmost glyph</p> </dd> <dt>top_bearing</dt><dd><p>The distance from the top edge of the textbox and the topmost glyph</p> </dd> <dt>bottom_bearing</dt><dd><p>The distance from the bottom edge of the textbox and the bottommost glyph</p> </dd> <dt>left_border</dt><dd><p>The position of the leftmost edge of the textbox related to the origin</p> </dd> <dt>top_border</dt><dd><p>The position of the topmost edge of the textbox related to the origin</p> </dd> <dt>pen_x</dt><dd><p>The horizontal position of the next glyph after the string</p> </dd> <dt>pen_y</dt><dd><p>The vertical position of the next glyph after the string</p> </dd> </dl> <h3>Examples</h3> <pre> string <- "This is a long string\nLook; It spans multiple lines\nand all" # Shape with default settings shape_string(string) # Mix styles within the same string string <- c( "This string will have\na ", "very large", " text style\nin the middle" ) shape_string(string, id = c(1, 1, 1), size = c(12, 24, 12)) </pre> <hr /><div style="text-align: center;">[Package <em>systemfonts</em> version 1.0.4 <a href="00Index.html">Index</a>]</div> </body></html>