1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>OpenType features: HarfBuzz Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
7 <link rel="home" href="index.html" title="HarfBuzz Manual">
8 <link rel="up" href="shaping-and-shape-plans.html" title="Shaping and shape plans">
9 <link rel="prev" href="shaping-and-shape-plans.html" title="Shaping and shape plans">
10 <link rel="next" href="shaping-shaper-selection.html" title="Shaper selection">
11 <meta name="generator" content="GTK-Doc V1.32.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts"></td>
17 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
18 <td><a accesskey="u" href="shaping-and-shape-plans.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
19 <td><a accesskey="p" href="shaping-and-shape-plans.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
20 <td><a accesskey="n" href="shaping-shaper-selection.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
23 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
24 <a name="shaping-opentype-features"></a>OpenType features</h2></div></div></div>
26 OpenType features enable fonts to include smart behavior,
27 implemented as "lookup" rules stored in the GSUB and GPOS
28 tables. The OpenType specification defines a long list of
29 standard features that fonts can use for these behaviors; each
30 feature has a four-character reserved name and a well-defined
34 Some OpenType features are defined for the purpose of supporting
35 complex-script shaping, and are automatically activated, but
36 only when a buffer's script property is set to a script that the
40 Other features are more generic and can apply to several (or
41 any) script, and shaping engines are expected to implement
42 them. By default, HarfBuzz activates several of these features
43 on every text run. They include <code class="literal">abvm</code>,
44 <code class="literal">blwm</code>, <code class="literal">ccmp</code>,
45 <code class="literal">locl</code>, <code class="literal">mark</code>,
46 <code class="literal">mkmk</code>, and <code class="literal">rlig</code>.
49 In addition, if the text direction is horizontal, HarfBuzz
50 also applies the <code class="literal">calt</code>,
51 <code class="literal">clig</code>, <code class="literal">curs</code>,
52 <code class="literal">dist</code>, <code class="literal">kern</code>,
53 <code class="literal">liga</code>, <code class="literal">rclt</code>,
54 and <code class="literal">frac</code> features.
57 If the text direction is vertical, HarfBuzz applies
58 the <code class="literal">vert</code> feature by default.
61 Still other features are designed to be purely optional and left
62 up to the application or the end user to enable or disable as desired.
65 You can adjust the set of features that HarfBuzz applies to a
66 buffer by supplying an array of <span class="type">hb_feature_t</span>
67 features as the third argument to
68 <code class="function">hb_shape()</code>. For a simple case, let's just
69 enable the <code class="literal">dlig</code> feature, which turns on any
70 "discretionary" ligatures in the font:
72 <pre class="programlisting">
73 hb_feature_t userfeatures[1];
74 userfeatures[0].tag = HB_TAG('d','l','i','g');
75 userfeatures[0].value = 1;
76 userfeatures[0].start = HB_FEATURE_GLOBAL_START;
77 userfeatures[0].end = HB_FEATURE_GLOBAL_END;
80 <code class="literal">HB_FEATURE_GLOBAL_END</code> and
81 <code class="literal">HB_FEATURE_GLOBAL_END</code> are macros we can use
82 to indicate that the features will be applied to the entire
83 buffer. We could also have used a literal <code class="literal">0</code>
84 for the start and a <code class="literal">-1</code> to indicate the end of
85 the buffer (or have selected other start and end positions, if needed).
88 When we pass the <code class="varname">userfeatures</code> array to
89 <code class="function">hb_shape()</code>, any discretionary ligature
90 substitutions from our font that match the text in our buffer
93 <pre class="programlisting">
94 hb_shape(font, buf, userfeatures, num_features);
97 Just like we enabled the <code class="literal">dlig</code> feature by
98 setting its <em class="parameter"><code>value</code></em> to
99 <code class="literal">1</code>, you would disable a feature by setting its
100 <em class="parameter"><code>value</code></em> to <code class="literal">0</code>. Some
101 features can take other <em class="parameter"><code>value</code></em> settings;
102 be sure you read the full specification of each feature tag to
103 understand what it does and how to control it.
107 <hr>Generated by GTK-Doc V1.32.1</div>