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