Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 1 | /* |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 2 | * Copyright © 2018 Ebrahim Byagowi |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 3 | * Copyright © 2018 Google, Inc. |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 4 | * |
| 5 | * This is part of HarfBuzz, a text shaping library. |
| 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 | * Google Author(s): Behdad Esfahbod |
| 26 | */ |
| 27 | |
| 28 | #ifndef HB_AAT_LAYOUT_KERX_TABLE_HH |
| 29 | #define HB_AAT_LAYOUT_KERX_TABLE_HH |
| 30 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 31 | #include "hb-open-type-private.hh" |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 32 | #include "hb-aat-layout-common-private.hh" |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 33 | #include "hb-aat-layout-ankr-table.hh" |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 34 | |
Ebrahim Byagowi | a02c3ee | 2018-04-12 13:38:19 +0430 | [diff] [blame] | 35 | /* |
| 36 | * kerx -- Extended Kerning |
| 37 | * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html |
| 38 | */ |
Ebrahim Byagowi | 158f281 | 2018-03-26 12:04:30 +0430 | [diff] [blame] | 39 | #define HB_AAT_TAG_kerx HB_TAG('k','e','r','x') |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 40 | |
| 41 | |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 42 | namespace AAT { |
| 43 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 44 | using namespace OT; |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 45 | |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 46 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 47 | struct KerxFormat0Records |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 48 | { |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 49 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 50 | { |
| 51 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 52 | return_trace (likely (c->check_struct (this))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | protected: |
| 56 | GlyphID left; |
| 57 | GlyphID right; |
| 58 | FWORD value; |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 59 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 60 | DEFINE_SIZE_STATIC (6); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | struct KerxSubTableFormat0 |
| 64 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 65 | // TODO(ebraminio) Enable when we got suitable BinSearchArrayOf |
| 66 | // inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right) const |
| 67 | // { |
| 68 | // hb_glyph_pair_t pair = {left, right}; |
| 69 | // int i = pairs.bsearch (pair); |
| 70 | // if (i == -1) |
| 71 | // return 0; |
| 72 | // return pairs[i].get_kerning (); |
| 73 | // } |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 74 | |
| 75 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 76 | { |
| 77 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 78 | return_trace (likely (c->check_struct (this) && |
| 79 | recordsZ.sanitize (c, nPairs))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | protected: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 83 | // TODO(ebraminio): A custom version of "BinSearchArrayOf<KerxPair> pairs;" is |
| 84 | // needed here to use HBUINT32 instead |
Ebrahim Byagowi | 211da5e | 2018-04-11 17:41:24 +0430 | [diff] [blame] | 85 | HBUINT32 nPairs; /* The number of kerning pairs in this subtable */ |
| 86 | HBUINT32 searchRange; /* The largest power of two less than or equal to the value of nPairs, |
| 87 | * multiplied by the size in bytes of an entry in the subtable. */ |
| 88 | HBUINT32 entrySelector; /* This is calculated as log2 of the largest power of two less |
| 89 | * than or equal to the value of nPairs. */ |
| 90 | HBUINT32 rangeShift; /* The value of nPairs minus the largest power of two less than or equal to nPairs. */ |
| 91 | UnsizedArrayOf<KerxFormat0Records> |
| 92 | recordsZ; /* VAR=nPairs */ |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 93 | public: |
Ebrahim Byagowi | 211da5e | 2018-04-11 17:41:24 +0430 | [diff] [blame] | 94 | DEFINE_SIZE_ARRAY (16, recordsZ); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | struct KerxSubTableFormat1 |
| 98 | { |
| 99 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 100 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 101 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 102 | return_trace (likely (c->check_struct (this) && |
| 103 | stateHeader.sanitize (c))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | protected: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 107 | StateTable<HBUINT16> stateHeader; |
| 108 | LOffsetTo<ArrayOf<HBUINT16> > valueTable; |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 109 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 110 | DEFINE_SIZE_STATIC (20); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 111 | }; |
| 112 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 113 | // TODO(ebraminio): Maybe this can be replaced with Lookup<HBUINT16>? |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 114 | struct KerxClassTable |
| 115 | { |
| 116 | inline unsigned int get_class (hb_codepoint_t g) const { return classes[g - firstGlyph]; } |
| 117 | |
| 118 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 119 | { |
| 120 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 121 | return_trace (likely (firstGlyph.sanitize (c) && |
| 122 | classes.sanitize (c))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | protected: |
| 126 | HBUINT16 firstGlyph; /* First glyph in class range. */ |
| 127 | ArrayOf<HBUINT16> classes; /* Glyph classes. */ |
| 128 | public: |
| 129 | DEFINE_SIZE_ARRAY (4, classes); |
| 130 | }; |
| 131 | |
| 132 | struct KerxSubTableFormat2 |
| 133 | { |
| 134 | inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const |
| 135 | { |
| 136 | unsigned int l = (this+leftClassTable).get_class (left); |
| 137 | unsigned int r = (this+leftClassTable).get_class (left); |
| 138 | unsigned int offset = l * rowWidth + r * sizeof (FWORD); |
| 139 | const FWORD *arr = &(this+array); |
| 140 | if (unlikely ((const void *) arr < (const void *) this || (const void *) arr >= (const void *) end)) |
| 141 | return 0; |
| 142 | const FWORD *v = &StructAtOffset<FWORD> (arr, offset); |
| 143 | if (unlikely ((const void *) v < (const void *) arr || (const void *) (v + 1) > (const void *) end)) |
| 144 | return 0; |
| 145 | return *v; |
| 146 | } |
| 147 | |
| 148 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 149 | { |
| 150 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 151 | return_trace (likely (c->check_struct (this) && |
| 152 | rowWidth.sanitize (c) && |
| 153 | leftClassTable.sanitize (c, this) && |
| 154 | rightClassTable.sanitize (c, this) && |
| 155 | array.sanitize (c, this))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | protected: |
| 159 | HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */ |
| 160 | LOffsetTo<KerxClassTable> |
| 161 | leftClassTable; /* Offset from beginning of this subtable to |
| 162 | * left-hand class table. */ |
| 163 | LOffsetTo<KerxClassTable> |
| 164 | rightClassTable;/* Offset from beginning of this subtable to |
| 165 | * right-hand class table. */ |
| 166 | LOffsetTo<FWORD> |
| 167 | array; /* Offset from beginning of this subtable to |
| 168 | * the start of the kerning array. */ |
| 169 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 170 | DEFINE_SIZE_STATIC (16); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 171 | }; |
| 172 | |
| 173 | struct KerxSubTableFormat4 |
| 174 | { |
| 175 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 176 | { |
| 177 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 178 | return_trace (likely (c->check_struct (this) && |
| 179 | rowWidth.sanitize (c) && |
| 180 | leftClassTable.sanitize (c, this) && |
| 181 | rightClassTable.sanitize (c, this) && |
| 182 | array.sanitize (c, this))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | protected: |
| 186 | HBUINT32 rowWidth; /* The width, in bytes, of a row in the table. */ |
| 187 | LOffsetTo<KerxClassTable> |
| 188 | leftClassTable; /* Offset from beginning of this subtable to |
| 189 | * left-hand class table. */ |
| 190 | LOffsetTo<KerxClassTable> |
| 191 | rightClassTable;/* Offset from beginning of this subtable to |
| 192 | * right-hand class table. */ |
| 193 | LOffsetTo<FWORD> |
| 194 | array; /* Offset from beginning of this subtable to |
| 195 | * the start of the kerning array. */ |
| 196 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 197 | DEFINE_SIZE_STATIC (16); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | struct KerxSubTableFormat6 |
| 201 | { |
| 202 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 203 | { |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 204 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 205 | return_trace (likely (c->check_struct (this) && |
| 206 | rowIndexTable.sanitize (c, this) && |
| 207 | columnIndexTable.sanitize (c, this) && |
| 208 | kerningArray.sanitize (c, this) && |
| 209 | kerningVector.sanitize (c, this))); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | protected: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 213 | HBUINT32 flags; |
| 214 | HBUINT16 rowCount; |
| 215 | HBUINT16 columnCount; |
Ebrahim Byagowi | 71b4598 | 2018-03-02 11:04:09 +0330 | [diff] [blame] | 216 | LOffsetTo<Lookup<HBUINT16> > rowIndexTable; |
| 217 | LOffsetTo<Lookup<HBUINT16> > columnIndexTable; |
| 218 | LOffsetTo<Lookup<HBUINT16> > kerningArray; |
| 219 | LOffsetTo<Lookup<HBUINT16> > kerningVector; |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 220 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 221 | DEFINE_SIZE_STATIC (24); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 222 | }; |
| 223 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 224 | enum coverage_flags_t |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 225 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 226 | COVERAGE_VERTICAL_FLAG = 0x80u, |
| 227 | COVERAGE_CROSSSTREAM_FLAG = 0x40u, |
| 228 | COVERAGE_VARIATION_FLAG = 0x20u, |
| 229 | COVERAGE_PROCESS_DIRECTION = 0x10u, |
| 230 | }; |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 231 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 232 | struct KerxTable |
| 233 | { |
Ebrahim Byagowi | ae14dd0 | 2018-02-26 00:31:09 +0330 | [diff] [blame] | 234 | inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const |
Ebrahim Byagowi | 1ab16f4 | 2018-02-24 12:49:42 +0330 | [diff] [blame] | 235 | { |
| 236 | TRACE_APPLY (this); |
| 237 | /* TODO */ |
| 238 | return_trace (false); |
| 239 | } |
| 240 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 241 | inline unsigned int get_size (void) const { return length; } |
| 242 | |
| 243 | inline bool sanitize (hb_sanitize_context_t *c) const |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 244 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 245 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 246 | if (unlikely (!c->check_struct (this))) |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 247 | return_trace (false); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 248 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 249 | switch (format) { |
| 250 | case 0: return u.format0.sanitize (c); |
| 251 | case 1: return u.format1.sanitize (c); |
| 252 | case 2: return u.format2.sanitize (c); |
| 253 | case 4: return u.format4.sanitize (c); |
| 254 | case 6: return u.format6.sanitize (c); |
| 255 | default:return_trace (false); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 256 | } |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 257 | } |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 258 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 259 | protected: |
| 260 | HBUINT32 length; |
| 261 | HBUINT8 coverage; |
| 262 | HBUINT16 unused; |
| 263 | HBUINT8 format; |
| 264 | HBUINT32 tupleIndex; |
| 265 | union { |
| 266 | KerxSubTableFormat0 format0; |
| 267 | KerxSubTableFormat1 format1; |
| 268 | KerxSubTableFormat2 format2; |
| 269 | KerxSubTableFormat4 format4; |
| 270 | KerxSubTableFormat6 format6; |
| 271 | } u; |
| 272 | public: |
| 273 | DEFINE_SIZE_MIN (12); |
| 274 | }; |
| 275 | |
| 276 | struct SubtableGlyphCoverageArray |
| 277 | { |
| 278 | inline bool sanitize (hb_sanitize_context_t *c) const |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 279 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 280 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | 2a4cdfa | 2018-04-20 21:12:58 +0430 | [diff] [blame] | 281 | return_trace (likely (c->check_struct (this))); |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | protected: |
| 285 | HBUINT32 length; |
| 286 | HBUINT32 coverage; |
| 287 | HBUINT32 tupleCount; |
| 288 | public: |
| 289 | DEFINE_SIZE_STATIC (12); |
| 290 | }; |
| 291 | |
| 292 | struct kerx |
| 293 | { |
Ebrahim Byagowi | 158f281 | 2018-03-26 12:04:30 +0430 | [diff] [blame] | 294 | static const hb_tag_t tableTag = HB_AAT_TAG_kerx; |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 295 | |
| 296 | inline bool apply (hb_aat_apply_context_t *c, const AAT::ankr *ankr) const |
| 297 | { |
| 298 | TRACE_APPLY (this); |
| 299 | const KerxTable &table = StructAfter<KerxTable> (*this); |
| 300 | return_trace (table.apply (c, ankr)); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 304 | { |
| 305 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 306 | if (unlikely (!(c->check_struct (this)))) |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 307 | return_trace (false); |
| 308 | |
Ebrahim Byagowi | a3e29fd | 2018-03-04 02:56:27 +0330 | [diff] [blame] | 309 | /* TODO: Something like `morx`s ChainSubtable should be done here instead */ |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 310 | const KerxTable *table = &StructAfter<KerxTable> (*this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 311 | if (unlikely (!(table->sanitize (c)))) |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 312 | return_trace (false); |
| 313 | |
| 314 | for (unsigned int i = 0; i < nTables - 1; ++i) |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 315 | { |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 316 | table = &StructAfter<KerxTable> (*table); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 317 | if (unlikely (!(table->sanitize (c)))) |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 318 | return_trace (false); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 319 | } |
| 320 | |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 321 | // If version is less than 3, we are done here; otherwise better to check footer also |
| 322 | if (version < 3) |
| 323 | return_trace (true); |
| 324 | |
| 325 | // TODO: Investigate why this just work on some fonts no matter of version |
| 326 | // const SubtableGlyphCoverageArray &footer = |
| 327 | // StructAfter<SubtableGlyphCoverageArray> (*table); |
| 328 | // return_trace (footer.sanitize (c)); |
| 329 | |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 330 | return_trace (true); |
| 331 | } |
| 332 | |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 333 | protected: |
| 334 | HBUINT16 version; |
| 335 | HBUINT16 padding; |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 336 | HBUINT32 nTables; |
Behdad Esfahbod | 63f57f4 | 2018-05-08 16:56:11 -0700 | [diff] [blame] | 337 | /*KerxTable tablesZ[VAR]; XXX ArrayOf??? */ |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 338 | /*SubtableGlyphCoverageArray coverage_array;*/ |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 339 | public: |
Ebrahim Byagowi | b73a5a1 | 2018-03-02 00:07:26 +0330 | [diff] [blame] | 340 | DEFINE_SIZE_STATIC (8); |
Ebrahim Byagowi | 79756c9 | 2018-02-19 03:17:44 +0330 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | } /* namespace AAT */ |
| 344 | |
| 345 | |
| 346 | #endif /* HB_AAT_LAYOUT_KERX_TABLE_HH */ |