Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright © 2013 Google, Inc. |
michael@0 | 3 | * |
michael@0 | 4 | * This is part of HarfBuzz, a text shaping library. |
michael@0 | 5 | * |
michael@0 | 6 | * Permission is hereby granted, without written agreement and without |
michael@0 | 7 | * license or royalty fees, to use, copy, modify, and distribute this |
michael@0 | 8 | * software and its documentation for any purpose, provided that the |
michael@0 | 9 | * above copyright notice and the following two paragraphs appear in |
michael@0 | 10 | * all copies of this software. |
michael@0 | 11 | * |
michael@0 | 12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
michael@0 | 13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
michael@0 | 14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
michael@0 | 15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
michael@0 | 16 | * DAMAGE. |
michael@0 | 17 | * |
michael@0 | 18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
michael@0 | 19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
michael@0 | 20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
michael@0 | 21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
michael@0 | 22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
michael@0 | 23 | * |
michael@0 | 24 | * Google Author(s): Behdad Esfahbod |
michael@0 | 25 | */ |
michael@0 | 26 | |
michael@0 | 27 | #ifndef HB_OT_LAYOUT_JSTF_TABLE_HH |
michael@0 | 28 | #define HB_OT_LAYOUT_JSTF_TABLE_HH |
michael@0 | 29 | |
michael@0 | 30 | #include "hb-open-type-private.hh" |
michael@0 | 31 | #include "hb-ot-layout-gpos-table.hh" |
michael@0 | 32 | |
michael@0 | 33 | |
michael@0 | 34 | namespace OT { |
michael@0 | 35 | |
michael@0 | 36 | |
michael@0 | 37 | /* |
michael@0 | 38 | * JstfModList -- Justification Modification List Tables |
michael@0 | 39 | */ |
michael@0 | 40 | |
michael@0 | 41 | typedef IndexArray JstfModList; |
michael@0 | 42 | |
michael@0 | 43 | |
michael@0 | 44 | /* |
michael@0 | 45 | * JstfMax -- Justification Maximum Table |
michael@0 | 46 | */ |
michael@0 | 47 | |
michael@0 | 48 | typedef OffsetListOf<PosLookup> JstfMax; |
michael@0 | 49 | |
michael@0 | 50 | |
michael@0 | 51 | /* |
michael@0 | 52 | * JstfPriority -- Justification Priority Table |
michael@0 | 53 | */ |
michael@0 | 54 | |
michael@0 | 55 | struct JstfPriority |
michael@0 | 56 | { |
michael@0 | 57 | inline bool sanitize (hb_sanitize_context_t *c) { |
michael@0 | 58 | TRACE_SANITIZE (this); |
michael@0 | 59 | return TRACE_RETURN (c->check_struct (this) && |
michael@0 | 60 | shrinkageEnableGSUB.sanitize (c, this) && |
michael@0 | 61 | shrinkageDisableGSUB.sanitize (c, this) && |
michael@0 | 62 | shrinkageEnableGPOS.sanitize (c, this) && |
michael@0 | 63 | shrinkageDisableGPOS.sanitize (c, this) && |
michael@0 | 64 | shrinkageJstfMax.sanitize (c, this) && |
michael@0 | 65 | extensionEnableGSUB.sanitize (c, this) && |
michael@0 | 66 | extensionDisableGSUB.sanitize (c, this) && |
michael@0 | 67 | extensionEnableGPOS.sanitize (c, this) && |
michael@0 | 68 | extensionDisableGPOS.sanitize (c, this) && |
michael@0 | 69 | extensionJstfMax.sanitize (c, this)); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | protected: |
michael@0 | 73 | OffsetTo<JstfModList> |
michael@0 | 74 | shrinkageEnableGSUB; /* Offset to Shrinkage Enable GSUB |
michael@0 | 75 | * JstfModList table--from beginning of |
michael@0 | 76 | * JstfPriority table--may be NULL */ |
michael@0 | 77 | OffsetTo<JstfModList> |
michael@0 | 78 | shrinkageDisableGSUB; /* Offset to Shrinkage Disable GSUB |
michael@0 | 79 | * JstfModList table--from beginning of |
michael@0 | 80 | * JstfPriority table--may be NULL */ |
michael@0 | 81 | OffsetTo<JstfModList> |
michael@0 | 82 | shrinkageEnableGPOS; /* Offset to Shrinkage Enable GPOS |
michael@0 | 83 | * JstfModList table--from beginning of |
michael@0 | 84 | * JstfPriority table--may be NULL */ |
michael@0 | 85 | OffsetTo<JstfModList> |
michael@0 | 86 | shrinkageDisableGPOS; /* Offset to Shrinkage Disable GPOS |
michael@0 | 87 | * JstfModList table--from beginning of |
michael@0 | 88 | * JstfPriority table--may be NULL */ |
michael@0 | 89 | OffsetTo<JstfMax> |
michael@0 | 90 | shrinkageJstfMax; /* Offset to Shrinkage JstfMax table-- |
michael@0 | 91 | * from beginning of JstfPriority table |
michael@0 | 92 | * --may be NULL */ |
michael@0 | 93 | OffsetTo<JstfModList> |
michael@0 | 94 | extensionEnableGSUB; /* Offset to Extension Enable GSUB |
michael@0 | 95 | * JstfModList table--from beginning of |
michael@0 | 96 | * JstfPriority table--may be NULL */ |
michael@0 | 97 | OffsetTo<JstfModList> |
michael@0 | 98 | extensionDisableGSUB; /* Offset to Extension Disable GSUB |
michael@0 | 99 | * JstfModList table--from beginning of |
michael@0 | 100 | * JstfPriority table--may be NULL */ |
michael@0 | 101 | OffsetTo<JstfModList> |
michael@0 | 102 | extensionEnableGPOS; /* Offset to Extension Enable GPOS |
michael@0 | 103 | * JstfModList table--from beginning of |
michael@0 | 104 | * JstfPriority table--may be NULL */ |
michael@0 | 105 | OffsetTo<JstfModList> |
michael@0 | 106 | extensionDisableGPOS; /* Offset to Extension Disable GPOS |
michael@0 | 107 | * JstfModList table--from beginning of |
michael@0 | 108 | * JstfPriority table--may be NULL */ |
michael@0 | 109 | OffsetTo<JstfMax> |
michael@0 | 110 | extensionJstfMax; /* Offset to Extension JstfMax table-- |
michael@0 | 111 | * from beginning of JstfPriority table |
michael@0 | 112 | * --may be NULL */ |
michael@0 | 113 | |
michael@0 | 114 | public: |
michael@0 | 115 | DEFINE_SIZE_STATIC (20); |
michael@0 | 116 | }; |
michael@0 | 117 | |
michael@0 | 118 | |
michael@0 | 119 | /* |
michael@0 | 120 | * JstfLangSys -- Justification Language System Table |
michael@0 | 121 | */ |
michael@0 | 122 | |
michael@0 | 123 | struct JstfLangSys : OffsetListOf<JstfPriority> |
michael@0 | 124 | { |
michael@0 | 125 | inline bool sanitize (hb_sanitize_context_t *c, |
michael@0 | 126 | const Record<JstfLangSys>::sanitize_closure_t * = NULL) { |
michael@0 | 127 | TRACE_SANITIZE (this); |
michael@0 | 128 | return TRACE_RETURN (OffsetListOf<JstfPriority>::sanitize (c)); |
michael@0 | 129 | } |
michael@0 | 130 | }; |
michael@0 | 131 | |
michael@0 | 132 | |
michael@0 | 133 | /* |
michael@0 | 134 | * ExtenderGlyphs -- Extender Glyph Table |
michael@0 | 135 | */ |
michael@0 | 136 | |
michael@0 | 137 | typedef SortedArrayOf<GlyphID> ExtenderGlyphs; |
michael@0 | 138 | |
michael@0 | 139 | |
michael@0 | 140 | /* |
michael@0 | 141 | * JstfScript -- The Justification Table |
michael@0 | 142 | */ |
michael@0 | 143 | |
michael@0 | 144 | struct JstfScript |
michael@0 | 145 | { |
michael@0 | 146 | inline unsigned int get_lang_sys_count (void) const |
michael@0 | 147 | { return langSys.len; } |
michael@0 | 148 | inline const Tag& get_lang_sys_tag (unsigned int i) const |
michael@0 | 149 | { return langSys.get_tag (i); } |
michael@0 | 150 | inline unsigned int get_lang_sys_tags (unsigned int start_offset, |
michael@0 | 151 | unsigned int *lang_sys_count /* IN/OUT */, |
michael@0 | 152 | hb_tag_t *lang_sys_tags /* OUT */) const |
michael@0 | 153 | { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } |
michael@0 | 154 | inline const JstfLangSys& get_lang_sys (unsigned int i) const |
michael@0 | 155 | { |
michael@0 | 156 | if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); |
michael@0 | 157 | return this+langSys[i].offset; |
michael@0 | 158 | } |
michael@0 | 159 | inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const |
michael@0 | 160 | { return langSys.find_index (tag, index); } |
michael@0 | 161 | |
michael@0 | 162 | inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } |
michael@0 | 163 | inline const JstfLangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } |
michael@0 | 164 | |
michael@0 | 165 | inline bool sanitize (hb_sanitize_context_t *c, |
michael@0 | 166 | const Record<JstfScript>::sanitize_closure_t * = NULL) { |
michael@0 | 167 | TRACE_SANITIZE (this); |
michael@0 | 168 | return TRACE_RETURN (extenderGlyphs.sanitize (c, this) && |
michael@0 | 169 | defaultLangSys.sanitize (c, this) && |
michael@0 | 170 | langSys.sanitize (c, this)); |
michael@0 | 171 | } |
michael@0 | 172 | |
michael@0 | 173 | protected: |
michael@0 | 174 | OffsetTo<ExtenderGlyphs> |
michael@0 | 175 | extenderGlyphs; /* Offset to ExtenderGlyph table--from beginning |
michael@0 | 176 | * of JstfScript table-may be NULL */ |
michael@0 | 177 | OffsetTo<JstfLangSys> |
michael@0 | 178 | defaultLangSys; /* Offset to DefaultJstfLangSys table--from |
michael@0 | 179 | * beginning of JstfScript table--may be Null */ |
michael@0 | 180 | RecordArrayOf<JstfLangSys> |
michael@0 | 181 | langSys; /* Array of JstfLangSysRecords--listed |
michael@0 | 182 | * alphabetically by LangSysTag */ |
michael@0 | 183 | public: |
michael@0 | 184 | DEFINE_SIZE_ARRAY (6, langSys); |
michael@0 | 185 | }; |
michael@0 | 186 | |
michael@0 | 187 | |
michael@0 | 188 | /* |
michael@0 | 189 | * JSTF -- The Justification Table |
michael@0 | 190 | */ |
michael@0 | 191 | |
michael@0 | 192 | struct JSTF |
michael@0 | 193 | { |
michael@0 | 194 | static const hb_tag_t tableTag = HB_OT_TAG_JSTF; |
michael@0 | 195 | |
michael@0 | 196 | inline unsigned int get_script_count (void) const |
michael@0 | 197 | { return scriptList.len; } |
michael@0 | 198 | inline const Tag& get_script_tag (unsigned int i) const |
michael@0 | 199 | { return scriptList.get_tag (i); } |
michael@0 | 200 | inline unsigned int get_script_tags (unsigned int start_offset, |
michael@0 | 201 | unsigned int *script_count /* IN/OUT */, |
michael@0 | 202 | hb_tag_t *script_tags /* OUT */) const |
michael@0 | 203 | { return scriptList.get_tags (start_offset, script_count, script_tags); } |
michael@0 | 204 | inline const JstfScript& get_script (unsigned int i) const |
michael@0 | 205 | { return this+scriptList[i].offset; } |
michael@0 | 206 | inline bool find_script_index (hb_tag_t tag, unsigned int *index) const |
michael@0 | 207 | { return scriptList.find_index (tag, index); } |
michael@0 | 208 | |
michael@0 | 209 | inline bool sanitize (hb_sanitize_context_t *c) { |
michael@0 | 210 | TRACE_SANITIZE (this); |
michael@0 | 211 | return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) && |
michael@0 | 212 | scriptList.sanitize (c, this)); |
michael@0 | 213 | } |
michael@0 | 214 | |
michael@0 | 215 | protected: |
michael@0 | 216 | FixedVersion version; /* Version of the JSTF table--initially set |
michael@0 | 217 | * to 0x00010000 */ |
michael@0 | 218 | RecordArrayOf<JstfScript> |
michael@0 | 219 | scriptList; /* Array of JstfScripts--listed |
michael@0 | 220 | * alphabetically by ScriptTag */ |
michael@0 | 221 | public: |
michael@0 | 222 | DEFINE_SIZE_ARRAY (6, scriptList); |
michael@0 | 223 | }; |
michael@0 | 224 | |
michael@0 | 225 | |
michael@0 | 226 | } /* namespace OT */ |
michael@0 | 227 | |
michael@0 | 228 | |
michael@0 | 229 | #endif /* HB_OT_LAYOUT_JSTF_TABLE_HH */ |