Add 'head' table
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 19 May 2010 16:03:35 +0000 (12:03 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 19 May 2010 16:03:35 +0000 (12:03 -0400)
src/Makefile.am
src/hb-font-private.hh
src/hb-font.cc
src/hb-open-type-private.hh
src/hb-ot-head-private.hh [new file with mode: 0644]

index f52ea49a9c0d22582c2957aa53e7cb6d402e2ba1..fb82f0e0f1a925160512fb829a3d739d4b7b2487 100644 (file)
@@ -20,6 +20,7 @@ HBSOURCES =  \
        hb-open-file-private.hh \
        hb-open-type-private.hh \
        hb-language.c \
+       hb-ot-head-private.hh \
        hb-private.h \
        hb-shape.cc \
        hb-unicode.c \
index 0d82850b0a9fa6e350e846a8d63373c4b5389e21..7cc632782cd3e012f36a31be2458abdab0ff22df 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "hb-font.h"
 
+#include "hb-ot-head-private.hh"
+
 #include "hb-ot-layout-private.hh"
 
 HB_BEGIN_DECLS
@@ -64,6 +66,9 @@ struct _hb_face_t {
   hb_destroy_func_t    destroy;
   void                *user_data;
 
+  hb_blob_t *head_blob;
+  const struct head *head_table;
+
   hb_ot_layout_t ot_layout;
 };
 
index 46b63a4816c151df623ebcf878c65b01e08d4e61..3feddfc8eb641a1ee62d2cb83766643b75924c7f 100644 (file)
@@ -231,6 +231,9 @@ static hb_face_t _hb_face_nil = {
   NULL, /* destroy */
   NULL, /* user_data */
 
+  NULL, /* head_blob */
+  NULL, /* head_table */
+
   {} /* ot_layout */
 };
 
@@ -324,6 +327,9 @@ hb_face_create_for_data (hb_blob_t    *blob,
   face->user_data = _hb_face_for_data_closure_create (Sanitizer<OpenTypeFontFile>::sanitize (blob), index);
   hb_blob_destroy (blob);
 
+  face->head_blob = Sanitizer<head>::sanitize (hb_face_get_table (face, HB_OT_TAG_head));
+  face->head_table = Sanitizer<head>::lock_instance (face->head_blob);
+
   _hb_ot_layout_init (face);
 
   return face;
@@ -349,6 +355,9 @@ hb_face_destroy (hb_face_t *face)
 
   _hb_ot_layout_fini (face);
 
+  hb_blob_unlock (face->head_blob);
+  hb_blob_destroy (face->head_blob);
+
   if (face->destroy)
     face->destroy (face->user_data);
 
index 4fc82dd5fbb6b67a232b80e12c2d9dc766b1e2b0..2ab639c4cacec18c9a834e14cfed32453366372d 100644 (file)
@@ -120,7 +120,7 @@ inline Type& StructAfter(TObject &X)
  */
 
 /* Global nul-content Null pool.  Enlarge as necessary. */
-static const void *_NullPool[16 / sizeof (void *)];
+static const void *_NullPool[64 / sizeof (void *)];
 
 /* Generic nul-content Null objects. */
 template <typename Type>
diff --git a/src/hb-ot-head-private.hh b/src/hb-ot-head-private.hh
new file mode 100644 (file)
index 0000000..cdc981f
--- /dev/null
@@ -0,0 +1,128 @@
+/*\r
+ * Copyright (C) 2010  Red Hat, Inc.\r
+ *\r
+ *  This is part of HarfBuzz, a text shaping library.\r
+ *\r
+ * Permission is hereby granted, without written agreement and without\r
+ * license or royalty fees, to use, copy, modify, and distribute this\r
+ * software and its documentation for any purpose, provided that the\r
+ * above copyright notice and the following two paragraphs appear in\r
+ * all copies of this software.\r
+ *\r
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR\r
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES\r
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN\r
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\r
+ * DAMAGE.\r
+ *\r
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,\r
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\r
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS\r
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO\r
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.\r
+ *\r
+ * Red Hat Author(s): Behdad Esfahbod\r
+ */\r
+\r
+#ifndef HB_OT_HEAD_PRIVATE_HH\r
+#define HB_OT_HEAD_PRIVATE_HH\r
+\r
+#include "hb-open-type-private.hh"\r
+\r
+/*\r
+ * head\r
+ */\r
+\r
+#define HB_OT_TAG_head HB_TAG('h','e','a','d')\r
+\r
+struct head\r
+{\r
+  static const hb_tag_t Tag    = HB_OT_TAG_head;\r
+\r
+  inline bool sanitize (hb_sanitize_context_t *c) {\r
+    TRACE_SANITIZE ();\r
+    /* Shall we check for magicNumber here?  Who cares? */\r
+    return c->check_struct (this) && likely (version.major == 1);\r
+  }\r
+\r
+  FixedVersion version;                /* Version of the head table--currently\r
+                                        * 0x00010000 for version 1.0. */\r
+  FixedVersion fontRevision;           /* Set by font manufacturer. */\r
+  ULONG                checkSumAdjustment;     /* To compute: set it to 0, sum the\r
+                                        * entire font as ULONG, then store\r
+                                        * 0xB1B0AFBA - sum. */\r
+  ULONG                magicNumber;            /* Set to 0x5F0F3CF5. */\r
+  USHORT       flags;                  /* Bit 0: Baseline for font at y=0;\r
+                                        * Bit 1: Left sidebearing point at x=0;\r
+                                        * Bit 2: Instructions may depend on point size;\r
+                                        * Bit 3: Force ppem to integer values for all\r
+                                        *   internal scaler math; may use fractional\r
+                                        *   ppem sizes if this bit is clear;\r
+                                        * Bit 4: Instructions may alter advance width\r
+                                        *   (the advance widths might not scale linearly);\r
+\r
+                                        * Bits 5-10: These should be set according to\r
+                                        *   Apple's specification. However, they are not\r
+                                        *   implemented in OpenType.\r
+                                        * Bit 5: This bit should be set in fonts that are\r
+                                        *   intended to e laid out vertically, and in\r
+                                        *   which the glyphs have been drawn such that an\r
+                                        *   x-coordinate of 0 corresponds to the desired\r
+                                        *   vertical baseline.\r
+                                        * Bit 6: This bit must be set to zero.\r
+                                        * Bit 7: This bit should be set if the font\r
+                                        *   requires layout for correct linguistic\r
+                                        *   rendering (e.g. Arabic fonts).\r
+                                        * Bit 8: This bit should be set for a GX font\r
+                                        *   which has one or more metamorphosis effects\r
+                                        *   designated as happening by default.\r
+                                        * Bit 9: This bit should be set if the font\r
+                                        *   contains any strong right-to-left glyphs.\r
+                                        * Bit 10: This bit should be set if the font\r
+                                        *   contains Indic-style rearrangement effects.\r
+\r
+                                        * Bit 11: Font data is 'lossless,' as a result\r
+                                        *   of having been compressed and decompressed\r
+                                        *   with the Agfa MicroType Express engine.\r
+                                        * Bit 12: Font converted (produce compatible metrics)\r
+                                        * Bit 13: Font optimized for ClearType™.\r
+                                        *   Note, fonts that rely on embedded bitmaps (EBDT)\r
+                                        *   for rendering should not be considered optimized\r
+                                        *   for ClearType, and therefore should keep this bit\r
+                                        *   cleared.\r
+                                        * Bit 14: Reserved, set to 0\r
+                                        * Bit 15: Reserved, set to 0. */\r
+  USHORT       unitsPerEm;             /* Valid range is from 16 to 16384. This value\r
+                                        * should be a power of 2 for fonts that have\r
+                                        * TrueType outlines. */\r
+  LONGDATETIME created;                /* Number of seconds since 12:00 midnight,\r
+                                          January 1, 1904. 64-bit integer */\r
+  LONGDATETIME modified;               /* Number of seconds since 12:00 midnight,\r
+                                          January 1, 1904. 64-bit integer */\r
+  SHORT                xMin;                   /* For all glyph bounding boxes. */\r
+  SHORT                yMin;                   /* For all glyph bounding boxes. */\r
+  SHORT                xMax;                   /* For all glyph bounding boxes. */\r
+  SHORT                yMax;                   /* For all glyph bounding boxes. */\r
+  USHORT       macStyle;               /* Bit 0: Bold (if set to 1);\r
+                                        * Bit 1: Italic (if set to 1)\r
+                                        * Bit 2: Underline (if set to 1)\r
+                                        * Bit 3: Outline (if set to 1)\r
+                                        * Bit 4: Shadow (if set to 1)\r
+                                        * Bit 5: Condensed (if set to 1)\r
+                                        * Bit 6: Extended (if set to 1)\r
+                                        * Bits 7-15: Reserved (set to 0). */\r
+  USHORT       lowestRecPPEM;          /* Smallest readable size in pixels. */\r
+  SHORT                fontDirectionHint;      /* Deprecated (Set to 2).\r
+                                        * 0: Fully mixed directional glyphs;\r
+                                        * 1: Only strongly left to right;\r
+                                        * 2: Like 1 but also contains neutrals;\r
+                                        * -1: Only strongly right to left;\r
+                                        * -2: Like -1 but also contains neutrals. */\r
+  SHORT                indexToLocFormat;       /* 0 for short offsets, 1 for long. */\r
+  SHORT                glyphDataFormat;        /* 0 for current format. */\r
+  public:\r
+  DEFINE_SIZE_STATIC (54);\r
+};\r
+\r
+\r
+#endif /* HB_OT_HEAD_PRIVATE_HH */\r