michael@0: /* michael@0: * Copyright © 2013 Google, Inc. michael@0: * michael@0: * This is part of HarfBuzz, a text shaping library. michael@0: * michael@0: * Permission is hereby granted, without written agreement and without michael@0: * license or royalty fees, to use, copy, modify, and distribute this michael@0: * software and its documentation for any purpose, provided that the michael@0: * above copyright notice and the following two paragraphs appear in michael@0: * all copies of this software. michael@0: * michael@0: * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR michael@0: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES michael@0: * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN michael@0: * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH michael@0: * DAMAGE. michael@0: * michael@0: * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, michael@0: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND michael@0: * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS michael@0: * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO michael@0: * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. michael@0: * michael@0: * Google Author(s): Behdad Esfahbod michael@0: */ michael@0: michael@0: #ifndef HB_OT_LAYOUT_JSTF_TABLE_HH michael@0: #define HB_OT_LAYOUT_JSTF_TABLE_HH michael@0: michael@0: #include "hb-open-type-private.hh" michael@0: #include "hb-ot-layout-gpos-table.hh" michael@0: michael@0: michael@0: namespace OT { michael@0: michael@0: michael@0: /* michael@0: * JstfModList -- Justification Modification List Tables michael@0: */ michael@0: michael@0: typedef IndexArray JstfModList; michael@0: michael@0: michael@0: /* michael@0: * JstfMax -- Justification Maximum Table michael@0: */ michael@0: michael@0: typedef OffsetListOf JstfMax; michael@0: michael@0: michael@0: /* michael@0: * JstfPriority -- Justification Priority Table michael@0: */ michael@0: michael@0: struct JstfPriority michael@0: { michael@0: inline bool sanitize (hb_sanitize_context_t *c) { michael@0: TRACE_SANITIZE (this); michael@0: return TRACE_RETURN (c->check_struct (this) && michael@0: shrinkageEnableGSUB.sanitize (c, this) && michael@0: shrinkageDisableGSUB.sanitize (c, this) && michael@0: shrinkageEnableGPOS.sanitize (c, this) && michael@0: shrinkageDisableGPOS.sanitize (c, this) && michael@0: shrinkageJstfMax.sanitize (c, this) && michael@0: extensionEnableGSUB.sanitize (c, this) && michael@0: extensionDisableGSUB.sanitize (c, this) && michael@0: extensionEnableGPOS.sanitize (c, this) && michael@0: extensionDisableGPOS.sanitize (c, this) && michael@0: extensionJstfMax.sanitize (c, this)); michael@0: } michael@0: michael@0: protected: michael@0: OffsetTo michael@0: shrinkageEnableGSUB; /* Offset to Shrinkage Enable GSUB michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: shrinkageDisableGSUB; /* Offset to Shrinkage Disable GSUB michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: shrinkageEnableGPOS; /* Offset to Shrinkage Enable GPOS michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: shrinkageDisableGPOS; /* Offset to Shrinkage Disable GPOS michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: shrinkageJstfMax; /* Offset to Shrinkage JstfMax table-- michael@0: * from beginning of JstfPriority table michael@0: * --may be NULL */ michael@0: OffsetTo michael@0: extensionEnableGSUB; /* Offset to Extension Enable GSUB michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: extensionDisableGSUB; /* Offset to Extension Disable GSUB michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: extensionEnableGPOS; /* Offset to Extension Enable GPOS michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: extensionDisableGPOS; /* Offset to Extension Disable GPOS michael@0: * JstfModList table--from beginning of michael@0: * JstfPriority table--may be NULL */ michael@0: OffsetTo michael@0: extensionJstfMax; /* Offset to Extension JstfMax table-- michael@0: * from beginning of JstfPriority table michael@0: * --may be NULL */ michael@0: michael@0: public: michael@0: DEFINE_SIZE_STATIC (20); michael@0: }; michael@0: michael@0: michael@0: /* michael@0: * JstfLangSys -- Justification Language System Table michael@0: */ michael@0: michael@0: struct JstfLangSys : OffsetListOf michael@0: { michael@0: inline bool sanitize (hb_sanitize_context_t *c, michael@0: const Record::sanitize_closure_t * = NULL) { michael@0: TRACE_SANITIZE (this); michael@0: return TRACE_RETURN (OffsetListOf::sanitize (c)); michael@0: } michael@0: }; michael@0: michael@0: michael@0: /* michael@0: * ExtenderGlyphs -- Extender Glyph Table michael@0: */ michael@0: michael@0: typedef SortedArrayOf ExtenderGlyphs; michael@0: michael@0: michael@0: /* michael@0: * JstfScript -- The Justification Table michael@0: */ michael@0: michael@0: struct JstfScript michael@0: { michael@0: inline unsigned int get_lang_sys_count (void) const michael@0: { return langSys.len; } michael@0: inline const Tag& get_lang_sys_tag (unsigned int i) const michael@0: { return langSys.get_tag (i); } michael@0: inline unsigned int get_lang_sys_tags (unsigned int start_offset, michael@0: unsigned int *lang_sys_count /* IN/OUT */, michael@0: hb_tag_t *lang_sys_tags /* OUT */) const michael@0: { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } michael@0: inline const JstfLangSys& get_lang_sys (unsigned int i) const michael@0: { michael@0: if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); michael@0: return this+langSys[i].offset; michael@0: } michael@0: inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const michael@0: { return langSys.find_index (tag, index); } michael@0: michael@0: inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } michael@0: inline const JstfLangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } michael@0: michael@0: inline bool sanitize (hb_sanitize_context_t *c, michael@0: const Record::sanitize_closure_t * = NULL) { michael@0: TRACE_SANITIZE (this); michael@0: return TRACE_RETURN (extenderGlyphs.sanitize (c, this) && michael@0: defaultLangSys.sanitize (c, this) && michael@0: langSys.sanitize (c, this)); michael@0: } michael@0: michael@0: protected: michael@0: OffsetTo michael@0: extenderGlyphs; /* Offset to ExtenderGlyph table--from beginning michael@0: * of JstfScript table-may be NULL */ michael@0: OffsetTo michael@0: defaultLangSys; /* Offset to DefaultJstfLangSys table--from michael@0: * beginning of JstfScript table--may be Null */ michael@0: RecordArrayOf michael@0: langSys; /* Array of JstfLangSysRecords--listed michael@0: * alphabetically by LangSysTag */ michael@0: public: michael@0: DEFINE_SIZE_ARRAY (6, langSys); michael@0: }; michael@0: michael@0: michael@0: /* michael@0: * JSTF -- The Justification Table michael@0: */ michael@0: michael@0: struct JSTF michael@0: { michael@0: static const hb_tag_t tableTag = HB_OT_TAG_JSTF; michael@0: michael@0: inline unsigned int get_script_count (void) const michael@0: { return scriptList.len; } michael@0: inline const Tag& get_script_tag (unsigned int i) const michael@0: { return scriptList.get_tag (i); } michael@0: inline unsigned int get_script_tags (unsigned int start_offset, michael@0: unsigned int *script_count /* IN/OUT */, michael@0: hb_tag_t *script_tags /* OUT */) const michael@0: { return scriptList.get_tags (start_offset, script_count, script_tags); } michael@0: inline const JstfScript& get_script (unsigned int i) const michael@0: { return this+scriptList[i].offset; } michael@0: inline bool find_script_index (hb_tag_t tag, unsigned int *index) const michael@0: { return scriptList.find_index (tag, index); } michael@0: michael@0: inline bool sanitize (hb_sanitize_context_t *c) { michael@0: TRACE_SANITIZE (this); michael@0: return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) && michael@0: scriptList.sanitize (c, this)); michael@0: } michael@0: michael@0: protected: michael@0: FixedVersion version; /* Version of the JSTF table--initially set michael@0: * to 0x00010000 */ michael@0: RecordArrayOf michael@0: scriptList; /* Array of JstfScripts--listed michael@0: * alphabetically by ScriptTag */ michael@0: public: michael@0: DEFINE_SIZE_ARRAY (6, scriptList); michael@0: }; michael@0: michael@0: michael@0: } /* namespace OT */ michael@0: michael@0: michael@0: #endif /* HB_OT_LAYOUT_JSTF_TABLE_HH */