PDF::Builder
v3.028 Released, 31 December 2025
Please also see the
CPAN listing, the
GitHub entry, and the latest changes list.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
— Abraham Lincoln
PDF::Builder::Resource::Font::SynFont - Module for creating temporary synthetic Fonts
Inherits from PDF::Builder::Resource::Font
This module permits you to create a "new" font (loaded temporarily, but not permanently stored) 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. B<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%
This works for corefonts, PS fonts, and TTF/OTF fonts; but does not work for CJK fonts or bitmapped fonts. See also "Synthetic Fonts" in PDF::Builder::Docs.
Alternate name: synthetic_font
This is for compatibility with recent changes to PDF::API2.
$font = PDF::Builder::Resource::Font::SynFont->new($pdf, $fontobj, %opts)
Returns a synfont object.
$fontobjis a normal font object read in from a file, and$fontis the modified output.Valid options %opts are:
- encode
Changes the encoding of the font from its default. See Perl's Encode for the supported values. Warning: only single byte encodings are supported. Multibyte encodings such as UTF-8 are invalid.
- 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(for PDF::API2 compatibility)- 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:
hscaleandslant(for PDF::API2 compatibility)The slant option is a deprecated name in both PDF::Builder and PDF::API2. Its value is the same as condense value (1 = normal, unchanged scale). For the hscale option, the value is percentage (%), with 100 being normal, and other values 100 times the condense value. Use only one (at most) of these three option names.
- 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 +/-360 degrees, they should be aware that these will be treated as an angle of 0 degrees (deg2rad() wraps around). 0 degrees 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.
Alternate name:
angle(for PDF::API2 compatibility)Use only one (at most) of these two option names.
- 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.
If used with the
synthetic_fontalternate entry name, the unit is 1/1000th of a text unit, so you will need a value 10 times larger than with thesynfontentry to get the same effect.- space
Additional charspacing in thousandths of an em.
- 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(for PDF::API2 compatibility)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.
Master Index
PDF::Builder -- Facilitates the creation and modification of PDF files
PDF::Builder::Resource -- Base class for PDF resources
PDF::Builder::Resource::Font -- Some common support routines for font files
PDF::Builder::Resource::Font::BdFont -- Module for using bitmapped Fonts
PDF::Builder::Resource::Font::CoreFont -- Module for using the 14 standard PDF built-in Fonts (plus 15 Windows Fonts)
PDF::Builder::Resource::Font::Postscript -- Support routines for using PostScript (Type 1) fonts
All content © copyright 2005 – 2026
by Catskill Technology Services, LLC.
All rights reserved.
Note that Third Party software (whether Open Source or proprietary) on this
site remains under the copyright and license of its owners.
Catskill Technology Services, LLC does not claim copyright over such software.
This page is https://www.catskilltech.com/Documentation/PDF/Builder/Resource/Font/SynFont.html
Search Quotations database.
Last updated Thu, 01 Jan 2026 at 7:55 PM