Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2007,2008,2009 Red Hat, Inc. |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 3 | * Copyright © 2012 Google, Inc. |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 4 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 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 |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 26 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 27 | */ |
| 28 | |
Behdad Esfahbod | 5f5b24f | 2009-08-02 20:03:12 -0400 | [diff] [blame] | 29 | #ifndef HB_OPEN_FILE_PRIVATE_HH |
| 30 | #define HB_OPEN_FILE_PRIVATE_HH |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 31 | |
Behdad Esfahbod | 7edb430 | 2009-08-04 22:06:57 -0400 | [diff] [blame] | 32 | #include "hb-open-type-private.hh" |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 33 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 34 | |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 35 | namespace OT { |
| 36 | |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 37 | |
| 38 | /* |
| 39 | * |
| 40 | * The OpenType Font File |
| 41 | * |
| 42 | */ |
| 43 | |
| 44 | |
| 45 | /* |
| 46 | * Organization of an OpenType Font |
| 47 | */ |
| 48 | |
| 49 | struct OpenTypeFontFile; |
| 50 | struct OffsetTable; |
| 51 | struct TTCHeader; |
| 52 | |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 53 | |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 54 | typedef struct TableRecord |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 55 | { |
Behdad Esfahbod | de2118e | 2015-02-17 17:27:44 +0300 | [diff] [blame] | 56 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 57 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 58 | TRACE_SANITIZE (this); |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 59 | return_trace (c->check_struct (this)); |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 60 | } |
| 61 | |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 62 | Tag tag; /* 4-byte identifier. */ |
| 63 | CheckSum checkSum; /* CheckSum for this table. */ |
| 64 | ULONG offset; /* Offset from beginning of TrueType font |
| 65 | * file. */ |
| 66 | ULONG length; /* Length of this table. */ |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 67 | public: |
| 68 | DEFINE_SIZE_STATIC (16); |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 69 | } OpenTypeTable; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 70 | |
| 71 | typedef struct OffsetTable |
| 72 | { |
| 73 | friend struct OpenTypeFontFile; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 74 | |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 75 | inline unsigned int get_table_count (void) const |
| 76 | { return numTables; } |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 77 | inline const TableRecord& get_table (unsigned int i) const |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 78 | { |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 79 | if (unlikely (i >= numTables)) return Null(TableRecord); |
| 80 | return tables[i]; |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 81 | } |
| 82 | inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const |
| 83 | { |
Behdad Esfahbod | ffd321a | 2010-04-21 00:14:12 -0400 | [diff] [blame] | 84 | Tag t; |
| 85 | t.set (tag); |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 86 | unsigned int count = numTables; |
| 87 | for (unsigned int i = 0; i < count; i++) |
| 88 | { |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 89 | if (t == tables[i].tag) |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 90 | { |
| 91 | if (table_index) *table_index = i; |
| 92 | return true; |
| 93 | } |
| 94 | } |
Behdad Esfahbod | b5db4f1 | 2010-05-10 22:22:22 -0400 | [diff] [blame] | 95 | if (table_index) *table_index = Index::NOT_FOUND_INDEX; |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 96 | return false; |
| 97 | } |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 98 | inline const TableRecord& get_table_by_tag (hb_tag_t tag) const |
Behdad Esfahbod | bff3c0f | 2009-08-07 19:46:30 -0400 | [diff] [blame] | 99 | { |
| 100 | unsigned int table_index; |
| 101 | find_table_index (tag, &table_index); |
| 102 | return get_table (table_index); |
| 103 | } |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 104 | |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 105 | public: |
Behdad Esfahbod | de2118e | 2015-02-17 17:27:44 +0300 | [diff] [blame] | 106 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 107 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 108 | TRACE_SANITIZE (this); |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 109 | return_trace (c->check_struct (this) && c->check_array (tables, TableRecord::static_size, numTables)); |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 110 | } |
| 111 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 112 | protected: |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 113 | Tag sfnt_version; /* '\0\001\0\00' if TrueType / 'OTTO' if CFF */ |
| 114 | USHORT numTables; /* Number of tables. */ |
Behdad Esfahbod | 7d4ada6 | 2014-06-27 17:30:59 -0400 | [diff] [blame] | 115 | USHORT searchRangeZ; /* (Maximum power of 2 <= numTables) x 16 */ |
| 116 | USHORT entrySelectorZ; /* Log2(maximum power of 2 <= numTables). */ |
| 117 | USHORT rangeShiftZ; /* NumTables x 16-searchRange. */ |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 118 | TableRecord tables[VAR]; /* TableRecord entries. numTables items */ |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 119 | public: |
Behdad Esfahbod | 22c5376 | 2010-12-14 23:51:29 -0500 | [diff] [blame] | 120 | DEFINE_SIZE_ARRAY (12, tables); |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 121 | } OpenTypeFontFace; |
Behdad Esfahbod | 569da92 | 2010-05-10 16:38:32 -0400 | [diff] [blame] | 122 | |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * TrueType Collections |
| 126 | */ |
| 127 | |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 128 | struct TTCHeaderVersion1 |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 129 | { |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 130 | friend struct TTCHeader; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 131 | |
Behdad Esfahbod | 20b035d | 2009-08-10 19:00:36 -0400 | [diff] [blame] | 132 | inline unsigned int get_face_count (void) const { return table.len; } |
Behdad Esfahbod | df3f505 | 2010-04-22 14:11:33 -0400 | [diff] [blame] | 133 | inline const OpenTypeFontFace& get_face (unsigned int i) const { return this+table[i]; } |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 134 | |
Behdad Esfahbod | de2118e | 2015-02-17 17:27:44 +0300 | [diff] [blame] | 135 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 136 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 137 | TRACE_SANITIZE (this); |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 138 | return_trace (table.sanitize (c, this)); |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 139 | } |
| 140 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 141 | protected: |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 142 | Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ |
Behdad Esfahbod | 9a13ed4 | 2016-02-22 11:44:45 +0900 | [diff] [blame] | 143 | FixedVersion<>version; /* Version of the TTC Header (1.0), |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 144 | * 0x00010000u */ |
Behdad Esfahbod | 3084767 | 2014-06-27 15:24:35 -0400 | [diff] [blame] | 145 | ArrayOf<OffsetTo<OffsetTable, ULONG>, ULONG> |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 146 | table; /* Array of offsets to the OffsetTable for each font |
| 147 | * from the beginning of the file */ |
Behdad Esfahbod | b365123 | 2010-05-10 16:57:29 -0400 | [diff] [blame] | 148 | public: |
Behdad Esfahbod | 0eb9fc6 | 2010-05-10 19:01:17 -0400 | [diff] [blame] | 149 | DEFINE_SIZE_ARRAY (12, table); |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 150 | }; |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 151 | |
| 152 | struct TTCHeader |
| 153 | { |
| 154 | friend struct OpenTypeFontFile; |
| 155 | |
| 156 | private: |
| 157 | |
| 158 | inline unsigned int get_face_count (void) const |
| 159 | { |
Behdad Esfahbod | 4f28fbd | 2011-05-31 12:33:11 -0400 | [diff] [blame] | 160 | switch (u.header.version.major) { |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 161 | case 2: /* version 2 is compatible with version 1 */ |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 162 | case 1: return u.version1.get_face_count (); |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 163 | default:return 0; |
| 164 | } |
| 165 | } |
| 166 | inline const OpenTypeFontFace& get_face (unsigned int i) const |
| 167 | { |
Behdad Esfahbod | 4f28fbd | 2011-05-31 12:33:11 -0400 | [diff] [blame] | 168 | switch (u.header.version.major) { |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 169 | case 2: /* version 2 is compatible with version 1 */ |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 170 | case 1: return u.version1.get_face (i); |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 171 | default:return Null(OpenTypeFontFace); |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
Behdad Esfahbod | de2118e | 2015-02-17 17:27:44 +0300 | [diff] [blame] | 175 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 176 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 177 | TRACE_SANITIZE (this); |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 178 | if (unlikely (!u.header.version.sanitize (c))) return_trace (false); |
Behdad Esfahbod | 4f28fbd | 2011-05-31 12:33:11 -0400 | [diff] [blame] | 179 | switch (u.header.version.major) { |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 180 | case 2: /* version 2 is compatible with version 1 */ |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 181 | case 1: return_trace (u.version1.sanitize (c)); |
| 182 | default:return_trace (true); |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 183 | } |
| 184 | } |
| 185 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 186 | protected: |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 187 | union { |
| 188 | struct { |
| 189 | Tag ttcTag; /* TrueType Collection ID string: 'ttcf' */ |
Behdad Esfahbod | 9a13ed4 | 2016-02-22 11:44:45 +0900 | [diff] [blame] | 190 | FixedVersion<>version; /* Version of the TTC Header (1.0 or 2.0), |
Behdad Esfahbod | 7627100 | 2014-07-11 14:54:42 -0400 | [diff] [blame] | 191 | * 0x00010000u or 0x00020000u */ |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 192 | } header; |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 193 | TTCHeaderVersion1 version1; |
Behdad Esfahbod | ae4190c | 2010-04-23 12:33:02 -0400 | [diff] [blame] | 194 | } u; |
| 195 | }; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 196 | |
| 197 | |
| 198 | /* |
| 199 | * OpenType Font File |
| 200 | */ |
| 201 | |
| 202 | struct OpenTypeFontFile |
| 203 | { |
Behdad Esfahbod | 153beeb | 2014-12-12 19:46:09 -0800 | [diff] [blame] | 204 | static const hb_tag_t tableTag = HB_TAG ('_','_','_','_'); /* Sanitizer needs this. */ |
| 205 | |
Behdad Esfahbod | 710500a | 2010-05-03 23:11:16 -0400 | [diff] [blame] | 206 | static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O'); /* OpenType with Postscript outlines */ |
| 207 | static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ); /* OpenType with TrueType outlines */ |
| 208 | static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f'); /* TrueType Collection */ |
Behdad Esfahbod | ce5694c | 2010-05-04 14:10:18 -0400 | [diff] [blame] | 209 | static const hb_tag_t TrueTag = HB_TAG ('t','r','u','e'); /* Obsolete Apple TrueType */ |
| 210 | static const hb_tag_t Typ1Tag = HB_TAG ('t','y','p','1'); /* Obsolete Apple Type1 font in SFNT container */ |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 211 | |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 212 | inline hb_tag_t get_tag (void) const { return u.tag; } |
| 213 | |
Behdad Esfahbod | 20b035d | 2009-08-10 19:00:36 -0400 | [diff] [blame] | 214 | inline unsigned int get_face_count (void) const |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 215 | { |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 216 | switch (u.tag) { |
| 217 | case CFFTag: /* All the non-collection tags */ |
Jeff Muizelaar | 4ce578e | 2010-05-03 15:03:53 -0400 | [diff] [blame] | 218 | case TrueTag: |
| 219 | case Typ1Tag: |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 220 | case TrueTypeTag: return 1; |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 221 | case TTCTag: return u.ttcHeader.get_face_count (); |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 222 | default: return 0; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 223 | } |
| 224 | } |
Behdad Esfahbod | 20b035d | 2009-08-10 19:00:36 -0400 | [diff] [blame] | 225 | inline const OpenTypeFontFace& get_face (unsigned int i) const |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 226 | { |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 227 | switch (u.tag) { |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 228 | /* Note: for non-collection SFNT data we ignore index. This is because |
| 229 | * Apple dfont container is a container of SFNT's. So each SFNT is a |
| 230 | * non-TTC, but the index is more than zero. */ |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 231 | case CFFTag: /* All the non-collection tags */ |
Jeff Muizelaar | 4ce578e | 2010-05-03 15:03:53 -0400 | [diff] [blame] | 232 | case TrueTag: |
| 233 | case Typ1Tag: |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 234 | case TrueTypeTag: return u.fontFace; |
| 235 | case TTCTag: return u.ttcHeader.get_face (i); |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 236 | default: return Null(OpenTypeFontFace); |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
Behdad Esfahbod | de2118e | 2015-02-17 17:27:44 +0300 | [diff] [blame] | 240 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 241 | { |
Behdad Esfahbod | be218c6 | 2012-11-23 15:32:14 -0500 | [diff] [blame] | 242 | TRACE_SANITIZE (this); |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 243 | if (unlikely (!u.tag.sanitize (c))) return_trace (false); |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 244 | switch (u.tag) { |
| 245 | case CFFTag: /* All the non-collection tags */ |
Jeff Muizelaar | 4ce578e | 2010-05-03 15:03:53 -0400 | [diff] [blame] | 246 | case TrueTag: |
| 247 | case Typ1Tag: |
Behdad Esfahbod | b471590 | 2015-09-29 14:57:02 +0100 | [diff] [blame] | 248 | case TrueTypeTag: return_trace (u.fontFace.sanitize (c)); |
| 249 | case TTCTag: return_trace (u.ttcHeader.sanitize (c)); |
| 250 | default: return_trace (true); |
Behdad Esfahbod | b508e5c | 2009-08-04 15:07:24 -0400 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
Behdad Esfahbod | ec8d249 | 2012-07-24 15:40:37 -0400 | [diff] [blame] | 254 | protected: |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 255 | union { |
| 256 | Tag tag; /* 4-byte identifier. */ |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 257 | OpenTypeFontFace fontFace; |
| 258 | TTCHeader ttcHeader; |
Behdad Esfahbod | 1aa4666 | 2010-04-23 13:32:03 -0400 | [diff] [blame] | 259 | } u; |
Behdad Esfahbod | dacebca | 2010-05-10 19:45:41 -0400 | [diff] [blame] | 260 | public: |
| 261 | DEFINE_SIZE_UNION (4, tag); |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 262 | }; |
Behdad Esfahbod | 2098a02 | 2009-08-02 19:57:00 -0400 | [diff] [blame] | 263 | |
| 264 | |
Behdad Esfahbod | 7d52e66 | 2012-11-16 18:49:54 -0800 | [diff] [blame] | 265 | } /* namespace OT */ |
Behdad Esfahbod | 7c8e844 | 2012-08-28 17:57:49 -0400 | [diff] [blame] | 266 | |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 267 | |
Behdad Esfahbod | 5f5b24f | 2009-08-02 20:03:12 -0400 | [diff] [blame] | 268 | #endif /* HB_OPEN_FILE_PRIVATE_HH */ |