Skip to main content

parse_graphicx_options

Function parse_graphicx_options 

Source
pub fn parse_graphicx_options(options: &str) -> Vec<GraphicxOp>
Expand description

Compile a graphicx option string into the transformation sequence.

Port of Perl image_graphicx_parse (Util/Image.pm L142-196). Key order matters and is Perl’s, in two ways:

  • A rotation is applied before scaling when no sizing option preceded the angle in the source string, and after it otherwise. Perl decides this the instant it parses angle ($rotfirst = !($width || $height || $xscale || $yscale), L168), from the keys seen so far — so angle=90,width=100pt rotates then scales, while width=100pt,angle=90 scales then rotates. graphicx really behaves this way and pdflatex agrees: the first is ~100x200, the second ~50x100 for a 200x100 source. We capture rot_first at the same point, not from the final key set.

pc differs from Perl by design: Perl’s table has pc => 12/72.27, which is 12 TeX pt expressed in bp only if you also drop the pt→bp step — a pica is 12 pt, so the factor is 12 * 72/72.27. Perl’s value makes a 1pc box 0.166bp instead of 11.955bp. Ours is the correct one; no test in the corpus exercised pc.