gfx/harfbuzz/src/hb-ot-layout-jstf-table.hh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/harfbuzz/src/hb-ot-layout-jstf-table.hh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,229 @@
     1.4 +/*
     1.5 + * Copyright © 2013  Google, Inc.
     1.6 + *
     1.7 + *  This is part of HarfBuzz, a text shaping library.
     1.8 + *
     1.9 + * Permission is hereby granted, without written agreement and without
    1.10 + * license or royalty fees, to use, copy, modify, and distribute this
    1.11 + * software and its documentation for any purpose, provided that the
    1.12 + * above copyright notice and the following two paragraphs appear in
    1.13 + * all copies of this software.
    1.14 + *
    1.15 + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
    1.16 + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
    1.17 + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
    1.18 + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
    1.19 + * DAMAGE.
    1.20 + *
    1.21 + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
    1.22 + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    1.23 + * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
    1.24 + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
    1.25 + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
    1.26 + *
    1.27 + * Google Author(s): Behdad Esfahbod
    1.28 + */
    1.29 +
    1.30 +#ifndef HB_OT_LAYOUT_JSTF_TABLE_HH
    1.31 +#define HB_OT_LAYOUT_JSTF_TABLE_HH
    1.32 +
    1.33 +#include "hb-open-type-private.hh"
    1.34 +#include "hb-ot-layout-gpos-table.hh"
    1.35 +
    1.36 +
    1.37 +namespace OT {
    1.38 +
    1.39 +
    1.40 +/*
    1.41 + * JstfModList -- Justification Modification List Tables
    1.42 + */
    1.43 +
    1.44 +typedef IndexArray JstfModList;
    1.45 +
    1.46 +
    1.47 +/*
    1.48 + * JstfMax -- Justification Maximum Table
    1.49 + */
    1.50 +
    1.51 +typedef OffsetListOf<PosLookup> JstfMax;
    1.52 +
    1.53 +
    1.54 +/*
    1.55 + * JstfPriority -- Justification Priority Table
    1.56 + */
    1.57 +
    1.58 +struct JstfPriority
    1.59 +{
    1.60 +  inline bool sanitize (hb_sanitize_context_t *c) {
    1.61 +    TRACE_SANITIZE (this);
    1.62 +    return TRACE_RETURN (c->check_struct (this) &&
    1.63 +			 shrinkageEnableGSUB.sanitize (c, this) &&
    1.64 +			 shrinkageDisableGSUB.sanitize (c, this) &&
    1.65 +			 shrinkageEnableGPOS.sanitize (c, this) &&
    1.66 +			 shrinkageDisableGPOS.sanitize (c, this) &&
    1.67 +			 shrinkageJstfMax.sanitize (c, this) &&
    1.68 +			 extensionEnableGSUB.sanitize (c, this) &&
    1.69 +			 extensionDisableGSUB.sanitize (c, this) &&
    1.70 +			 extensionEnableGPOS.sanitize (c, this) &&
    1.71 +			 extensionDisableGPOS.sanitize (c, this) &&
    1.72 +			 extensionJstfMax.sanitize (c, this));
    1.73 +  }
    1.74 +
    1.75 +  protected:
    1.76 +  OffsetTo<JstfModList>
    1.77 +		shrinkageEnableGSUB;	/* Offset to Shrinkage Enable GSUB
    1.78 +					 * JstfModList table--from beginning of
    1.79 +					 * JstfPriority table--may be NULL */
    1.80 +  OffsetTo<JstfModList>
    1.81 +		shrinkageDisableGSUB;	/* Offset to Shrinkage Disable GSUB
    1.82 +					 * JstfModList table--from beginning of
    1.83 +					 * JstfPriority table--may be NULL */
    1.84 +  OffsetTo<JstfModList>
    1.85 +		shrinkageEnableGPOS;	/* Offset to Shrinkage Enable GPOS
    1.86 +					 * JstfModList table--from beginning of
    1.87 +					 * JstfPriority table--may be NULL */
    1.88 +  OffsetTo<JstfModList>
    1.89 +		shrinkageDisableGPOS;	/* Offset to Shrinkage Disable GPOS
    1.90 +					 * JstfModList table--from beginning of
    1.91 +					 * JstfPriority table--may be NULL */
    1.92 +  OffsetTo<JstfMax>
    1.93 +		shrinkageJstfMax;	/* Offset to Shrinkage JstfMax table--
    1.94 +					 * from beginning of JstfPriority table
    1.95 +					 * --may be NULL */
    1.96 +  OffsetTo<JstfModList>
    1.97 +		extensionEnableGSUB;	/* Offset to Extension Enable GSUB
    1.98 +					 * JstfModList table--from beginning of
    1.99 +					 * JstfPriority table--may be NULL */
   1.100 +  OffsetTo<JstfModList>
   1.101 +		extensionDisableGSUB;	/* Offset to Extension Disable GSUB
   1.102 +					 * JstfModList table--from beginning of
   1.103 +					 * JstfPriority table--may be NULL */
   1.104 +  OffsetTo<JstfModList>
   1.105 +		extensionEnableGPOS;	/* Offset to Extension Enable GPOS
   1.106 +					 * JstfModList table--from beginning of
   1.107 +					 * JstfPriority table--may be NULL */
   1.108 +  OffsetTo<JstfModList>
   1.109 +		extensionDisableGPOS;	/* Offset to Extension Disable GPOS
   1.110 +					 * JstfModList table--from beginning of
   1.111 +					 * JstfPriority table--may be NULL */
   1.112 +  OffsetTo<JstfMax>
   1.113 +		extensionJstfMax;	/* Offset to Extension JstfMax table--
   1.114 +					 * from beginning of JstfPriority table
   1.115 +					 * --may be NULL */
   1.116 +
   1.117 +  public:
   1.118 +  DEFINE_SIZE_STATIC (20);
   1.119 +};
   1.120 +
   1.121 +
   1.122 +/*
   1.123 + * JstfLangSys -- Justification Language System Table
   1.124 + */
   1.125 +
   1.126 +struct JstfLangSys : OffsetListOf<JstfPriority>
   1.127 +{
   1.128 +  inline bool sanitize (hb_sanitize_context_t *c,
   1.129 +			const Record<JstfLangSys>::sanitize_closure_t * = NULL) {
   1.130 +    TRACE_SANITIZE (this);
   1.131 +    return TRACE_RETURN (OffsetListOf<JstfPriority>::sanitize (c));
   1.132 +  }
   1.133 +};
   1.134 +
   1.135 +
   1.136 +/*
   1.137 + * ExtenderGlyphs -- Extender Glyph Table
   1.138 + */
   1.139 +
   1.140 +typedef SortedArrayOf<GlyphID> ExtenderGlyphs;
   1.141 +
   1.142 +
   1.143 +/*
   1.144 + * JstfScript -- The Justification Table
   1.145 + */
   1.146 +
   1.147 +struct JstfScript
   1.148 +{
   1.149 +  inline unsigned int get_lang_sys_count (void) const
   1.150 +  { return langSys.len; }
   1.151 +  inline const Tag& get_lang_sys_tag (unsigned int i) const
   1.152 +  { return langSys.get_tag (i); }
   1.153 +  inline unsigned int get_lang_sys_tags (unsigned int start_offset,
   1.154 +					 unsigned int *lang_sys_count /* IN/OUT */,
   1.155 +					 hb_tag_t     *lang_sys_tags /* OUT */) const
   1.156 +  { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); }
   1.157 +  inline const JstfLangSys& get_lang_sys (unsigned int i) const
   1.158 +  {
   1.159 +    if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys ();
   1.160 +    return this+langSys[i].offset;
   1.161 +  }
   1.162 +  inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
   1.163 +  { return langSys.find_index (tag, index); }
   1.164 +
   1.165 +  inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
   1.166 +  inline const JstfLangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
   1.167 +
   1.168 +  inline bool sanitize (hb_sanitize_context_t *c,
   1.169 +			const Record<JstfScript>::sanitize_closure_t * = NULL) {
   1.170 +    TRACE_SANITIZE (this);
   1.171 +    return TRACE_RETURN (extenderGlyphs.sanitize (c, this) &&
   1.172 +			 defaultLangSys.sanitize (c, this) &&
   1.173 +			 langSys.sanitize (c, this));
   1.174 +  }
   1.175 +
   1.176 +  protected:
   1.177 +  OffsetTo<ExtenderGlyphs>
   1.178 +		extenderGlyphs;	/* Offset to ExtenderGlyph table--from beginning
   1.179 +				 * of JstfScript table-may be NULL */
   1.180 +  OffsetTo<JstfLangSys>
   1.181 +		defaultLangSys;	/* Offset to DefaultJstfLangSys table--from
   1.182 +				 * beginning of JstfScript table--may be Null */
   1.183 +  RecordArrayOf<JstfLangSys>
   1.184 +		langSys;	/* Array of JstfLangSysRecords--listed
   1.185 +				 * alphabetically by LangSysTag */
   1.186 +  public:
   1.187 +  DEFINE_SIZE_ARRAY (6, langSys);
   1.188 +};
   1.189 +
   1.190 +
   1.191 +/*
   1.192 + * JSTF -- The Justification Table
   1.193 + */
   1.194 +
   1.195 +struct JSTF
   1.196 +{
   1.197 +  static const hb_tag_t tableTag	= HB_OT_TAG_JSTF;
   1.198 +
   1.199 +  inline unsigned int get_script_count (void) const
   1.200 +  { return scriptList.len; }
   1.201 +  inline const Tag& get_script_tag (unsigned int i) const
   1.202 +  { return scriptList.get_tag (i); }
   1.203 +  inline unsigned int get_script_tags (unsigned int start_offset,
   1.204 +				       unsigned int *script_count /* IN/OUT */,
   1.205 +				       hb_tag_t     *script_tags /* OUT */) const
   1.206 +  { return scriptList.get_tags (start_offset, script_count, script_tags); }
   1.207 +  inline const JstfScript& get_script (unsigned int i) const
   1.208 +  { return this+scriptList[i].offset; }
   1.209 +  inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
   1.210 +  { return scriptList.find_index (tag, index); }
   1.211 +
   1.212 +  inline bool sanitize (hb_sanitize_context_t *c) {
   1.213 +    TRACE_SANITIZE (this);
   1.214 +    return TRACE_RETURN (version.sanitize (c) && likely (version.major == 1) &&
   1.215 +			 scriptList.sanitize (c, this));
   1.216 +  }
   1.217 +
   1.218 +  protected:
   1.219 +  FixedVersion	version;	/* Version of the JSTF table--initially set
   1.220 +				 * to 0x00010000 */
   1.221 +  RecordArrayOf<JstfScript>
   1.222 +		scriptList;  	/* Array of JstfScripts--listed
   1.223 +				 * alphabetically by ScriptTag */
   1.224 +  public:
   1.225 +  DEFINE_SIZE_ARRAY (6, scriptList);
   1.226 +};
   1.227 +
   1.228 +
   1.229 +} /* namespace OT */
   1.230 +
   1.231 +
   1.232 +#endif /* HB_OT_LAYOUT_JSTF_TABLE_HH */

mercurial