Rand Stats

PDF::Font::Loader

zef:dwarring

Actions Status

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

Name

PDF::Font::Loader

Synopsis

# load a font from a file
use PDF::Font::Loader :load-font;
use PDF::Content::FontObj;

my PDF::Content::FontObj $deja;
$deja = PDF::Font::Loader.load-font: :file<t/fonts/DejaVuSans.ttf>;
-- or --
$deja = load-font( :file<t/fonts/DejaVuSans.ttf> );

# find/load the best matching system font
# *** requires FontConfig ***
use PDF::Font::Loader :load-font, :find-font;
my Str $file = find-font( :family<DejaVu>, :slant<italic> );
my PDF::Content::FontObj $deja-vu = load-font: :$file;

# use the font to add text to a PDF
use PDF::Lite;
my PDF::Lite $pdf .= new;
$pdf.add-page.text: {
  .font = $deja;
  .text-position = [10, 600];
  .say: 'Hello, world';
}
$pdf.save-as: "/tmp/example.pdf";

Description

This module provides font loading and handling for PDF::Lite, PDF::API6 and other PDF modules.

Classes in this distribution

Install

PDF::Font::Loader depends on:

Font::FreeType Raku module which further depends on the freetype library, so you must install that prior to installing this module.

The find-font method requires installation of the FontConfig library .