FontObj

[Raku PDF Project] / [PDF-Font-Loader Module] / PDF::Font::Loader :: FontObj

class PDF::Font::Loader::FontObj

Loaded font objects

Methods

font-name

The font name

height

Overall font height

encode

Encodes strings

decode

Decodes buffers

kern

Kern text via the font's kerning tables. Returns chunks of text separated by numeric kern widths.

say $font.kern("ABCD"); # ["AB", -18, "CD"]

glyph-width

Return the width of a glyph. This is a rw method that can be used to globally adjust a font's glyph spacing for rendering and string-width calculations:

say $vera.glyph-width('V'); # 684;
$vera.glyph-width('V') -= 100;
say $vera.glyph-width('V'); # 584;

to-dict

Produces a draft PDF font dictionary. cb-finish() needs to be called to finalize it.

cb-finish

Finishing hook for the PDF tool-chain. This produces a finalized PDF font dictionary, including embedded fonts, character widths and encoding mappings.

is-embedded

Whether a font-file is embedded.

is-subset

Whether the font has been subsetting

is-core-font

Whether the font is a core font

has-encoding

Whether the font has unicode encoding. This is needed to encode or extract text.

underline-position

Position, from the baseline where an underline should be drawn. This is usually negative and should be multipled by the font-size/1000 to get the actual position.

underline-thickness

Recommended underline thickness for the font. This should be multipled by font-size/1000.

face

Font::FreeType::Face object associated with the font.

If the font was loaded from a $dict object and is-embedded is true, the face object has been loaded from the embedded font, otherwise its a system-loaded font, selected to match the font.

stringwidth

method stringwidth(Str $text, Numeric $point-size?, Bool :$kern) returns Numeric

Returns the width of the string passed as argument.

By default the computed size is in 1000's of a font unit. Alternatively second point-size argument can be used to scale the width according to the font size.

The :kern option can be used to adjust the stringwidth, using the font's horizontal kerning tables.

get-glyphs

use PDF::Font::Loader::Glyph;
my PDF::Font::Loader::Glyph @glyphs = $font.get-glyphs: "Hi";
say "name:{.name} code:{.code-point} cid:{.cid} gid:{.gid} dx:{.dx} dy:{.dy}"
    for @glyphs;

Maps a string to glyphs, of type PDF::Font::Loader::Glyph.

PDF::Font::Loader v0.7.5

Font loading and embedding for the PDF tool-chain

Authors

  • David Warring

License

Artistic-2.0

Dependencies

Font::AFM:ver<1.24.6+>Font::FreeType:ver<0.4.3+>Hash::intNative::PackingPDF::Content:ver<0.6.12+>PDF::Lite:ver<0.0.11+>PDF:ver<0.5.4+>

Test Dependencies

Provides

  • PDF::Font::Loader
  • PDF::Font::Loader::Dict
  • PDF::Font::Loader::Enc
  • PDF::Font::Loader::Enc::CMap
  • PDF::Font::Loader::Enc::Glyphic
  • PDF::Font::Loader::Enc::Identity16
  • PDF::Font::Loader::Enc::Type1
  • PDF::Font::Loader::Enc::Unicode
  • PDF::Font::Loader::FontObj
  • PDF::Font::Loader::FontObj::CID
  • PDF::Font::Loader::Glyph
  • PDF::Font::Loader::Type1::Stream

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.