2008-01-15 23:46:32 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Red Hat, Inc.
|
2000-12-20 05:41:36 +01:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* This is part of HarfBuzz, an OpenType Layout engine library.
|
2000-12-20 05:41:36 +01:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
2000-12-20 05:41:36 +01:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
2000-12-20 05:41:36 +01:00
|
|
|
*
|
2008-01-15 23:46:32 +01:00
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Red Hat Author(s): Owen Taylor
|
2000-12-20 05:41:36 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2007-11-07 09:06:01 +01:00
|
|
|
#include "harfbuzz.h"
|
2006-03-31 14:28:09 +02:00
|
|
|
#include "harfbuzz-dump.h"
|
2000-12-20 05:41:36 +01:00
|
|
|
|
|
|
|
#define N_ELEMENTS(arr) (sizeof(arr)/ sizeof((arr)[0]))
|
|
|
|
|
2005-08-29 12:06:40 +02:00
|
|
|
static int
|
2007-10-11 02:07:58 +02:00
|
|
|
croak (const char *situation, HB_Error error)
|
2000-12-20 05:41:36 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: Error %d\n", situation, error);
|
|
|
|
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2007-10-11 02:07:58 +02:00
|
|
|
HB_Error error;
|
2000-12-20 05:41:36 +01:00
|
|
|
FT_Library library;
|
2007-11-07 10:59:18 +01:00
|
|
|
HB_Font font;
|
2006-03-31 14:28:09 +02:00
|
|
|
HB_GSUB gsub;
|
|
|
|
HB_GPOS gpos;
|
2000-12-20 05:41:36 +01:00
|
|
|
|
|
|
|
if (argc != 2)
|
|
|
|
{
|
2009-01-29 10:19:43 +01:00
|
|
|
fprintf (stderr, "Usage: harfbuzz-dump MYFONT.TTF\n");
|
2000-12-20 05:41:36 +01:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((error = FT_Init_FreeType (&library)))
|
|
|
|
croak ("FT_Init_FreeType", error);
|
|
|
|
|
2007-11-07 10:59:18 +01:00
|
|
|
if ((error = FT_New_Face (library, argv[1], 0, &font)))
|
2000-12-20 05:41:36 +01:00
|
|
|
croak ("FT_New_Face", error);
|
|
|
|
|
2005-08-29 12:06:40 +02:00
|
|
|
printf ("<?xml version=\"1.0\"?>\n");
|
|
|
|
printf ("<OpenType>\n");
|
|
|
|
|
2007-11-07 10:59:18 +01:00
|
|
|
if (!(error = HB_Load_GSUB_Table (font, &gsub, NULL)))
|
2000-12-20 05:41:36 +01:00
|
|
|
{
|
2006-03-31 14:28:09 +02:00
|
|
|
HB_Dump_GSUB_Table (gsub, stdout);
|
2000-12-20 05:41:36 +01:00
|
|
|
|
2006-03-31 14:28:09 +02:00
|
|
|
if ((error = HB_Done_GSUB_Table (gsub)))
|
|
|
|
croak ("HB_Done_GSUB_Table", error);
|
2000-12-20 05:41:36 +01:00
|
|
|
}
|
2007-10-26 01:22:17 +02:00
|
|
|
else if (error != HB_Err_Not_Covered)
|
2007-11-18 23:34:08 +01:00
|
|
|
fprintf (stderr, "HB_Load_GSUB_Table: error 0x%x\n", error);
|
2000-12-20 05:41:36 +01:00
|
|
|
|
2007-11-07 10:59:18 +01:00
|
|
|
if (!(error = HB_Load_GPOS_Table (font, &gpos, NULL)))
|
2000-12-20 05:41:36 +01:00
|
|
|
{
|
2006-03-31 14:28:09 +02:00
|
|
|
HB_Dump_GPOS_Table (gpos, stdout);
|
2000-12-20 05:41:36 +01:00
|
|
|
|
2006-03-31 14:28:09 +02:00
|
|
|
if ((error = HB_Done_GPOS_Table (gpos)))
|
|
|
|
croak ("HB_Done_GPOS_Table", error);
|
2000-12-20 05:41:36 +01:00
|
|
|
}
|
2007-10-26 01:22:17 +02:00
|
|
|
else if (error != HB_Err_Not_Covered)
|
2007-11-18 23:34:08 +01:00
|
|
|
fprintf (stderr, "HB_Load_GPOS_Table: error 0x%x\n", error);
|
2000-12-20 05:41:36 +01:00
|
|
|
|
2005-08-29 12:06:40 +02:00
|
|
|
printf ("</OpenType>\n");
|
|
|
|
|
2007-11-07 10:59:18 +01:00
|
|
|
if ((error = FT_Done_Face (font)))
|
2000-12-20 05:41:36 +01:00
|
|
|
croak ("FT_Done_Face", error);
|
|
|
|
|
|
|
|
if ((error = FT_Done_FreeType (library)))
|
|
|
|
croak ("FT_Done_FreeType", error);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|