1 /*
2 * Copyright (C) 2000 Red Hat, Inc.
3 *
4 * This is part of HarfBuzz, an OpenType Layout engine 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 * Red Hat Author(s): Owen Taylor
25 */
26
27 #include <stdio.h>
28 #include <stdlib.h>
29
30 #include "harfbuzz.h"
31 #include "harfbuzz-dump.h"
32
33 #define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
34
35 static int
croak(const char * situation,HB_Error error)36 croak (const char *situation, HB_Error error)
37 {
38 fprintf (stderr, "%s: Error %d\n", situation, error);
39
40 exit (1);
41 }
42
43 int
main(int argc,char ** argv)44 main (int argc, char **argv)
45 {
46 HB_Error error;
47 FT_Library library;
48 HB_Font font;
49 HB_GSUB gsub;
50 HB_GPOS gpos;
51
52 if (argc != 2)
53 {
54 fprintf (stderr, "Usage: harfbuzz-dump MYFONT.TTF\n");
55 exit(1);
56 }
57
58 if ((error = FT_Init_FreeType (&library)))
59 croak ("FT_Init_FreeType", error);
60
61 if ((error = FT_New_Face (library, argv[1], 0, &font)))
62 croak ("FT_New_Face", error);
63
64 printf ("<?xml version=\"1.0\"?>\n");
65 printf ("<OpenType>\n");
66
67 if (!(error = HB_Load_GSUB_Table (font, &gsub, NULL)))
68 {
69 HB_Dump_GSUB_Table (gsub, stdout);
70
71 if ((error = HB_Done_GSUB_Table (gsub)))
72 croak ("HB_Done_GSUB_Table", error);
73 }
74 else if (error != HB_Err_Not_Covered)
75 fprintf (stderr, "HB_Load_GSUB_Table: error 0x%x\n", error);
76
77 if (!(error = HB_Load_GPOS_Table (font, &gpos, NULL)))
78 {
79 HB_Dump_GPOS_Table (gpos, stdout);
80
81 if ((error = HB_Done_GPOS_Table (gpos)))
82 croak ("HB_Done_GPOS_Table", error);
83 }
84 else if (error != HB_Err_Not_Covered)
85 fprintf (stderr, "HB_Load_GPOS_Table: error 0x%x\n", error);
86
87 printf ("</OpenType>\n");
88
89 if ((error = FT_Done_Face (font)))
90 croak ("FT_Done_Face", error);
91
92 if ((error = FT_Done_FreeType (library)))
93 croak ("FT_Done_FreeType", error);
94
95 return 0;
96 }
97
98