2 * Copyright © 2010,2011 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
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.
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
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.
24 * Google Author(s): Behdad Esfahbod
34 main (int argc, char **argv)
37 fprintf (stderr, "usage: %s font-file text\n", argv[0]);
42 hb_blob_t *blob = hb_blob_create_from_file_or_fail (argv[1]);
43 hb_face_t *face = hb_face_create (blob, 0 /* first face */);
44 hb_blob_destroy (blob);
47 hb_font_t *font = hb_font_create (face);
48 hb_buffer_t *buffer = hb_buffer_create ();
50 hb_buffer_add_utf8 (buffer, argv[2], -1, 0, -1);
51 hb_buffer_guess_segment_properties (buffer);
52 hb_shape (font, buffer, NULL, 0);
54 hb_tag_t features[] = {HB_TAG('a','a','l','t'), HB_TAG_NONE};
55 hb_set_t *lookup_indexes = hb_set_create ();
56 hb_ot_layout_collect_lookups (face,
61 printf ("lookups %u\n", hb_set_get_population (lookup_indexes));
64 hb_glyph_info_t *info = hb_buffer_get_glyph_infos (buffer, &count);
65 for (unsigned i = 0; i < count; i++)
67 unsigned alt_count = 0;
68 for (hb_codepoint_t lookup_index = HB_SET_VALUE_INVALID;
69 hb_set_next (lookup_indexes, &lookup_index);)
70 if ((alt_count = hb_ot_layout_lookup_get_glyph_alternates (face,
77 printf ("glyph %u alt count %u\n", info[i].codepoint, alt_count);
80 hb_set_destroy (lookup_indexes);
81 hb_buffer_destroy (buffer);
82 hb_font_destroy (font);
83 hb_face_destroy (face);