Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2018 Ebrahim Byagowi |
| 3 | * |
| 4 | * This is part of HarfBuzz, a text shaping library. |
| 5 | * |
| 6 | * Permission is hereby granted, without written agreement and without |
| 7 | * license or royalty fees, to use, copy, modify, and distribute this |
| 8 | * software and its documentation for any purpose, provided that the |
| 9 | * above copyright notice and the following two paragraphs appear in |
| 10 | * all copies of this software. |
| 11 | * |
| 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
| 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 | * DAMAGE. |
| 17 | * |
| 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
| 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 23 | */ |
| 24 | |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 25 | #ifndef HB_AAT_LAYOUT_FEAT_TABLE_HH |
| 26 | #define HB_AAT_LAYOUT_FEAT_TABLE_HH |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 27 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 28 | #include "hb-aat-layout-common.hh" |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 29 | |
Ebrahim Byagowi | a02c3ee | 2018-04-12 13:38:19 +0430 | [diff] [blame] | 30 | /* |
| 31 | * feat -- Feature Name |
| 32 | * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html |
| 33 | */ |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 34 | #define HB_AAT_TAG_feat HB_TAG('f','e','a','t') |
| 35 | |
| 36 | |
| 37 | namespace AAT { |
| 38 | |
Ebrahim Byagowi | a02c3ee | 2018-04-12 13:38:19 +0430 | [diff] [blame] | 39 | |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 40 | struct SettingName |
| 41 | { |
| 42 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 43 | { |
| 44 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 45 | return_trace (likely (c->check_struct (this))); |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 46 | } |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 47 | |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 48 | protected: |
| 49 | HBUINT16 setting; /* The setting. */ |
| 50 | NameID nameIndex; /* The name table index for the setting's name. */ |
| 51 | public: |
| 52 | DEFINE_SIZE_STATIC (4); |
| 53 | }; |
| 54 | |
| 55 | struct FeatureName |
| 56 | { |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 57 | inline bool sanitize (hb_sanitize_context_t *c, const void *base) const |
| 58 | { |
| 59 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 60 | return_trace (likely (c->check_struct (this) && |
| 61 | (base+settingTable).sanitize (c, nSettings))); |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | enum { |
| 65 | Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */ |
| 66 | NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in |
| 67 | * the setting name array for this feature should |
| 68 | * be taken as the default for the feature |
| 69 | * (if one is required). If set, then bits 0-15 of this |
| 70 | * featureFlags field contain the index of the setting |
| 71 | * which is to be taken as the default. */ |
| 72 | IndexMask = 0x00FF /* If bits 30 and 31 are set, then these sixteen bits |
| 73 | * indicate the index of the setting in the setting name |
| 74 | * array for this feature which should be taken |
| 75 | * as the default. */ |
| 76 | }; |
| 77 | |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 78 | protected: |
| 79 | HBUINT16 feature; /* Feature type. */ |
| 80 | HBUINT16 nSettings; /* The number of records in the setting name array. */ |
Behdad Esfahbod | 10642b3 | 2018-09-15 19:43:33 +0200 | [diff] [blame] | 81 | LOffsetTo<UnsizedArrayOf<SettingName>, false> |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 82 | settingTable; /* Offset in bytes from the beginning of this table to |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 83 | * this feature's setting name array. The actual type of |
| 84 | * record this offset refers to will depend on the |
| 85 | * exclusivity value, as described below. */ |
| 86 | HBUINT16 featureFlags; /* Single-bit flags associated with the feature type. */ |
| 87 | HBINT16 nameIndex; /* The name table index for the feature's name. |
| 88 | * This index has values greater than 255 and |
| 89 | * less than 32768. */ |
| 90 | public: |
| 91 | DEFINE_SIZE_STATIC (12); |
| 92 | }; |
| 93 | |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 94 | struct feat |
| 95 | { |
| 96 | static const hb_tag_t tableTag = HB_AAT_TAG_feat; |
| 97 | |
| 98 | inline bool sanitize (hb_sanitize_context_t *c) const |
| 99 | { |
| 100 | TRACE_SANITIZE (this); |
Ebrahim Byagowi | a47070c | 2018-04-18 12:09:37 +0430 | [diff] [blame] | 101 | return_trace (likely (c->check_struct (this) && |
| 102 | names.sanitize (c, featureNameCount, this))); |
Ebrahim Byagowi | 44bf432 | 2018-03-31 16:51:36 +0430 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | protected: |
| 106 | FixedVersion<>version; /* Version number of the feature name table |
| 107 | * (0x00010000 for the current version). */ |
| 108 | HBUINT16 featureNameCount; |
| 109 | /* The number of entries in the feature name array. */ |
| 110 | HBUINT16 reserved1; /* Reserved (set to zero). */ |
| 111 | HBUINT32 reserved2; /* Reserved (set to zero). */ |
| 112 | UnsizedArrayOf<FeatureName> |
| 113 | names; /* The feature name array. */ |
| 114 | public: |
| 115 | DEFINE_SIZE_STATIC (24); |
| 116 | }; |
| 117 | |
| 118 | } /* namespace AAT */ |
| 119 | |
Ebrahim Byagowi | d3984b4 | 2018-04-01 12:16:42 +0430 | [diff] [blame] | 120 | #endif /* HB_AAT_LAYOUT_FEAT_TABLE_HH */ |