Skip to content

pdf-raku/PDF-Font-Loader-raku

Repository files navigation

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;
my $font-size = 12; # point-size
$pdf.add-page.text: {
  .font = $deja, $font-size;
  .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.

PDF::Font::Loader::HarfBuzz - is an optional module, but needs to be installed for font-shaping.

About

Font loader for the PDF tool-chain

Resources

License

Stars

Watchers

Forks

Packages

No packages published