summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2018-06-26 11:15:52 +0900
committerYoungbok Shin <youngb.shin@samsung.com>2018-06-26 11:15:52 +0900
commitb9f425ddd6223cd82b3d35f13fbd060d3c0c0e38 (patch)
tree87220edcaa6118811d062d77d0562a3f74c7f885 /src/main.cc
parent1c272a48507bb3c7905aa30d8bf0d092b474f781 (diff)
downloadharfbuzz-b9f425ddd6223cd82b3d35f13fbd060d3c0c0e38.tar.gz
harfbuzz-b9f425ddd6223cd82b3d35f13fbd060d3c0c0e38.tar.bz2
harfbuzz-b9f425ddd6223cd82b3d35f13fbd060d3c0c0e38.zip
Imported Upstream version 1.8.1upstream/1.8.1
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc39
1 files changed, 15 insertions, 24 deletions
diff --git a/src/main.cc b/src/main.cc
index d221e9d..ca0fcc5 100644
--- a/src/main.cc
+++ b/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;
}
-
-