Help language development. Donate to The Perl Foundation

HarfBuzz cpan:WARRINGD last updated on 2021-02-22


[Raku HarfBuzz Project] / [HarfBuzz Module]


Bindings to the HarfBuzz text shaping library.

EXPERIMENTAL minimum HarfBuzz version is v2.6.6 - See Installation


HarfBuzz - Use HarfBuzz for text shaping and font manipulation.


use HarfBuzz::Font;
use HarfBuzz::Buffer;
use HarfBuzz::Shaper;
use HarfBuzz::Feature;
use HarfBuzz::Glyphs;
my HarfBuzz::Feature() @features = <smcp -kern -liga>; # enable small-caps, disable kerning and ligatures
my $file = 't/fonts/NimbusRoman-Regular.otf';
my HarfBuzz::Font $font .= new :$file, :size(36), :@features;
my HarfBuzz::Buffer $buf .= new :text<Hello!>;
my HarfBuzz::Shaper $shaper .= new: :$font :$buf;
for $shaper.shape -> HarfBuzz::Glyph $glyph { ... }
my Hash @info = $shaper.ast;


HarfBuzz is a Raku module that provides access to a small subset of the native HarfBuzz library.

The subset is suitable for typesetting programs, whether they need to do basic glyph selection and layout, or deal with complex languages like Devanagari, Hebrew or Arabic.

Following the above example, the returned info is an array of hashes, one element for each glyph to be typeset. The hash contains the following items:

ax:   horizontal advance
ay:   vertical advance
dx:   horizontal offset
dy:   vertical offset
g:    glyph index in font (CId)
name: glyph name

Note that the number of glyphs does not necessarily match the number of input characters!

Classes/Modules in this distribution


This module requires HarfBuzz 2.6.6+ to be fully operational and pass all it's tests, which typically means Debian 11 Bullseye (currently testing).

$ sudo apt-get install libharfbuzz-dev # Debian 11+

Or the HarfBuzz library needs to be built from source its repo:

A source build is required if you are installing this as HarfBuzz::Subset dependency.

Additional Modules

See Also