The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PDF::Builder::Resource::Font::SynFont - Module for creating temporary synthetic Fonts.

SYNOPSIS

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)
    * 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.

METHODS

$font = PDF::Builder::Resource::Font::SynFont->new($pdf, $fontobj, %opts)

Returns a synfont object. $fontobj is a normal font object read in from a file, and $font is 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

Condense/expand factor (0.1-0.9 = condense, 1 = normal, 1.1+ = expand). It's the multiplier for character widths vs. normal.

Alternate names: hscale and slant (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 angle (+/-) in degrees, where the character box is skewed. 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.

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_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

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.