Class HBShape
A shaper for TextBlock and TextLine that runs hb-shape, the program of HarfBuzz, the text engine of Chrome and Android, with nothing linked into the program; used only when given with SetShaper. The NuGet package PDFjet.HarfBuzz gives the same glyphs with nothing to install. Lines break at spaces and, in Thai, Lao, Khmer and Burmese, between words, by ICU's dictionaries of the world fonts. hb-shape is installed on the server, HarfBuzz 15 or newer: on Ubuntu and Debian apt install libharfbuzz-bin; on Fedora and RHEL dnf install harfbuzz-utils; on macOS and Linux brew install harfbuzz; on Windows harfbuzz-win64-<version>.zip of github.com/harfbuzz/harfbuzz/releases. It talks with hb-shape through files, not pipes, the same on every system: the text of each font in a temporary file, the glyphs back in another.
new TextBlock(hindi, text).SetFallbackFont(latin).SetShaper(new HBShape())
public class HBShape : IShaper, IHarfBuzz
- Inheritance
-
HBShape
- Implements
- Inherited Members
Constructors
HBShape()
An HBShape that runs hb-shape of the PATH.
public HBShape()
HBShape(string)
An HBShape that runs the hb-shape of the path.
public HBShape(string program)
Parameters
programstringhb-shape's path, such as C:\Tools\harfbuzz-win64\hb-shape.exe, or its name looked for on the PATH.
Methods
GetVersion()
What hb-shape --version prints first, such as "hb-shape (HarfBuzz) 15.2.0".
public string GetVersion()
Returns
- string
the version.
Shape(ShapingRequest)
Shapes the text with hb-shape, each run of one font in that font, and breaks it into lines no wider than the width.
public List<ShapedLine> Shape(ShapingRequest request)
Parameters
requestShapingRequestthe text, its language, the font files, the font size and the width of the lines.
Returns
- List<ShapedLine>
the lines, in order.
ShapeRuns(byte[], IList<string>, string)
Shapes each run in the font with hb-shape, all of them in one run of it, a run a line of its input file.
public IList<HarfBuzzGlyph[]> ShapeRuns(byte[] font, IList<string> runs, string language)
Parameters
fontbyte[]the font file.
runsIList<string>the runs of text.
languagestringthe language, or null.
Returns
- IList<HarfBuzzGlyph[]>
the glyphs of each run, in font units.