HarfBuzz

bindings to the HarfBuzz font shaping library (experimental)

[Raku HarfBuzz Project] / [HarfBuzz Module]

HarfBuzz-raku

Bindings to the HarfBuzz text shaping library.

Minimum supported HarfBuzz version is v2.6.4 - See Installation

Note: If you wish to install the HarfBuzz::Subset module, then the minimum HarfBuzz version is v3.0.0+.

Name

HarfBuzz - Use HarfBuzz for text shaping and font manipulation.

Synopsis

use HarfBuzz::Font;
use HarfBuzz::Buffer;
use HarfBuzz::Shaper;
use HarfBuzz::Feature;
use HarfBuzz::Glyph;
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;

Description

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
c:    input character position
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

Installation

This module requires HarfBuzz 2.6.4+.

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

If you are installing this as a HarfBuzz::Subset dependency, HarfBuzz 3.0.0+ is required, which may (as of February 2022) require building from source its repo.

Additional Modules

See Also

HarfBuzz v0.0.13

bindings to the HarfBuzz font shaping library (experimental)

Authors

  • David Warring

License

Artistic-2.0

Dependencies

Method::Also

Test Dependencies

Provides

  • HarfBuzz
  • HarfBuzz::Blob
  • HarfBuzz::Buffer
  • HarfBuzz::Face
  • HarfBuzz::Feature
  • HarfBuzz::Font
  • HarfBuzz::Glyph
  • HarfBuzz::Raw
  • HarfBuzz::Raw::Defs
  • HarfBuzz::Shaper

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