PDF::Bu...:SynFont(3)
๐ PDF::Builder::Resource::Font::SynFont ๐
okay bestie, welcome to PDF::Bu...:SynFont(3) โ this is the User Contributed Perl Documentation page for PDF::Builder::Resource::Font::SynFont, and yes the name got chopped in the header but it's fine, we're here, we're thriving ๐ซถ
โจ NAME โจ
PDF::Builder::Resource::Font::SynFont โ the module for making temporary synthetic Fonts ๐ธ
it inherits from PDF::Builder::Resource::Font, so all that good good is in the family tree ๐
๐ SYNOPSIS ๐
so this module lets you create a "new" font โ loaded temporarily, not permanently stored, she's a guest not a resident โ based on an existing font, where you can modify certain attributes in the original font, such as:
- slant/obliqueness
- extra weight/boldness (by drawing glyph outlines at various line thicknesses, rather than just filling enclosed areas)
- condense/expand (narrower or wider characters) a.k.a. stretch
- extra space between characters
- small caps (synthesized, not using any provided with a font)
- change the encoding
$pdf = PDF::Builder->new();
$cft = $pdf->font('Times-Roman'); # corefont, ttfont, etc. also works
$sft = $pdf->synfont($cft, 'condense' => .75); # condense by 25%
look at that. iconic. Times-Roman walked in and walked out 25% more condensed. main character energy fr fr ๐ฅ
this works for corefonts, PS fonts, and TTF/OTF fonts โ but it does not work for CJK fonts or bitmapped fonts, sorry babes ๐ญ. See also "Synthetic Fonts" in PDF::Builder::Docs.
alternate name: "synthetic_font"
this is for compatibility with recent changes to PDF::API2. keeping the old friends happy ๐
๐ฆ METHODS ๐ฆ
๐ new
$font = PDF::Builder::Resource::Font::SynFont->new($pdf, $fontobj, %opts)
returns a synfont object, slay. $fontobj is a normal font object read in from a file, and $font is the modified output โ the glow-up โจ
valid options %opts are:
encodeโ changes the encoding of the font from its default. See Perl'sEncodefor the supported values.
โ ๏ธ warning bestie: only single byte encodings are supported. Multibyte encodings such as UTF-8 are invalid. do not do it. i'm begging ๐
pdfnameโ changes the reference-name of the font from its default. the reference-name is normally generated automatically and can be retrieved via$pdfname=$font->name().- alternate name:
"name"(forPDF::API2compatibility)
- alternate name:
condenseโ character width condense/expand factor (0.1-0.9= condense,1= normal/default,1.1+= expand). it is the multiplier to apply to the width of each character.
in some font systems, this aspect or axis is known as stretch.
- alternate names:
"hscale"and"slant"(forPDF::API2compatibility)
theslantoption is a deprecated name in bothPDF::BuilderandPDF::API2. its value is the same as thecondensevalue (1= normal, unchanged scale). for thehscaleoption, the value is percentage (%), with100being normal, and other values100times thecondensevalue.
use only one (at most) of these three option names. pick a lane bestie ๐๐จ
obliqueโ italic or slanted text angle (+/-) in degrees, where the character box is skewed (sheared), top to the right. while it's unlikely that anyone will want to slant characters at+/-360degrees, they should be aware that these will be treated as an angle of0degrees (deg2rad()wraps around).0degrees of italic slant (obliqueness) is the default.
note that a font management system may have separate axes for normal/italic fonts, and the degree of slant. Italic is a different (but related) face to the regular (e.g., Roman) face, sometimes made to resemble handwritten characters, and is usually a binary selection (it's either italic or it's not). Slant, on the other hand, can be in arbitrary amounts, and may be applied to either normal (originally Roman posture) or italics (which are often themselves slightly slanted). finally, what many fonts call "italic" others may call "slanted" or "oblique", and in these cases the coordinate system is merely sheared to slant the character box. the way that fonts have opinions ๐ญ
- alternate name:
"angle"(forPDF::API2compatibility)
use only one (at most) of these two option names. one. at most. ๐
boldโ embolding factor (0.1+,bold=1,heavy=2, ...). it is additional outline thickness (linewidth), which expands the character (glyph) outwards (as well as shrinking unfilled enclosed areas such as bowls and counters). normally, the glyph's outline is not drawn (it is only filled); this adds a thick outline. the units are in 1/100ths of a text unit.
heads up: if used with the"synthetic_font"alternate entry name, the unit is 1/1000th of a text unit, so you will need a value 10 times larger than with the"synfont"entry to get the same effect. do not get got by the math ๐งฎ
spaceโ additional charspacing in thousandths of an em. give those letters some room to breathe ๐ฌ๏ธcapsโ create synthetic small-caps.0= no,1= yes. these are capitals of lowercase letters, at 80% height and 88% width. note that this is guaranteed to cover ASCII lowercase letters only โ single byte encoded accented characters usually work, but we can make no promises on accented characters in general, as well as ligatures!- alternate name:
"smallcaps"(forPDF::API2compatibility)
- alternate name:
use only one (at most) of these two option names.
note that only lower case letters which appear in the "standard" font (plane 0 for core fonts and PS fonts) will be small-capped. this may include eszett (German sharp s), which becomes SS, and dotless i and j which become I and J respectively. there are many other accented Latin alphabet letters which may show up in planes 1 and higher. ligatures (e.g., ij and ffl) do not have uppercase equivalents, nor does a long s. if you have text which includes such characters, you may want to consider preprocessing it to replace them with Latin character expansions (e.g., i+j and f+f+l) before small-capping. it's giving "do the homework first" ๐โจ
and that's the whole page, bestie!! ๐๐ this iconic little doc shipped with perl v5.42.0, dated 2026-01-17, and it's part of the PDF::Bu...:SynFont(3) page โ go make some synthetic fonts and absolutely ate ๐ซถ๐
๐
๐ฆ where this page comes from
- fedora 44: perl-PDF-Builder 3.028-2.fc44 ยท LGPL-2.1-or-later AND LGPL-2.1-only AND MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms