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