Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016 Elie Roux <elie.roux@telecom-bretagne.eu> |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 3 | * Copyright © 2018 Google, Inc. |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [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 | * |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 25 | * Google Author(s): Behdad Esfahbod |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 26 | */ |
| 27 | |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 28 | #ifndef HB_OT_LAYOUT_BASE_TABLE_HH |
| 29 | #define HB_OT_LAYOUT_BASE_TABLE_HH |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 30 | |
| 31 | #include "hb-open-type-private.hh" |
| 32 | #include "hb-ot-layout-common-private.hh" |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 33 | |
| 34 | namespace OT { |
| 35 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 36 | #define NOT_INDEXED ((unsigned int) -1) |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 37 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 38 | /* |
| 39 | * BASE -- The BASE Table |
| 40 | */ |
| 41 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 42 | struct BaseCoordFormat1 |
| 43 | { |
| 44 | inline int get_coord (void) const { return coordinate; } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 45 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 46 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 47 | { |
| 48 | TRACE_SANITIZE (this); |
| 49 | return_trace (c->check_struct (this)); |
| 50 | } |
| 51 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 52 | protected: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 53 | HBUINT16 format; /* Format identifier--format = 1 */ |
| 54 | HBINT16 coordinate; /* X or Y value, in design units */ |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 55 | public: |
| 56 | DEFINE_SIZE_STATIC (4); |
| 57 | }; |
| 58 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 59 | struct BaseCoordFormat2 |
| 60 | { |
| 61 | inline int get_coord (void) const |
| 62 | { |
| 63 | /* TODO */ |
| 64 | return coordinate; |
| 65 | } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 66 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 67 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 68 | { |
| 69 | TRACE_SANITIZE (this); |
| 70 | return_trace (c->check_struct (this)); |
| 71 | } |
| 72 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 73 | protected: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 74 | HBUINT16 format; /* Format identifier--format = 2 */ |
| 75 | HBINT16 coordinate; /* X or Y value, in design units */ |
| 76 | GlyphID referenceGlyph; /* Glyph ID of control glyph */ |
| 77 | HBUINT16 coordPoint; /* Index of contour point on the |
| 78 | * reference glyph */ |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 79 | public: |
| 80 | DEFINE_SIZE_STATIC (8); |
| 81 | }; |
| 82 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 83 | struct BaseCoordFormat3 |
| 84 | { |
| 85 | inline int get_coord (void) const |
| 86 | { |
| 87 | /* TODO */ |
| 88 | return coordinate; |
| 89 | } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 90 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 91 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 92 | { |
| 93 | TRACE_SANITIZE (this); |
| 94 | return_trace (c->check_struct (this) && deviceTable.sanitize (c, this)); |
| 95 | } |
| 96 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 97 | protected: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 98 | HBUINT16 format; /* Format identifier--format = 3 */ |
| 99 | HBINT16 coordinate; /* X or Y value, in design units */ |
| 100 | OffsetTo<Device> deviceTable; /* Offset to Device table for X or |
| 101 | * Y value, from beginning of |
| 102 | * BaseCoord table (may be NULL). */ |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 103 | public: |
| 104 | DEFINE_SIZE_STATIC (6); |
| 105 | }; |
| 106 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 107 | struct BaseCoord |
| 108 | { |
| 109 | inline int get_coord (void) const |
| 110 | { |
| 111 | switch (u.format) { |
| 112 | case 1: return u.format1.get_coord (); |
| 113 | case 2: return u.format2.get_coord (); |
| 114 | case 3: return u.format3.get_coord (); |
| 115 | default:return 0; |
| 116 | } |
| 117 | } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 118 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 119 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 120 | { |
| 121 | TRACE_SANITIZE (this); |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 122 | if (!u.format.sanitize (c)) return_trace (false); |
| 123 | switch (u.format) { |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 124 | case 1: return_trace (u.format1.sanitize (c)); |
| 125 | case 2: return_trace (u.format2.sanitize (c)); |
| 126 | case 3: return_trace (u.format3.sanitize (c)); |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 127 | default:return_trace (false); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 131 | protected: |
| 132 | union { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 133 | HBUINT16 format; |
| 134 | BaseCoordFormat1 format1; |
| 135 | BaseCoordFormat2 format2; |
| 136 | BaseCoordFormat3 format3; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 137 | } u; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 138 | public: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 139 | DEFINE_SIZE_UNION (2, format); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 140 | }; |
| 141 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 142 | struct FeatMinMaxRecord |
| 143 | { |
| 144 | inline int get_min_value (void) const |
| 145 | { return (this+minCoord).get_coord(); } |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 146 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 147 | inline int get_max_value (void) const |
| 148 | { return (this+maxCoord).get_coord(); } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 149 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 150 | inline const Tag &get_tag () const |
| 151 | { return tag; } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 152 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 153 | inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 154 | { |
| 155 | TRACE_SANITIZE (this); |
| 156 | return_trace (c->check_struct (this) && |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 157 | minCoord.sanitize (c, base) && |
| 158 | maxCoord.sanitize (c, base)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 161 | protected: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 162 | Tag tag; /* 4-byte feature identification tag--must |
| 163 | * match feature tag in FeatureList */ |
| 164 | OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines |
| 165 | * the minimum extent value, from beginning |
| 166 | * of MinMax table (may be NULL) */ |
| 167 | OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines |
| 168 | * the maximum extent value, from beginning |
| 169 | * of MinMax table (may be NULL) */ |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 170 | public: |
| 171 | DEFINE_SIZE_STATIC (8); |
| 172 | |
| 173 | }; |
| 174 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 175 | struct MinMax |
| 176 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 177 | inline unsigned int get_feature_tag_index (Tag featureTableTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 178 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 179 | /* TODO bsearch */ |
| 180 | unsigned int count = featMinMaxRecords.len; |
| 181 | for (unsigned int i = 0; i < count; i++) |
| 182 | { |
| 183 | Tag tag = featMinMaxRecords[i].get_tag(); |
| 184 | int cmp = tag.cmp(featureTableTag); |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 185 | if (cmp == 0) return i; |
| 186 | if (cmp > 0) return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 187 | } |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 188 | return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 191 | inline int get_min_value (unsigned int featureTableTagIndex) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 192 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 193 | if (featureTableTagIndex == NOT_INDEXED) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 194 | return (this+minCoord).get_coord(); |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 195 | return featMinMaxRecords[featureTableTagIndex].get_min_value(); |
| 196 | } |
| 197 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 198 | inline int get_max_value (unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 199 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 200 | if (featureTableTagIndex == NOT_INDEXED) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 201 | return (this+maxCoord).get_coord(); |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 202 | return featMinMaxRecords[featureTableTagIndex].get_max_value(); |
| 203 | } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 204 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 205 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 206 | { |
| 207 | TRACE_SANITIZE (this); |
| 208 | return_trace (c->check_struct (this) && |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 209 | minCoord.sanitize (c, this) && |
| 210 | maxCoord.sanitize (c, this) && |
| 211 | featMinMaxRecords.sanitize (c, this)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 212 | } |
| 213 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 214 | protected: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 215 | OffsetTo<BaseCoord> minCoord; /* Offset to BaseCoord table that defines |
| 216 | * minimum extent value, from the beginning |
| 217 | * of MinMax table (may be NULL) */ |
| 218 | OffsetTo<BaseCoord> maxCoord; /* Offset to BaseCoord table that defines |
| 219 | * maximum extent value, from the beginning |
| 220 | * of MinMax table (may be NULL) */ |
| 221 | ArrayOf<FeatMinMaxRecord> |
| 222 | featMinMaxRecords; /* Array of FeatMinMaxRecords, in alphabetical |
| 223 | * order by featureTableTag */ |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 224 | public: |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 225 | DEFINE_SIZE_ARRAY (6, featMinMaxRecords); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 226 | }; |
| 227 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 228 | /* TODO... */ |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 229 | struct BaseLangSysRecord |
| 230 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 231 | inline const Tag& get_tag(void) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 232 | { return baseLangSysTag; } |
| 233 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 234 | inline unsigned int get_feature_tag_index (Tag featureTableTag) const |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 235 | { return (this+minMax).get_feature_tag_index(featureTableTag); } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 236 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 237 | inline int get_min_value (unsigned int featureTableTagIndex) const |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 238 | { return (this+minMax).get_min_value(featureTableTagIndex); } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 239 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 240 | inline int get_max_value (unsigned int featureTableTagIndex) const |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 241 | { return (this+minMax).get_max_value(featureTableTagIndex); } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 242 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 243 | inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 244 | { |
| 245 | TRACE_SANITIZE (this); |
| 246 | return_trace (c->check_struct (this) && |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 247 | minMax.sanitize (c, base)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 248 | } |
| 249 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 250 | protected: |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 251 | Tag baseLangSysTag; |
| 252 | OffsetTo<MinMax> minMax; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 253 | public: |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 254 | DEFINE_SIZE_STATIC (6); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 255 | |
| 256 | }; |
| 257 | |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 258 | struct BaseValues |
| 259 | { |
| 260 | inline unsigned int get_default_base_tag_index (void) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 261 | { return defaultIndex; } |
| 262 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 263 | inline int get_base_coord (unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 264 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 265 | return (this+baseCoords[baselineTagIndex]).get_coord(); |
| 266 | } |
| 267 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 268 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 269 | { |
| 270 | TRACE_SANITIZE (this); |
| 271 | return_trace (c->check_struct (this) && |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 272 | defaultIndex <= baseCoordCount && |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 273 | baseCoords.sanitize (c, this)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 274 | } |
| 275 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 276 | protected: |
Behdad Esfahbod | 551fa2d | 2018-02-25 16:32:17 -0800 | [diff] [blame] | 277 | Index defaultIndex; |
| 278 | HBUINT16 baseCoordCount; |
| 279 | OffsetArrayOf<BaseCoord> baseCoords; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 280 | public: |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 281 | DEFINE_SIZE_ARRAY (6, baseCoords); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 282 | |
| 283 | }; |
| 284 | |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 285 | struct BaseScript { |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 286 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 287 | inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 288 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 289 | Tag tag; |
| 290 | int cmp; |
| 291 | for (unsigned int i = 0; i < baseLangSysCount; i++) { |
| 292 | tag = baseLangSysRecords[i].get_tag(); |
| 293 | // taking advantage of alphabetical order |
| 294 | cmp = tag.cmp(baseLangSysTag); |
| 295 | if (cmp == 0) return i; |
| 296 | if (cmp > 0) return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 297 | } |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 298 | return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 299 | } |
| 300 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 301 | inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 302 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 303 | if (baseLangSysIndex == NOT_INDEXED) { |
| 304 | if (unlikely(defaultMinMax)) return NOT_INDEXED; |
| 305 | return (this+defaultMinMax).get_feature_tag_index(featureTableTag); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 306 | } |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 307 | if (unlikely(baseLangSysIndex >= baseLangSysCount)) return NOT_INDEXED; |
| 308 | return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index(featureTableTag); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 309 | } |
| 310 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 311 | inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 312 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 313 | if (baseLangSysIndex == NOT_INDEXED) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 314 | return (this+defaultMinMax).get_min_value(featureTableTagIndex); |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 315 | return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 316 | } |
| 317 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 318 | inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 319 | { |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 320 | if (baseLangSysIndex == NOT_INDEXED) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 321 | return (this+defaultMinMax).get_min_value(featureTableTagIndex); |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 322 | return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 323 | } |
| 324 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 325 | inline unsigned int get_default_base_tag_index (void) const |
| 326 | { return (this+baseValues).get_default_base_tag_index(); } |
| 327 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 328 | inline int get_base_coord (unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 329 | { return (this+baseValues).get_base_coord(baselineTagIndex); } |
| 330 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 331 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 332 | { |
| 333 | TRACE_SANITIZE (this); |
| 334 | return_trace (c->check_struct (this) && |
| 335 | baseValues.sanitize (c, this) && |
| 336 | defaultMinMax.sanitize (c, this) && |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 337 | baseLangSysRecords.sanitize (c, this)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 338 | } |
| 339 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 340 | protected: |
Elie Roux | bd15567 | 2017-02-25 17:08:01 +0100 | [diff] [blame] | 341 | OffsetTo<BaseValues> baseValues; |
| 342 | OffsetTo<MinMax> defaultMinMax; |
Behdad Esfahbod | 05699fd | 2018-02-24 12:01:54 -0800 | [diff] [blame] | 343 | HBUINT16 baseLangSysCount; |
Elie Roux | bd15567 | 2017-02-25 17:08:01 +0100 | [diff] [blame] | 344 | ArrayOf<BaseLangSysRecord> baseLangSysRecords; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 345 | |
| 346 | public: |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 347 | DEFINE_SIZE_ARRAY (8, baseLangSysRecords); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 348 | }; |
| 349 | |
| 350 | |
| 351 | struct BaseScriptRecord { |
| 352 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 353 | inline const Tag& get_tag (void) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 354 | { return baseScriptTag; } |
| 355 | |
| 356 | inline unsigned int get_default_base_tag_index(void) const |
| 357 | { return (this+baseScript).get_default_base_tag_index(); } |
| 358 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 359 | inline int get_base_coord(unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 360 | { return (this+baseScript).get_base_coord(baselineTagIndex); } |
| 361 | |
| 362 | inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const |
| 363 | { return (this+baseScript).get_lang_tag_index(baseLangSysTag); } |
| 364 | |
| 365 | inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const |
| 366 | { return (this+baseScript).get_feature_tag_index(baseLangSysIndex, featureTableTag); } |
| 367 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 368 | inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 369 | { return (this+baseScript).get_max_value(baseLangSysIndex, featureTableTagIndex); } |
| 370 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 371 | inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 372 | { return (this+baseScript).get_min_value(baseLangSysIndex, featureTableTagIndex); } |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 373 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 374 | inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 375 | { |
| 376 | TRACE_SANITIZE (this); |
| 377 | return_trace (c->check_struct (this) && |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 378 | baseScript != Null(OffsetTo<BaseScript>) && |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 379 | baseScript.sanitize (c, base)); |
| 380 | } |
| 381 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 382 | protected: |
Elie Roux | bd15567 | 2017-02-25 17:08:01 +0100 | [diff] [blame] | 383 | Tag baseScriptTag; |
| 384 | OffsetTo<BaseScript> baseScript; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 385 | |
| 386 | public: |
Elie Roux | f131f00 | 2017-02-19 10:12:22 +0100 | [diff] [blame] | 387 | DEFINE_SIZE_STATIC (6); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 388 | }; |
| 389 | |
| 390 | struct BaseScriptList { |
| 391 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 392 | inline unsigned int get_base_script_index (Tag baseScriptTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 393 | { |
| 394 | for (unsigned int i = 0; i < baseScriptCount; i++) |
| 395 | if (baseScriptRecords[i].get_tag() == baseScriptTag) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 396 | return i; |
| 397 | return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 398 | } |
| 399 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 400 | inline unsigned int get_default_base_tag_index (unsigned int baseScriptIndex) const |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 401 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 402 | if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; |
| 403 | return baseScriptRecords[baseScriptIndex].get_default_base_tag_index(); |
| 404 | } |
| 405 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 406 | inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 407 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 408 | return baseScriptRecords[baseScriptIndex].get_base_coord(baselineTagIndex); |
| 409 | } |
| 410 | |
| 411 | inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const |
| 412 | { |
| 413 | if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; |
| 414 | return baseScriptRecords[baseScriptIndex].get_lang_tag_index(baseLangSysTag); |
| 415 | } |
| 416 | |
| 417 | inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const |
| 418 | { |
| 419 | if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; |
| 420 | return baseScriptRecords[baseScriptIndex].get_feature_tag_index(baseLangSysIndex, featureTableTag); |
| 421 | } |
| 422 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 423 | inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 424 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 425 | return baseScriptRecords[baseScriptIndex].get_max_value(baseLangSysIndex, featureTableTagIndex); |
| 426 | } |
| 427 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 428 | inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 429 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 430 | return baseScriptRecords[baseScriptIndex].get_min_value(baseLangSysIndex, featureTableTagIndex); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 431 | } |
| 432 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 433 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 434 | { |
| 435 | TRACE_SANITIZE (this); |
| 436 | return_trace (c->check_struct (this) && |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 437 | baseScriptRecords.sanitize (c, this)); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 438 | } |
| 439 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 440 | protected: |
Behdad Esfahbod | 05699fd | 2018-02-24 12:01:54 -0800 | [diff] [blame] | 441 | HBUINT16 baseScriptCount; |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 442 | ArrayOf<BaseScriptRecord> baseScriptRecords; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 443 | |
| 444 | public: |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 445 | DEFINE_SIZE_ARRAY (4, baseScriptRecords); |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 446 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 447 | }; |
| 448 | |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 449 | struct BaseTagList |
| 450 | { |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 451 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 452 | inline unsigned int get_tag_index(Tag baselineTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 453 | { |
| 454 | for (unsigned int i = 0; i < baseTagCount; i++) |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 455 | if (baselineTags[i] == baselineTag) |
| 456 | return i; |
| 457 | return NOT_INDEXED; |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | inline bool sanitize (hb_sanitize_context_t *c) const |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 461 | { |
| 462 | TRACE_SANITIZE (this); |
| 463 | return_trace (c->check_struct (this)); |
| 464 | } |
| 465 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 466 | protected: |
Behdad Esfahbod | 05699fd | 2018-02-24 12:01:54 -0800 | [diff] [blame] | 467 | HBUINT16 baseTagCount; |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 468 | SortedArrayOf<Tag> baselineTags; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 469 | |
| 470 | public: |
Elie Roux | 499b4be | 2017-02-25 16:48:22 +0100 | [diff] [blame] | 471 | DEFINE_SIZE_ARRAY (4, baselineTags); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 472 | }; |
| 473 | |
Elie Roux | a0bdd54 | 2017-02-25 16:34:58 +0100 | [diff] [blame] | 474 | struct Axis |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 475 | { |
| 476 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 477 | inline unsigned int get_base_tag_index(Tag baselineTag) const |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 478 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 479 | if (unlikely(baseTagList == Null(OffsetTo<BaseTagList>))) return NOT_INDEXED; |
| 480 | return (this+baseTagList).get_tag_index(baselineTag); |
| 481 | } |
| 482 | |
| 483 | inline unsigned int get_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 484 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 485 | if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; |
| 486 | return (this+baseScriptList).get_default_base_tag_index(baseScriptIndex); |
| 487 | } |
| 488 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 489 | inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 490 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 491 | return (this+baseScriptList).get_base_coord(baseScriptIndex, baselineTagIndex); |
| 492 | } |
| 493 | |
| 494 | inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const |
| 495 | { |
| 496 | if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; |
| 497 | return (this+baseScriptList).get_lang_tag_index(baseScriptIndex, baseLangSysTag); |
| 498 | } |
| 499 | |
| 500 | inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const |
| 501 | { |
| 502 | if (unlikely(baseScriptList == Null(OffsetTo<BaseScriptList>))) return NOT_INDEXED; |
| 503 | return (this+baseScriptList).get_feature_tag_index(baseScriptIndex, baseLangSysIndex, featureTableTag); |
| 504 | } |
| 505 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 506 | inline int get_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 507 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 508 | return (this+baseScriptList).get_max_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
| 509 | } |
| 510 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 511 | inline int get_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 512 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 513 | return (this+baseScriptList).get_min_value(baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
Elie Roux | d34e35b | 2017-02-25 20:41:05 +0100 | [diff] [blame] | 514 | } |
| 515 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 516 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 517 | { |
| 518 | TRACE_SANITIZE (this); |
| 519 | return_trace (c->check_struct (this) && |
| 520 | baseTagList.sanitize (c, this) && |
| 521 | baseScriptList.sanitize (c, this)); |
| 522 | } |
| 523 | |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 524 | protected: |
Elie Roux | bd15567 | 2017-02-25 17:08:01 +0100 | [diff] [blame] | 525 | OffsetTo<BaseTagList> baseTagList; |
| 526 | OffsetTo<BaseScriptList> baseScriptList; |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 527 | |
| 528 | public: |
| 529 | DEFINE_SIZE_STATIC (4); |
| 530 | }; |
| 531 | |
Behdad Esfahbod | d7633d0 | 2018-02-27 12:50:57 -0800 | [diff] [blame] | 532 | struct BASE |
Elie Roux | f131f00 | 2017-02-19 10:12:22 +0100 | [diff] [blame] | 533 | { |
Behdad Esfahbod | d7633d0 | 2018-02-27 12:50:57 -0800 | [diff] [blame] | 534 | static const hb_tag_t tableTag = HB_OT_TAG_BASE; |
Elie Roux | f131f00 | 2017-02-19 10:12:22 +0100 | [diff] [blame] | 535 | |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 536 | inline bool has_vert_axis(void) |
| 537 | { return vertAxis != Null(OffsetTo<Axis>); } |
| 538 | |
| 539 | inline bool has_horiz_axis(void) |
| 540 | { return horizAxis != Null(OffsetTo<Axis>); } |
| 541 | |
| 542 | // horizontal axis base coords: |
| 543 | |
| 544 | inline unsigned int get_horiz_base_tag_index(Tag baselineTag) const |
| 545 | { |
| 546 | if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 547 | return (this+horizAxis).get_base_tag_index(baselineTag); |
| 548 | } |
| 549 | |
| 550 | inline unsigned int get_horiz_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 551 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 552 | if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 553 | return (this+horizAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); |
| 554 | } |
| 555 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 556 | inline int get_horiz_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 557 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 558 | return (this+horizAxis).get_base_coord(baseScriptIndex, baselineTagIndex); |
| 559 | } |
| 560 | |
| 561 | // vertical axis base coords: |
| 562 | |
| 563 | inline unsigned int get_vert_base_tag_index(Tag baselineTag) const |
| 564 | { |
| 565 | if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 566 | return (this+vertAxis).get_base_tag_index(baselineTag); |
| 567 | } |
| 568 | |
| 569 | inline unsigned int get_vert_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 570 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 571 | if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 572 | return (this+vertAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); |
| 573 | } |
| 574 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 575 | inline int get_vert_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 576 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 577 | return (this+vertAxis).get_base_coord(baseScriptIndex, baselineTagIndex); |
| 578 | } |
| 579 | |
| 580 | // horizontal axis min/max coords: |
| 581 | |
| 582 | inline unsigned int get_horiz_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const |
| 583 | { |
| 584 | if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 585 | return (this+horizAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); |
| 586 | } |
| 587 | |
| 588 | inline unsigned int get_horiz_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const |
| 589 | { |
| 590 | if (unlikely(horizAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 591 | return (this+horizAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); |
| 592 | } |
| 593 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 594 | inline int get_horiz_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 595 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 596 | return (this+horizAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
| 597 | } |
| 598 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 599 | inline int get_horiz_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 600 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 601 | return (this+horizAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
| 602 | } |
| 603 | |
| 604 | // vertical axis min/max coords: |
| 605 | |
| 606 | inline unsigned int get_vert_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const |
| 607 | { |
| 608 | if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 609 | return (this+vertAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); |
| 610 | } |
| 611 | |
| 612 | inline unsigned int get_vert_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const |
| 613 | { |
| 614 | if (unlikely(vertAxis == Null(OffsetTo<Axis>))) return NOT_INDEXED; |
| 615 | return (this+vertAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); |
| 616 | } |
| 617 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 618 | inline int get_vert_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 619 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 620 | return (this+vertAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
| 621 | } |
| 622 | |
Behdad Esfahbod | 7a70c20 | 2018-02-27 12:45:26 -0800 | [diff] [blame] | 623 | inline int get_vert_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 624 | { |
Elie Roux | 3963315 | 2017-02-26 15:07:53 +0100 | [diff] [blame] | 625 | return (this+vertAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); |
| 626 | } |
| 627 | |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 628 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 629 | { |
| 630 | TRACE_SANITIZE (this); |
| 631 | return_trace (c->check_struct (this) && |
Behdad Esfahbod | d7633d0 | 2018-02-27 12:50:57 -0800 | [diff] [blame] | 632 | likely (version.major == 1) && |
| 633 | horizAxis.sanitize (c, this) && |
| 634 | vertAxis.sanitize (c, this) && |
| 635 | (version.to_int () < 0x00010001u || varStore.sanitize (c, this))); |
Elie Roux | 1d30c6d | 2017-02-25 16:19:35 +0100 | [diff] [blame] | 636 | } |
| 637 | |
Elie Roux | f131f00 | 2017-02-19 10:12:22 +0100 | [diff] [blame] | 638 | protected: |
Elie Roux | bd15567 | 2017-02-25 17:08:01 +0100 | [diff] [blame] | 639 | FixedVersion<> version; |
| 640 | OffsetTo<Axis> horizAxis; |
| 641 | OffsetTo<Axis> vertAxis; |
Behdad Esfahbod | d7633d0 | 2018-02-27 12:50:57 -0800 | [diff] [blame] | 642 | LOffsetTo<VariationStore> |
| 643 | varStore; /* Offset to the table of Item Variation |
| 644 | * Store--from beginning of BASE |
| 645 | * header (may be NULL). Introduced |
| 646 | * in version 0x00010001. */ |
Elie Roux | f131f00 | 2017-02-19 10:12:22 +0100 | [diff] [blame] | 647 | public: |
Behdad Esfahbod | d7633d0 | 2018-02-27 12:50:57 -0800 | [diff] [blame] | 648 | DEFINE_SIZE_MIN (8); |
Elie Roux | f748e11 | 2017-02-18 19:54:33 +0100 | [diff] [blame] | 649 | }; |
| 650 | |
| 651 | |
| 652 | } /* namespace OT */ |
| 653 | |
| 654 | |
Ebrahim Byagowi | 0ad8c66 | 2018-02-26 12:45:08 +0330 | [diff] [blame] | 655 | #endif /* HB_OT_LAYOUT_BASE_TABLE_HH */ |