|
Packit |
874993 |
|
|
Packit |
874993 |
<html>
|
|
Packit |
874993 |
<head>
|
|
Packit |
874993 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
Packit |
874993 |
<title>What is Harfbuzz?: HarfBuzz Manual</title>
|
|
Packit |
874993 |
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
|
Packit |
874993 |
<link rel="home" href="index.html" title="HarfBuzz Manual">
|
|
Packit |
874993 |
<link rel="up" href="pt01.html" title="Part I. User's manual">
|
|
Packit |
874993 |
<link rel="prev" href="pt01.html" title="Part I. User's manual">
|
|
Packit |
874993 |
<link rel="next" href="why-is-it-called-harfbuzz.html" title="Why is it called Harfbuzz?">
|
|
Packit |
874993 |
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
|
|
Packit |
874993 |
<link rel="stylesheet" href="style.css" type="text/css">
|
|
Packit |
874993 |
</head>
|
|
Packit |
874993 |
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
What is Harfbuzz?
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Why do I need it?
|
|
Packit |
874993 |
Why is it called Harfbuzz?
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Harfbuzz is a text shaping engine. It solves
|
|
Packit |
874993 |
the problem of selecting and positioning glyphs from a font given a
|
|
Packit |
874993 |
Unicode string.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Why do I need it?
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Text shaping is an integral part of preparing text for display. It
|
|
Packit |
874993 |
is a fairly low level operation; Harfbuzz is used directly by
|
|
Packit |
874993 |
graphic rendering libraries such as Pango, and the layout engines
|
|
Packit |
874993 |
in Firefox, LibreOffice and Chromium. Unless you are
|
|
Packit |
874993 |
writing one of these layout engines yourself,
|
|
Packit |
874993 |
you will probably not need to use Harfbuzz - normally higher level
|
|
Packit |
874993 |
libraries will turn text into glyphs for you.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
However, if you are writing a layout engine
|
|
Packit |
874993 |
or graphics library yourself, you will need to perform text
|
|
Packit |
874993 |
shaping, and this is where Harfbuzz can help you. Here are some
|
|
Packit |
874993 |
reasons why you need it:
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
OpenType fonts contain a set of glyphs, indexed by glyph ID.
|
|
Packit |
874993 |
The glyph ID within the font does not necessarily relate to a
|
|
Packit |
874993 |
Unicode codepoint. For instance, some fonts have the letter
|
|
Packit |
874993 |
"a" as glyph ID 1. To pull the right glyph out of
|
|
Packit |
874993 |
the font in order to display it, you need to consult a table
|
|
Packit |
874993 |
within the font (the "cmap" table) which maps
|
|
Packit |
874993 |
Unicode codepoints to glyph IDs. Text shaping turns codepoints
|
|
Packit |
874993 |
into glyph IDs.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Many OpenType fonts contain ligatures: combinations of
|
|
Packit |
874993 |
characters which are rendered together. For instance, it's
|
|
Packit |
874993 |
common for the fi combination to appear in
|
|
Packit |
874993 |
print as the single ligature "fi". Whether you should
|
|
Packit |
874993 |
render text as fi or "fi" does not
|
|
Packit |
874993 |
depend on the input text, but on the capabilities of the font
|
|
Packit |
874993 |
and the level of ligature application you wish to perform.
|
|
Packit |
874993 |
Text shaping involves querying the font's ligature tables and
|
|
Packit |
874993 |
determining what substitutions should be made.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
While ligatures like "fi" are typographic
|
|
Packit |
874993 |
refinements, some languages require such
|
|
Packit |
874993 |
substitutions to be made in order to display text correctly.
|
|
Packit |
874993 |
In Tamil, when the letter "TTA" (ட) letter is
|
|
Packit |
874993 |
followed by "U" (உ), the combination should appear
|
|
Packit |
874993 |
as the single glyph "டு". The sequence of Unicode
|
|
Packit |
874993 |
characters "டஉ" needs to be rendered as a single
|
|
Packit |
874993 |
glyph from the font - text shaping chooses the correct glyph
|
|
Packit |
874993 |
from the sequence of characters provided.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Similarly, each Arabic character has four different variants:
|
|
Packit |
874993 |
within a font, there will be glyphs for the initial, medial,
|
|
Packit |
874993 |
final, and isolated forms of each letter. Unicode only encodes
|
|
Packit |
874993 |
one codepoint per character, and so a Unicode string will not
|
|
Packit |
874993 |
tell you which glyph to use. Text shaping chooses the correct
|
|
Packit |
874993 |
form of the letter and returns the correct glyph from the font
|
|
Packit |
874993 |
that you need to render.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Other languages have marks and accents which need to be
|
|
Packit |
874993 |
rendered in certain positions around a base character. For
|
|
Packit |
874993 |
instance, the Moldovan language has the Cyrillic letter
|
|
Packit |
874993 |
"zhe" (ж) with a breve accent, like so: ӂ. Some
|
|
Packit |
874993 |
fonts will contain this character as an individual glyph,
|
|
Packit |
874993 |
whereas other fonts will not contain a zhe-with-breve glyph
|
|
Packit |
874993 |
but expect the rendering engine to form the character by
|
|
Packit |
874993 |
overlaying the two glyphs ж and ˘. Where you should draw the
|
|
Packit |
874993 |
combining breve depends on the height of the preceding glyph.
|
|
Packit |
874993 |
Again, for Arabic, the correct positioning of vowel marks
|
|
Packit |
874993 |
depends on the height of the character on which you are
|
|
Packit |
874993 |
placing the mark. Text shaping tells you whether you have a
|
|
Packit |
874993 |
precomposed glyph within your font or if you need to compose a
|
|
Packit |
874993 |
glyph yourself out of combining marks, and if so, where to
|
|
Packit |
874993 |
position those marks.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
If this is something that you need to do, then you need a text
|
|
Packit |
874993 |
shaping engine: you could use Uniscribe if you are using Windows;
|
|
Packit |
874993 |
you could use CoreText on OS X; or you could use Harfbuzz. In the
|
|
Packit |
874993 |
rest of this manual, we are going to assume that you are the
|
|
Packit |
874993 |
implementor of a text layout engine.
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
|
|
Packit |
874993 |
Generated by GTK-Doc V1.25.1
|
|
Packit |
874993 |
</body>
|
|
Packit |
874993 |
</html>
|