1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright © 2019 Adobe, Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * This is part of HarfBuzz, a text shaping library. 5cb93a386Sopenharmony_ci * 6cb93a386Sopenharmony_ci * Permission is hereby granted, without written agreement and without 7cb93a386Sopenharmony_ci * license or royalty fees, to use, copy, modify, and distribute this 8cb93a386Sopenharmony_ci * software and its documentation for any purpose, provided that the 9cb93a386Sopenharmony_ci * above copyright notice and the following two paragraphs appear in 10cb93a386Sopenharmony_ci * all copies of this software. 11cb93a386Sopenharmony_ci * 12cb93a386Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13cb93a386Sopenharmony_ci * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14cb93a386Sopenharmony_ci * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15cb93a386Sopenharmony_ci * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16cb93a386Sopenharmony_ci * DAMAGE. 17cb93a386Sopenharmony_ci * 18cb93a386Sopenharmony_ci * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19cb93a386Sopenharmony_ci * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20cb93a386Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21cb93a386Sopenharmony_ci * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22cb93a386Sopenharmony_ci * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23cb93a386Sopenharmony_ci * 24cb93a386Sopenharmony_ci * Adobe Author(s): Michiharu Ariza 25cb93a386Sopenharmony_ci */ 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci#include "hb.hh" 28cb93a386Sopenharmony_ci#include "hb-ot.h" 29cb93a386Sopenharmony_ci 30cb93a386Sopenharmony_ci#ifdef HB_NO_OPEN 31cb93a386Sopenharmony_ci#define hb_blob_create_from_file_or_fail(x) hb_blob_get_empty () 32cb93a386Sopenharmony_ci#endif 33cb93a386Sopenharmony_ci 34cb93a386Sopenharmony_ciint 35cb93a386Sopenharmony_cimain (int argc, char **argv) 36cb93a386Sopenharmony_ci{ 37cb93a386Sopenharmony_ci if (argc != 2) { 38cb93a386Sopenharmony_ci fprintf (stderr, "usage: %s font-file\n", argv[0]); 39cb93a386Sopenharmony_ci exit (1); 40cb93a386Sopenharmony_ci } 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_ci hb_blob_t *blob = hb_blob_create_from_file_or_fail (argv[1]); 43cb93a386Sopenharmony_ci assert (blob); 44cb93a386Sopenharmony_ci hb_face_t *face = hb_face_create (blob, 0 /* first face */); 45cb93a386Sopenharmony_ci hb_font_t *font = hb_font_create (face); 46cb93a386Sopenharmony_ci hb_blob_destroy (blob); 47cb93a386Sopenharmony_ci blob = nullptr; 48cb93a386Sopenharmony_ci 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci const unsigned int num_glyphs = hb_face_get_glyph_count (face); 51cb93a386Sopenharmony_ci int result = 1; 52cb93a386Sopenharmony_ci 53cb93a386Sopenharmony_ci for (hb_codepoint_t gid = 0; gid < num_glyphs; gid++) 54cb93a386Sopenharmony_ci { 55cb93a386Sopenharmony_ci char buf[64]; 56cb93a386Sopenharmony_ci unsigned int buf_size = sizeof (buf); 57cb93a386Sopenharmony_ci if (hb_font_get_glyph_name (font, gid, buf, buf_size)) 58cb93a386Sopenharmony_ci { 59cb93a386Sopenharmony_ci hb_codepoint_t gid_inv; 60cb93a386Sopenharmony_ci if (hb_font_get_glyph_from_name(font, buf, strlen (buf), &gid_inv)) 61cb93a386Sopenharmony_ci { 62cb93a386Sopenharmony_ci if (gid == gid_inv) 63cb93a386Sopenharmony_ci { 64cb93a386Sopenharmony_ci printf ("%u <-> %s\n", gid, buf); 65cb93a386Sopenharmony_ci } 66cb93a386Sopenharmony_ci else 67cb93a386Sopenharmony_ci { 68cb93a386Sopenharmony_ci printf ("%u -> %s -> %u\n", gid, buf, gid_inv); 69cb93a386Sopenharmony_ci result = 0; 70cb93a386Sopenharmony_ci } 71cb93a386Sopenharmony_ci } 72cb93a386Sopenharmony_ci else 73cb93a386Sopenharmony_ci { 74cb93a386Sopenharmony_ci printf ("%u -> %s -> ?\n", gid, buf); 75cb93a386Sopenharmony_ci result = 0; 76cb93a386Sopenharmony_ci } 77cb93a386Sopenharmony_ci } 78cb93a386Sopenharmony_ci else 79cb93a386Sopenharmony_ci { 80cb93a386Sopenharmony_ci printf ("%u -> ?\n", gid); 81cb93a386Sopenharmony_ci result = 0; 82cb93a386Sopenharmony_ci } 83cb93a386Sopenharmony_ci } 84cb93a386Sopenharmony_ci 85cb93a386Sopenharmony_ci hb_font_destroy (font); 86cb93a386Sopenharmony_ci hb_face_destroy (face); 87cb93a386Sopenharmony_ci 88cb93a386Sopenharmony_ci return result; 89cb93a386Sopenharmony_ci} 90