summaryrefslogtreecommitdiff
path: root/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc')
-rw-r--r--Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc
new file mode 100644
index 00000000000..5be8676c64c
--- /dev/null
+++ b/Build/source/texk/lcdf-typetools/lcdf-typetools-2.104/libefont/ttfhead.cc
@@ -0,0 +1,69 @@
+// -*- related-file-name: "../include/efont/ttfhead.hh" -*-
+
+/* ttfhead.{cc,hh} -- TrueType head table
+ *
+ * Copyright (c) 2007-2012 Eddie Kohler
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version. This program is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <efont/ttfhead.hh>
+#include <lcdf/error.hh>
+#include <lcdf/straccum.hh>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <algorithm>
+
+namespace Efont { namespace OpenType {
+
+Head::Head(const String &s, ErrorHandler *errh)
+ : _d(s)
+{
+ _error = parse_header(errh ? errh : ErrorHandler::silent_handler());
+}
+
+int
+Head::parse_header(ErrorHandler *errh)
+{
+ // HEAD format:
+ // 0 Fixed Table version number 0x00010000 (ver. 1.0)
+ // 4 Fixed fontRevision
+ // 8 ULONG checkSumAdjustment
+ // 12 ULONG magicNumber Set to 0x5F0F3CF5
+ // 16 USHORT flags
+ // 18 USHORT unitsPerEm
+ // 20 LONGDATETIME created
+ // 28 LONGDATETIME modified
+ // 36 USHORT xMin
+ // 38 SHORT yMin
+ // 40 SHORT xMax
+ // 42 SHORT yMax
+ // 44 USHORT macStyle
+ // 46 USHORT lowestRecPPEM
+ // 48 SHORT fontDirectionHint
+ // 50 SHORT indexToLocFormat
+ // 52 SHORT glyphDataFormat
+ int len = _d.length();
+ const uint8_t *data = _d.udata();
+ if (len == 0)
+ return errh->error("font has no 'head' table"), -EFAULT;
+ if (54 > len)
+ return errh->error("'head' table too small"), -EFAULT;
+ if (!(data[0] == '\000' && data[1] == '\001'))
+ return errh->error("bad 'head' version number"), -ERANGE;
+ if (_d.u32(12) != 0x5F0F3CF5)
+ return errh->error("bad 'head' magic number"), -ERANGE;
+ return 0;
+}
+
+}}