diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-06-06 07:23:34 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2018-06-06 07:23:34 +0000 |
commit | b00780a7898db7f92c00d485fa1524805cd3e070 (patch) | |
tree | 88f07845cafb38cde35e3586d821a6c0505381df /Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc | |
parent | 3809fcc9aa6e0a70857cbe4985576c55317539dc (diff) |
harfbuzz 1.8.0
git-svn-id: svn://tug.org/texlive/trunk@47939 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc')
-rw-r--r-- | Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc index d221e9da221..ca0fcc5b607 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/main.cc @@ -24,6 +24,7 @@ * Red Hat Author(s): Behdad Esfahbod */ +#include "hb-static.cc" #include "hb-open-file-private.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsubgpos-private.hh" @@ -37,10 +38,6 @@ using namespace OT; -#ifndef HB_NO_VISIBILITY -const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {}; -#endif - int main (int argc, char **argv) { @@ -49,25 +46,21 @@ main (int argc, char **argv) exit (1); } - const char *font_data = nullptr; - int len = 0; - -#ifdef HAVE_GLIB - GMappedFile *mf = g_mapped_file_new (argv[1], false, nullptr); - 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); + Sanitizer<OpenTypeFontFile> sanitizer; + hb_blob_t *font_blob = sanitizer.sanitize (blob); + const OpenTypeFontFile* sanitized = font_blob->as<OpenTypeFontFile> (); + if (sanitized == &Null(OpenTypeFontFile)) + { + printf ("Sanitization of the file wasn't successful. Exit"); + return 1; + } + const OpenTypeFontFile& ot = *sanitized; + switch (ot.get_tag ()) { case OpenTypeFontFile::TrueTypeTag: @@ -101,7 +94,7 @@ main (int argc, char **argv) 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); @@ -197,5 +190,3 @@ main (int argc, char **argv) return 0; } - - |