Imported Upstream version 0.9.3
[platform/upstream/harfbuzz.git] / src / hb-ot-head-table.hh
1 /*
2  * Copyright © 2010  Red Hat, Inc.
3  * Copyright © 2012  Google, Inc.
4  *
5  *  This is part of HarfBuzz, a text shaping library.
6  *
7  * Permission is hereby granted, without written agreement and without
8  * license or royalty fees, to use, copy, modify, and distribute this
9  * software and its documentation for any purpose, provided that the
10  * above copyright notice and the following two paragraphs appear in
11  * all copies of this software.
12  *
13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17  * DAMAGE.
18  *
19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24  *
25  * Red Hat Author(s): Behdad Esfahbod
26  * Google Author(s): Behdad Esfahbod
27  */
28
29 #ifndef HB_OT_HEAD_TABLE_HH
30 #define HB_OT_HEAD_TABLE_HH
31
32 #include "hb-open-type-private.hh"
33
34
35
36 /*
37  * head -- Font Header
38  */
39
40 #define HB_OT_TAG_head HB_TAG('h','e','a','d')
41
42 struct head
43 {
44   static const hb_tag_t Tag     = HB_OT_TAG_head;
45
46   inline unsigned int get_upem (void) const {
47     unsigned int upem = unitsPerEm;
48     /* If no valid head table found, assume 1000, which matches typicaly Type1 usage. */
49     return 16 <= upem && upem <= 16384 ? upem : 1000;
50   }
51
52   inline bool sanitize (hb_sanitize_context_t *c) {
53     TRACE_SANITIZE ();
54     return TRACE_RETURN (c->check_struct (this) && likely (version.major == 1));
55   }
56
57   protected:
58   FixedVersion  version;                /* Version of the head table--currently
59                                          * 0x00010000 for version 1.0. */
60   FixedVersion  fontRevision;           /* Set by font manufacturer. */
61   ULONG         checkSumAdjustment;     /* To compute: set it to 0, sum the
62                                          * entire font as ULONG, then store
63                                          * 0xB1B0AFBA - sum. */
64   ULONG         magicNumber;            /* Set to 0x5F0F3CF5. */
65   USHORT        flags;                  /* Bit 0: Baseline for font at y=0;
66                                          * Bit 1: Left sidebearing point at x=0;
67                                          * Bit 2: Instructions may depend on point size;
68                                          * Bit 3: Force ppem to integer values for all
69                                          *   internal scaler math; may use fractional
70                                          *   ppem sizes if this bit is clear;
71                                          * Bit 4: Instructions may alter advance width
72                                          *   (the advance widths might not scale linearly);
73
74                                          * Bits 5-10: These should be set according to
75                                          *   Apple's specification. However, they are not
76                                          *   implemented in OpenType.
77                                          * Bit 5: This bit should be set in fonts that are
78                                          *   intended to e laid out vertically, and in
79                                          *   which the glyphs have been drawn such that an
80                                          *   x-coordinate of 0 corresponds to the desired
81                                          *   vertical baseline.
82                                          * Bit 6: This bit must be set to zero.
83                                          * Bit 7: This bit should be set if the font
84                                          *   requires layout for correct linguistic
85                                          *   rendering (e.g. Arabic fonts).
86                                          * Bit 8: This bit should be set for a GX font
87                                          *   which has one or more metamorphosis effects
88                                          *   designated as happening by default.
89                                          * Bit 9: This bit should be set if the font
90                                          *   contains any strong right-to-left glyphs.
91                                          * Bit 10: This bit should be set if the font
92                                          *   contains Indic-style rearrangement effects.
93
94                                          * Bit 11: Font data is 'lossless,' as a result
95                                          *   of having been compressed and decompressed
96                                          *   with the Agfa MicroType Express engine.
97                                          * Bit 12: Font converted (produce compatible metrics)
98                                          * Bit 13: Font optimized for ClearType™.
99                                          *   Note, fonts that rely on embedded bitmaps (EBDT)
100                                          *   for rendering should not be considered optimized
101                                          *   for ClearType, and therefore should keep this bit
102                                          *   cleared.
103                                          * Bit 14: Last Resort font. If set, indicates that
104                                          * the glyphs encoded in the cmap subtables are simply
105                                          * generic symbolic representations of code point
106                                          * ranges and don’t truly represent support for those
107                                          * code points. If unset, indicates that the glyphs
108                                          * encoded in the cmap subtables represent proper
109                                          * support for those code points.
110                                          * Bit 15: Reserved, set to 0. */
111   USHORT        unitsPerEm;             /* Valid range is from 16 to 16384. This value
112                                          * should be a power of 2 for fonts that have
113                                          * TrueType outlines. */
114   LONGDATETIME  created;                /* Number of seconds since 12:00 midnight,
115                                            January 1, 1904. 64-bit integer */
116   LONGDATETIME  modified;               /* Number of seconds since 12:00 midnight,
117                                            January 1, 1904. 64-bit integer */
118   SHORT         xMin;                   /* For all glyph bounding boxes. */
119   SHORT         yMin;                   /* For all glyph bounding boxes. */
120   SHORT         xMax;                   /* For all glyph bounding boxes. */
121   SHORT         yMax;                   /* For all glyph bounding boxes. */
122   USHORT        macStyle;               /* Bit 0: Bold (if set to 1);
123                                          * Bit 1: Italic (if set to 1)
124                                          * Bit 2: Underline (if set to 1)
125                                          * Bit 3: Outline (if set to 1)
126                                          * Bit 4: Shadow (if set to 1)
127                                          * Bit 5: Condensed (if set to 1)
128                                          * Bit 6: Extended (if set to 1)
129                                          * Bits 7-15: Reserved (set to 0). */
130   USHORT        lowestRecPPEM;          /* Smallest readable size in pixels. */
131   SHORT         fontDirectionHint;      /* Deprecated (Set to 2).
132                                          * 0: Fully mixed directional glyphs;
133                                          * 1: Only strongly left to right;
134                                          * 2: Like 1 but also contains neutrals;
135                                          * -1: Only strongly right to left;
136                                          * -2: Like -1 but also contains neutrals. */
137   SHORT         indexToLocFormat;       /* 0 for short offsets, 1 for long. */
138   SHORT         glyphDataFormat;        /* 0 for current format. */
139   public:
140   DEFINE_SIZE_STATIC (54);
141 };
142
143
144
145 #endif /* HB_OT_HEAD_TABLE_HH */