* Red Hat Author(s): Behdad Esfahbod
*/
-#include "hb-mutex-private.hh"
-#include "hb-open-file-private.hh"
+#include "hb-static.cc"
+#include "hb-open-file.hh"
#include "hb-ot-layout-gdef-table.hh"
-#include "hb-ot-layout-gsubgpos-private.hh"
+#include "hb-ot-layout-gsubgpos.hh"
#ifdef HAVE_GLIB
#include <glib.h>
#include <stdio.h>
+using namespace OT;
int
main (int argc, char **argv)
exit (1);
}
- const char *font_data = NULL;
- int len = 0;
-
-#ifdef HAVE_GLIB
- GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL);
- font_data = g_mapped_file_get_contents (mf);
- len = g_mapped_file_get_length (mf);
-#else
- FILE *f = fopen (argv[1], "rb");
- fseek (f, 0, SEEK_END);
- len = ftell (f);
- fseek (f, 0, SEEK_SET);
- font_data = (const char *) malloc (len);
- len = fread ((char *) font_data, 1, len, f);
-#endif
-
+ hb_blob_t *blob = hb_blob_create_from_file (argv[1]);
+ unsigned int len;
+ const char *font_data = hb_blob_get_data (blob, &len);
printf ("Opened font file %s: %d bytes long\n", argv[1], len);
- const OpenTypeFontFile &ot = *CastP<OpenTypeFontFile> (font_data);
+ hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile> (blob);
+ const OpenTypeFontFile* sanitized = font_blob->as<OpenTypeFontFile> ();
+ if (!font_blob->data)
+ {
+ printf ("Sanitization of the file wasn't successful. Exit");
+ return 1;
+ }
+ const OpenTypeFontFile& ot = *sanitized;
+
switch (ot.get_tag ()) {
case OpenTypeFontFile::TrueTypeTag:
case OpenTypeFontFile::Typ1Tag:
printf ("Obsolete Apple Type1 font in SFNT container\n");
break;
+ case OpenTypeFontFile::DFontTag:
+ printf ("DFont Mac Resource Fork\n");
+ break;
default:
printf ("Unknown font format\n");
break;
for (int n_table = 0; n_table < num_tables; n_table++) {
const OpenTypeTable &table = font.get_table (n_table);
printf (" Table %2d of %2d: %.4s (0x%08x+0x%08x)\n", n_table, num_tables,
- (const char *)table.tag,
+ (const char *) table.tag,
(unsigned int) table.offset,
(unsigned int) table.length);
switch (table.tag) {
- case GSUBGPOS::GSUBTag:
- case GSUBGPOS::GPOSTag:
+ case HB_OT_TAG_GSUB:
+ case HB_OT_TAG_GPOS:
{
const GSUBGPOS &g = *CastP<GSUBGPOS> (font_data + table.offset);
else
printf (" Language System %2d of %2d: %.4s\n", n_langsys, num_langsys,
(const char *)script.get_lang_sys_tag (n_langsys));
- if (langsys.get_required_feature_index () == Index::NOT_FOUND_INDEX)
+ if (!langsys.has_required_feature ())
printf (" No required feature\n");
+ else
+ printf (" Required feature index: %d\n",
+ langsys.get_required_feature_index ());
int num_features = langsys.get_feature_count ();
printf (" %d feature(s) found in language system\n", num_features);
printf (" %d feature(s) found in table\n", num_features);
for (int n_feature = 0; n_feature < num_features; n_feature++) {
const Feature &feature = g.get_feature (n_feature);
- printf (" Feature %2d of %2d: %.4s; %d lookup(s)\n", n_feature, num_features,
- (const char *)g.get_feature_tag(n_feature),
- feature.get_lookup_count());
-
int num_lookups = feature.get_lookup_count ();
+ printf (" Feature %2d of %2d: %c%c%c%c\n", n_feature, num_features,
+ HB_UNTAG(g.get_feature_tag(n_feature)));
+
printf (" %d lookup(s) found in feature\n", num_lookups);
for (int n_lookup = 0; n_lookup < num_lookups; n_lookup++) {
printf (" Lookup index %2d of %2d: %d\n", n_lookup, num_lookups,
}
break;
- case GDEF::Tag:
+ case GDEF::tableTag:
{
const GDEF &gdef = *CastP<GDEF> (font_data + table.offset);
return 0;
}
-
-