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