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 * head -- Font Header 36 * https://docs.microsoft.com/en-us/typography/opentype/spec/head 37 */ 38 #define HB_OT_TAG_head HB_TAG('h','e','a','d') 39 40 41 namespace OT { 42 43 44 struct head 45 { 46 friend struct OffsetTable; 47 48 static const hb_tag_t tableTag = HB_OT_TAG_head; 49 50 inline unsigned int get_upem (void) const 51 { 52 unsigned int upem = unitsPerEm; 53 /* If no valid head table found, assume 1000, which matches typical Type1 usage. */ 54 return 16 <= upem && upem <= 16384 ? upem : 1000; 55 } 56 57 inline bool sanitize (hb_sanitize_context_t *c) const 58 { 59 TRACE_SANITIZE (this); 60 return_trace (c->check_struct (this) && 61 version.major == 1 && 62 magicNumber == 0x5F0F3CF5u); 63 } 64 65 protected: 66 FixedVersion<>version; /* Version of the head table--currently 67 * 0x00010000u for version 1.0. */ 68 FixedVersion<>fontRevision; /* Set by font manufacturer. */ 69 HBUINT32 checkSumAdjustment; /* To compute: set it to 0, sum the 70 * entire font as HBUINT32, then store 71 * 0xB1B0AFBAu - sum. */ 72 HBUINT32 magicNumber; /* Set to 0x5F0F3CF5u. */ 73 HBUINT16 flags; /* Bit 0: Baseline for font at y=0; 74 * Bit 1: Left sidebearing point at x=0; 75 * Bit 2: Instructions may depend on point size; 76 * Bit 3: Force ppem to integer values for all 77 * internal scaler math; may use fractional 124 HBINT16 xMin; /* For all glyph bounding boxes. */ 125 HBINT16 yMin; /* For all glyph bounding boxes. */ 126 HBINT16 xMax; /* For all glyph bounding boxes. */ 127 HBINT16 yMax; /* For all glyph bounding boxes. */ 128 HBUINT16 macStyle; /* Bit 0: Bold (if set to 1); 129 * Bit 1: Italic (if set to 1) 130 * Bit 2: Underline (if set to 1) 131 * Bit 3: Outline (if set to 1) 132 * Bit 4: Shadow (if set to 1) 133 * Bit 5: Condensed (if set to 1) 134 * Bit 6: Extended (if set to 1) 135 * Bits 7-15: Reserved (set to 0). */ 136 HBUINT16 lowestRecPPEM; /* Smallest readable size in pixels. */ 137 HBINT16 fontDirectionHint; /* Deprecated (Set to 2). 138 * 0: Fully mixed directional glyphs; 139 * 1: Only strongly left to right; 140 * 2: Like 1 but also contains neutrals; 141 * -1: Only strongly right to left; 142 * -2: Like -1 but also contains neutrals. */ 143 public: 144 HBINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ 145 HBINT16 glyphDataFormat; /* 0 for current format. */ 146 147 DEFINE_SIZE_STATIC (54); 148 }; 149 150 151 } /* namespace OT */ 152 153 154 #endif /* HB_OT_HEAD_TABLE_HH */ | 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.hh" 33 34 /* 35 * head -- Font Header 36 * https://docs.microsoft.com/en-us/typography/opentype/spec/head 37 */ 38 #define HB_OT_TAG_head HB_TAG('h','e','a','d') 39 40 41 namespace OT { 42 43 44 struct head 45 { 46 friend struct OffsetTable; 47 48 static constexpr hb_tag_t tableTag = HB_OT_TAG_head; 49 50 unsigned int get_upem () const 51 { 52 unsigned int upem = unitsPerEm; 53 /* If no valid head table found, assume 1000, which matches typical Type1 usage. */ 54 return 16 <= upem && upem <= 16384 ? upem : 1000; 55 } 56 57 enum mac_style_flag_t { 58 BOLD = 1u<<0, 59 ITALIC = 1u<<1, 60 UNDERLINE = 1u<<2, 61 OUTLINE = 1u<<3, 62 SHADOW = 1u<<4, 63 CONDENSED = 1u<<5 64 }; 65 66 bool is_bold () const { return macStyle & BOLD; } 67 bool is_italic () const { return macStyle & ITALIC; } 68 bool is_condensed () const { return macStyle & CONDENSED; } 69 70 bool sanitize (hb_sanitize_context_t *c) const 71 { 72 TRACE_SANITIZE (this); 73 return_trace (c->check_struct (this) && 74 version.major == 1 && 75 magicNumber == 0x5F0F3CF5u); 76 } 77 78 protected: 79 FixedVersion<>version; /* Version of the head table--currently 80 * 0x00010000u for version 1.0. */ 81 FixedVersion<>fontRevision; /* Set by font manufacturer. */ 82 HBUINT32 checkSumAdjustment; /* To compute: set it to 0, sum the 83 * entire font as HBUINT32, then store 84 * 0xB1B0AFBAu - sum. */ 85 HBUINT32 magicNumber; /* Set to 0x5F0F3CF5u. */ 86 HBUINT16 flags; /* Bit 0: Baseline for font at y=0; 87 * Bit 1: Left sidebearing point at x=0; 88 * Bit 2: Instructions may depend on point size; 89 * Bit 3: Force ppem to integer values for all 90 * internal scaler math; may use fractional 137 HBINT16 xMin; /* For all glyph bounding boxes. */ 138 HBINT16 yMin; /* For all glyph bounding boxes. */ 139 HBINT16 xMax; /* For all glyph bounding boxes. */ 140 HBINT16 yMax; /* For all glyph bounding boxes. */ 141 HBUINT16 macStyle; /* Bit 0: Bold (if set to 1); 142 * Bit 1: Italic (if set to 1) 143 * Bit 2: Underline (if set to 1) 144 * Bit 3: Outline (if set to 1) 145 * Bit 4: Shadow (if set to 1) 146 * Bit 5: Condensed (if set to 1) 147 * Bit 6: Extended (if set to 1) 148 * Bits 7-15: Reserved (set to 0). */ 149 HBUINT16 lowestRecPPEM; /* Smallest readable size in pixels. */ 150 HBINT16 fontDirectionHint; /* Deprecated (Set to 2). 151 * 0: Fully mixed directional glyphs; 152 * 1: Only strongly left to right; 153 * 2: Like 1 but also contains neutrals; 154 * -1: Only strongly right to left; 155 * -2: Like -1 but also contains neutrals. */ 156 public: 157 HBUINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ 158 HBUINT16 glyphDataFormat; /* 0 for current format. */ 159 160 DEFINE_SIZE_STATIC (54); 161 }; 162 163 164 } /* namespace OT */ 165 166 167 #endif /* HB_OT_HEAD_TABLE_HH */ |