blob: b22b958838df6cc4625fbd198a47f3decffdade9 [file] [log] [blame]
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -06001/*
2 * Copyright © 2011 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
27#ifndef SHAPE_OPTIONS_HH
28#define SHAPE_OPTIONS_HH
29
30#include "options.hh"
31
32struct shape_options_t
33{
34 ~shape_options_t ()
35 {
36 g_free (direction);
37 g_free (language);
38 g_free (script);
39 free (features);
40 g_strfreev (shapers);
41 }
42
43 void add_options (option_parser_t *parser);
44
45 void setup_buffer (hb_buffer_t *buffer)
46 {
47 hb_buffer_set_direction (buffer, hb_direction_from_string (direction, -1));
48 hb_buffer_set_script (buffer, hb_script_from_string (script, -1));
49 hb_buffer_set_language (buffer, hb_language_from_string (language, -1));
50 hb_buffer_set_flags (buffer, (hb_buffer_flags_t)
51 (HB_BUFFER_FLAG_DEFAULT |
52 (bot ? HB_BUFFER_FLAG_BOT : 0) |
53 (eot ? HB_BUFFER_FLAG_EOT : 0) |
Behdad Esfahbod61823832022-01-28 13:45:25 -070054 (verify ? HB_BUFFER_FLAG_VERIFY : 0) |
Behdad Esfahbod56f11ec2022-02-18 14:08:43 -060055 (unsafe_to_concat ? HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT : 0) |
Behdad Esfahbodf43dadb2022-07-30 10:23:03 -060056 (safe_to_insert_tatweel ? HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL : 0) |
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -060057 (preserve_default_ignorables ? HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES : 0) |
58 (remove_default_ignorables ? HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES : 0) |
59 0));
60 hb_buffer_set_invisible_glyph (buffer, invisible_glyph);
Behdad Esfahbodda500562021-10-26 08:02:29 -060061 hb_buffer_set_not_found_glyph (buffer, not_found_glyph);
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -060062 hb_buffer_set_cluster_level (buffer, cluster_level);
63 hb_buffer_guess_segment_properties (buffer);
64 }
65
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -060066 void populate_buffer (hb_buffer_t *buffer, const char *text, int text_len,
Behdad Esfahbodd45f7262022-12-23 13:13:29 -070067 const char *text_before, const char *text_after,
68 hb_font_t *font)
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -060069 {
70 hb_buffer_clear_contents (buffer);
Behdad Esfahbodd45f7262022-12-23 13:13:29 -070071
72 if (glyphs)
73 {
Behdad Esfahbod0066e822022-12-23 13:37:38 -070074 /* Call the setup_buffer first while the buffer is empty,
75 * as guess_segment_properties doesn't like glyphs in the buffer. */
76
77 setup_buffer (buffer);
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070078 char *glyphs_text = (char *) text;
Behdad Esfahbodf798cf22023-01-23 20:57:30 -070079 int glyphs_len = text_len;
80 if (glyphs_len < 0)
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070081 glyphs_len = strlen (glyphs_text);
Behdad Esfahbodf798cf22023-01-23 20:57:30 -070082
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070083 if (glyphs_len && glyphs_text[glyphs_len - 1] != ']')
Behdad Esfahbodf798cf22023-01-23 20:57:30 -070084 {
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070085 glyphs_text = g_strdup_printf ("%*s]", glyphs_len, glyphs_text);
Behdad Esfahbodf798cf22023-01-23 20:57:30 -070086 glyphs_len = -1;
87 }
88
Behdad Esfahbodd45f7262022-12-23 13:13:29 -070089 hb_buffer_deserialize_glyphs (buffer,
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070090 glyphs_text, glyphs_len,
Behdad Esfahbodd45f7262022-12-23 13:13:29 -070091 nullptr,
92 font,
93 HB_BUFFER_SERIALIZE_FORMAT_TEXT);
Behdad Esfahbodf798cf22023-01-23 20:57:30 -070094
Behdad Esfahbod161d8f92023-01-24 11:48:10 -070095 if (!strchr (glyphs_text, '+'))
Behdad Esfahbod68a79022023-01-24 11:44:32 -070096 {
97 scale_advances = false;
98 unsigned count;
99 hb_direction_t direction = hb_buffer_get_direction (buffer);
100 hb_glyph_info_t *infos = hb_buffer_get_glyph_infos (buffer, &count);
101 hb_glyph_position_t *positions = hb_buffer_get_glyph_positions (buffer, &count);
102 for (unsigned i = 0; i < count; i++)
103 hb_font_get_glyph_advance_for_direction (font,
104 infos[i].codepoint,
105 direction,
106 &positions[i].x_advance,
107 &positions[i].y_advance);
108 }
109
Behdad Esfahbod161d8f92023-01-24 11:48:10 -0700110 if (glyphs_text != text)
111 g_free (glyphs_text);
Behdad Esfahbodf798cf22023-01-23 20:57:30 -0700112
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700113 return;
114 }
115
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600116 if (text_before) {
117 unsigned int len = strlen (text_before);
118 hb_buffer_add_utf8 (buffer, text_before, len, len, 0);
119 }
120 hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len);
121 if (text_after) {
122 hb_buffer_add_utf8 (buffer, text_after, -1, 0, 0);
123 }
124
125 if (!utf8_clusters) {
126 /* Reset cluster values to refer to Unicode character index
127 * instead of UTF-8 index. */
128 unsigned int num_glyphs = hb_buffer_get_length (buffer);
129 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, nullptr);
130 for (unsigned int i = 0; i < num_glyphs; i++)
131 {
132 info->cluster = i;
133 info++;
134 }
135 }
136
137 setup_buffer (buffer);
138 }
139
140 hb_bool_t shape (hb_font_t *font, hb_buffer_t *buffer, const char **error=nullptr)
141 {
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700142 if (glyphs)
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600143 {
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700144 /* Scale positions. */
145 int x_scale, y_scale;
146 hb_font_get_scale (font, &x_scale, &y_scale);
147 unsigned upem = hb_face_get_upem (hb_font_get_face (font));
148 unsigned count;
149 auto *positions = hb_buffer_get_glyph_positions (buffer, &count);
150 for (unsigned i = 0; i < count; i++)
151 {
152 auto &pos = positions[i];
153 pos.x_offset = pos.x_offset * x_scale / upem;
154 pos.y_offset = pos.y_offset * y_scale / upem;
Behdad Esfahbod68a79022023-01-24 11:44:32 -0700155 if (scale_advances)
156 {
157 pos.x_advance = pos.x_advance * x_scale / upem;
158 pos.y_advance = pos.y_advance * y_scale / upem;
159 }
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700160 }
161 }
162 else
163 {
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700164 if (advance <= 0)
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700165 {
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700166 if (!hb_shape_full (font, buffer, features, num_features, shapers))
167 {
168 if (error)
169 *error = "Shaping failed.";
170 goto fail;
171 }
Behdad Esfahbodaa10dea2023-03-01 11:08:32 -0700172
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700173 if (advance < 0)
Behdad Esfahbodaa10dea2023-03-01 11:08:32 -0700174 {
175 float unit = (1 << SUBPIXEL_BITS);
176
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700177 /* Calculate buffer advance */
Behdad Esfahbodaa10dea2023-03-01 11:08:32 -0700178 float w = 0;
179 unsigned count = 0;
180 hb_glyph_position_t *pos = hb_buffer_get_glyph_positions (buffer, &count);
181 if (HB_DIRECTION_IS_HORIZONTAL (hb_buffer_get_direction (buffer)))
182 for (unsigned i = 0; i < count; i++)
183 w += pos[i].x_advance;
184 else
185 for (unsigned i = 0; i < count; i++)
186 w += pos[i].y_advance;
187
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700188 printf ("Default size: %u\n", (unsigned) roundf (w / unit));
Behdad Esfahbodaa10dea2023-03-01 11:08:32 -0700189 exit (0);
190 }
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700191 }
Behdad Esfahbod25c66d62023-03-01 14:16:08 -0700192#ifdef HB_EXPERIMENTAL_API
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700193 else
194 {
Behdad Esfahbodb937edf2023-03-01 10:44:57 -0700195 float unit = (1 << SUBPIXEL_BITS);
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700196 float target_advance = advance * unit;
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700197 float w = 0;
198 hb_tag_t var_tag;
199 float var_value;
200 if (!hb_shape_justify (font, buffer, features, num_features, shapers,
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700201 target_advance - unit * 0.5f, target_advance + unit * 0.5f,
Behdad Esfahbodb937edf2023-03-01 10:44:57 -0700202 &w, &var_tag, &var_value))
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700203 {
204 if (error)
205 *error = "Shaping failed.";
206 goto fail;
207 }
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700208 }
Behdad Esfahbod25c66d62023-03-01 14:16:08 -0700209#endif
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600210 }
211
212 if (normalize_glyphs)
213 hb_buffer_normalize_glyphs (buffer);
214
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600215 return true;
216
217 fail:
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600218 return false;
219 }
220
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600221 void shape_closure (const char *text, int text_len,
222 hb_font_t *font, hb_buffer_t *buffer,
223 hb_set_t *glyphs)
224 {
225 hb_buffer_reset (buffer);
226 hb_buffer_add_utf8 (buffer, text, text_len, 0, text_len);
227 setup_buffer (buffer);
228 hb_ot_shape_glyphs_closure (font, buffer, features, num_features, glyphs);
229 }
230
231 /* Buffer properties */
232 char *direction = nullptr;
233 char *language = nullptr;
234 char *script = nullptr;
235
236 /* Buffer flags */
237 hb_bool_t bot = false;
238 hb_bool_t eot = false;
239 hb_bool_t preserve_default_ignorables = false;
240 hb_bool_t remove_default_ignorables = false;
241
242 hb_feature_t *features = nullptr;
243 unsigned int num_features = 0;
244 char **shapers = nullptr;
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700245 signed advance = 0;
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600246 hb_bool_t utf8_clusters = false;
247 hb_codepoint_t invisible_glyph = 0;
Behdad Esfahbodda500562021-10-26 08:02:29 -0600248 hb_codepoint_t not_found_glyph = 0;
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600249 hb_buffer_cluster_level_t cluster_level = HB_BUFFER_CLUSTER_LEVEL_DEFAULT;
250 hb_bool_t normalize_glyphs = false;
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700251 hb_bool_t glyphs = false;
Behdad Esfahbod68a79022023-01-24 11:44:32 -0700252 bool scale_advances = true;
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600253 hb_bool_t verify = false;
Behdad Esfahbod56f11ec2022-02-18 14:08:43 -0600254 hb_bool_t unsafe_to_concat = false;
Behdad Esfahbodf43dadb2022-07-30 10:23:03 -0600255 hb_bool_t safe_to_insert_tatweel = false;
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600256 unsigned int num_iterations = 1;
257};
258
259
260static gboolean
261parse_shapers (const char *name G_GNUC_UNUSED,
262 const char *arg,
263 gpointer data,
264 GError **error)
265{
266 shape_options_t *shape_opts = (shape_options_t *) data;
267 char **shapers = g_strsplit (arg, ",", 0);
268
Behdad Esfahbod58bfe402021-08-11 19:48:28 -0600269 for (char **shaper = shapers; *shaper; shaper++)
270 {
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600271 bool found = false;
272 for (const char **hb_shaper = hb_shape_list_shapers (); *hb_shaper; hb_shaper++) {
Behdad Esfahbod58bfe402021-08-11 19:48:28 -0600273 if (strcmp (*shaper, *hb_shaper) == 0)
274 {
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600275 found = true;
276 break;
277 }
278 }
Behdad Esfahbod58bfe402021-08-11 19:48:28 -0600279 if (!found)
280 {
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600281 g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
282 "Unknown or unsupported shaper: %s", *shaper);
283 g_strfreev (shapers);
284 return false;
285 }
286 }
287
288 g_strfreev (shape_opts->shapers);
289 shape_opts->shapers = shapers;
290 return true;
291}
292
293static G_GNUC_NORETURN gboolean
294list_shapers (const char *name G_GNUC_UNUSED,
295 const char *arg G_GNUC_UNUSED,
296 gpointer data G_GNUC_UNUSED,
297 GError **error G_GNUC_UNUSED)
298{
299 for (const char **shaper = hb_shape_list_shapers (); *shaper; shaper++)
300 g_printf ("%s\n", *shaper);
301
302 exit(0);
303}
304
305
306static gboolean
307parse_features (const char *name G_GNUC_UNUSED,
308 const char *arg,
309 gpointer data,
310 GError **error G_GNUC_UNUSED)
311{
312 shape_options_t *shape_opts = (shape_options_t *) data;
313 char *s = (char *) arg;
314 size_t l = strlen (s);
315 char *p;
316
317 shape_opts->num_features = 0;
318 g_free (shape_opts->features);
319 shape_opts->features = nullptr;
320
321 /* if the string is quoted, strip the quotes */
322 if (s[0] == s[l - 1] && (s[0] == '\"' || s[0] == '\''))
323 {
324 s[l - 1] = '\0';
325 s++;
326 }
327
328 if (!*s)
329 return true;
330
331 /* count the features first, so we can allocate memory */
332 p = s;
333 do {
334 shape_opts->num_features++;
Behdad Esfahbod1eb8e822022-07-18 14:47:49 -0600335 p = strpbrk (p, ", ");
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600336 if (p)
337 p++;
338 } while (p);
339
340 shape_opts->features = (hb_feature_t *) calloc (shape_opts->num_features, sizeof (*shape_opts->features));
341 if (!shape_opts->features)
342 return false;
343
344 /* now do the actual parsing */
345 p = s;
346 shape_opts->num_features = 0;
347 while (p && *p) {
Behdad Esfahbod1eb8e822022-07-18 14:47:49 -0600348 char *end = strpbrk (p, ", ");
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600349 if (hb_feature_from_string (p, end ? end - p : -1, &shape_opts->features[shape_opts->num_features]))
350 shape_opts->num_features++;
351 p = end ? end + 1 : nullptr;
352 }
353
354 return true;
355}
356
357void
358shape_options_t::add_options (option_parser_t *parser)
359{
360 GOptionEntry entries[] =
361 {
362 {"list-shapers", 0, G_OPTION_FLAG_NO_ARG,
363 G_OPTION_ARG_CALLBACK, (gpointer) &list_shapers, "List available shapers and quit", nullptr},
364 {"shaper", 0, G_OPTION_FLAG_HIDDEN,
365 G_OPTION_ARG_CALLBACK, (gpointer) &parse_shapers, "Hidden duplicate of --shapers", nullptr},
366 {"shapers", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_shapers, "Set comma-separated list of shapers to try","list"},
367 {"direction", 0, 0, G_OPTION_ARG_STRING, &this->direction, "Set text direction (default: auto)", "ltr/rtl/ttb/btt"},
Simon Cozense29f5632021-08-18 08:51:41 +0100368 {"language", 0, 0, G_OPTION_ARG_STRING, &this->language, "Set text language (default: $LANG)", "BCP 47 tag"},
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600369 {"script", 0, 0, G_OPTION_ARG_STRING, &this->script, "Set text script (default: auto)", "ISO-15924 tag"},
370 {"bot", 0, 0, G_OPTION_ARG_NONE, &this->bot, "Treat text as beginning-of-paragraph", nullptr},
371 {"eot", 0, 0, G_OPTION_ARG_NONE, &this->eot, "Treat text as end-of-paragraph", nullptr},
Behdad Esfahbod25c66d62023-03-01 14:16:08 -0700372#ifdef HB_EXPERIMENTAL_API
Behdad Esfahbod6de9d2b2023-03-01 14:32:06 -0700373 {"justify-to", 0, 0,
374 G_OPTION_ARG_INT, &this->advance, "Target size to justify to", "SIZE, or -1"},
Behdad Esfahbod25c66d62023-03-01 14:16:08 -0700375#endif
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600376 {"preserve-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->preserve_default_ignorables, "Preserve Default-Ignorable characters", nullptr},
377 {"remove-default-ignorables",0, 0, G_OPTION_ARG_NONE, &this->remove_default_ignorables, "Remove Default-Ignorable characters", nullptr},
378 {"invisible-glyph", 0, 0, G_OPTION_ARG_INT, &this->invisible_glyph, "Glyph value to replace Default-Ignorables with", nullptr},
Behdad Esfahbodda500562021-10-26 08:02:29 -0600379 {"not-found-glyph", 0, 0, G_OPTION_ARG_INT, &this->not_found_glyph, "Glyph value to replace not-found characters with", nullptr},
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600380 {"utf8-clusters", 0, 0, G_OPTION_ARG_NONE, &this->utf8_clusters, "Use UTF8 byte indices, not char indices", nullptr},
381 {"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2"},
382 {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", nullptr},
Behdad Esfahbod56f11ec2022-02-18 14:08:43 -0600383 {"unsafe-to-concat",0, 0, G_OPTION_ARG_NONE, &this->unsafe_to_concat, "Produce unsafe-to-concat glyph flag", nullptr},
Behdad Esfahbodf43dadb2022-07-30 10:23:03 -0600384 {"safe-to-insert-tatweel",0, 0, G_OPTION_ARG_NONE, &this->safe_to_insert_tatweel, "Produce safe-to-insert-tatweel glyph flag", nullptr},
Behdad Esfahbodd45f7262022-12-23 13:13:29 -0700385 {"glyphs", 0, 0, G_OPTION_ARG_NONE, &this->glyphs, "Interpret input as glyph string", nullptr},
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600386 {"verify", 0, 0, G_OPTION_ARG_NONE, &this->verify, "Perform sanity checks on shaping results", nullptr},
Behdad Esfahbod6e483c42023-02-28 12:25:32 -0700387 {"num-iterations", 'n',G_OPTION_FLAG_IN_MAIN,
Behdad Esfahbodb83f25c2021-08-11 20:42:20 -0600388 G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"},
Behdad Esfahbodc3599fd2021-08-06 23:24:28 -0600389 {nullptr}
390 };
391 parser->add_group (entries,
392 "shape",
393 "Shape options:",
394 "Options for the shaping process",
395 this);
396
397 const gchar *features_help = "Comma-separated list of font features\n"
398 "\n"
399 " Features can be enabled or disabled, either globally or limited to\n"
400 " specific character ranges. The format for specifying feature settings\n"
401 " follows. All valid CSS font-feature-settings values other than 'normal'\n"
402 " and the global values are also accepted, though not documented below.\n"
403 " CSS string escapes are not supported."
404 "\n"
405 " The range indices refer to the positions between Unicode characters,\n"
406 " unless the --utf8-clusters is provided, in which case range indices\n"
407 " refer to UTF-8 byte indices. The position before the first character\n"
408 " is always 0.\n"
409 "\n"
410 " The format is Python-esque. Here is how it all works:\n"
411 "\n"
412 " Syntax: Value: Start: End:\n"
413 "\n"
414 " Setting value:\n"
415 " \"kern\" 1 0 ∞ # Turn feature on\n"
416 " \"+kern\" 1 0 ∞ # Turn feature on\n"
417 " \"-kern\" 0 0 ∞ # Turn feature off\n"
418 " \"kern=0\" 0 0 ∞ # Turn feature off\n"
419 " \"kern=1\" 1 0 ∞ # Turn feature on\n"
420 " \"aalt=2\" 2 0 ∞ # Choose 2nd alternate\n"
421 "\n"
422 " Setting index:\n"
423 " \"kern[]\" 1 0 ∞ # Turn feature on\n"
424 " \"kern[:]\" 1 0 ∞ # Turn feature on\n"
425 " \"kern[5:]\" 1 5 ∞ # Turn feature on, partial\n"
426 " \"kern[:5]\" 1 0 5 # Turn feature on, partial\n"
427 " \"kern[3:5]\" 1 3 5 # Turn feature on, range\n"
428 " \"kern[3]\" 1 3 3+1 # Turn feature on, single char\n"
429 "\n"
430 " Mixing it all:\n"
431 "\n"
432 " \"aalt[3:5]=2\" 2 3 5 # Turn 2nd alternate on for range";
433
434 GOptionEntry entries2[] =
435 {
436 {"features", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_features, features_help, "list"},
437 {nullptr}
438 };
439 parser->add_group (entries2,
440 "features",
441 "Features options:",
442 "Options for font features used",
443 this);
444}
445
446#endif