hb-ot-layout-common-private.hh revision abcfe9b59b4475eb02dd679aac4bc59616713b28
16f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2007,2008,2009 Red Hat, Inc. 32409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2010 Google, Inc. 46f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 5c755cb3e3ac55156d0d2ec05adea7a650b97cc41Behdad Esfahbod * This is part of HarfBuzz, a text shaping library. 66f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 76f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Permission is hereby granted, without written agreement and without 86f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 96f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * software and its documentation for any purpose, provided that the 106f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * above copyright notice and the following two paragraphs appear in 116f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * all copies of this software. 126f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 136f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 146f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 156f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 166f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 176f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * DAMAGE. 186f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 196f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 206f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 216f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 226f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 236f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 246f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 256f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Red Hat Author(s): Behdad Esfahbod 265bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod * Google Author(s): Behdad Esfahbod 276f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 286f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 295f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH 305f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#define HB_OT_LAYOUT_COMMON_PRIVATE_HH 316f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3222da7fd94d6318c52df69d70470a85464ffc533dBehdad Esfahbod#include "hb-ot-layout-private.hh" 332098a021a826e76ee27d5db74e32738d7d1c3d30Behdad Esfahbod 347edb430f9182723b7b720708c56088cec1200a70Behdad Esfahbod#include "hb-open-type-private.hh" 356f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 366f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 37cd33cb9ed84308da72bd7c64b9355dc2410c63ecBehdad Esfahbod#define NO_CONTEXT ((unsigned int) 0x110000) 38cd33cb9ed84308da72bd7c64b9355dc2410c63ecBehdad Esfahbod#define NOT_COVERED ((unsigned int) 0x110000) 39cd33cb9ed84308da72bd7c64b9355dc2410c63ecBehdad Esfahbod#define MAX_NESTING_LEVEL 8 40cd33cb9ed84308da72bd7c64b9355dc2410c63ecBehdad Esfahbod 41acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_BEGIN_DECLS 42acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_END_DECLS 43acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 44cd33cb9ed84308da72bd7c64b9355dc2410c63ecBehdad Esfahbod 456f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 466f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 476f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * OpenType Layout Common Table Formats 486f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * 496f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 506f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 512e8fb6c38dbc01cb77b384c0ae0212514dfbb588Behdad Esfahbod 526f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 536f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Script, ScriptList, LangSys, Feature, FeatureList, Lookup, LookupList 546f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 556f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 566f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodtemplate <typename Type> 5760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Record 5860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 594e573715ae5f5ed486ad66382bb44c47a86591ffBehdad Esfahbod inline int cmp (hb_tag_t a) const { 6036b3862009c00ad922d68810173a69ac59723365Behdad Esfahbod return tag.cmp (a); 61cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod } 62cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod 63d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c, void *base) { 643e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 65d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return c->check_struct (this) 66d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && offset.sanitize (c, base); 67cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 68cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 696f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod Tag tag; /* 4-byte Tag identifier */ 706f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod OffsetTo<Type> 716f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod offset; /* Offset from beginning of object holding 726f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * the Record */ 73569da92bc6956f42d9b2d65c784e184fb6380efeBehdad Esfahbod public: 74569da92bc6956f42d9b2d65c784e184fb6380efeBehdad Esfahbod DEFINE_SIZE_STATIC (6); 756f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 766f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 776f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodtemplate <typename Type> 78cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbodstruct RecordArrayOf : SortedArrayOf<Record<Type> > { 7960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline const Tag& get_tag (unsigned int i) const 8060d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 814e22c7e94102c9f00c32b8cb6aaa832f83909149Behdad Esfahbod /* We cheat slightly and don't define separate Null objects 824e22c7e94102c9f00c32b8cb6aaa832f83909149Behdad Esfahbod * for Record types. Instead, we return the correct Null(Tag) 834e22c7e94102c9f00c32b8cb6aaa832f83909149Behdad Esfahbod * here. */ 8464d3fc8d0dada673245cc8c0b1c12cd849b30997Behdad Esfahbod if (unlikely (i >= this->len)) return Null(Tag); 85d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod return (*this)[i].tag; 866f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 87e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_tags (unsigned int start_offset, 88e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *record_count /* IN/OUT */, 89e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod hb_tag_t *record_tags /* OUT */) const 90bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { 91e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (record_count) { 924f5f1c34dda1e0629bfa6d7b0ffa2e1ce003b7c7Behdad Esfahbod const Record<Type> *array = this->sub_array (start_offset, record_count); 9348de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod unsigned int count = *record_count; 94e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 95e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod record_tags[i] = array[i].tag; 96e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod } 97e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return this->len; 98bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod } 99bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline bool find_index (hb_tag_t tag, unsigned int *index) const 100bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { 101cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod int i = this->search (tag); 102cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod if (i != -1) { 103bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod if (index) *index = i; 104bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod return true; 105cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod } else { 106cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod if (index) *index = Index::NOT_FOUND_INDEX; 107cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod return false; 108bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod } 109bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod } 110bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod}; 111bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod 112bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbodtemplate <typename Type> 113bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbodstruct RecordListOf : RecordArrayOf<Type> 114bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod{ 115bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline const Type& operator [] (unsigned int i) const 1166bec81aa3a58b8be255568b2ea63b7854e1b0ea7Behdad Esfahbod { return this+RecordArrayOf<Type>::operator [](i).offset; } 117cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 118d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 1193e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 120d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return RecordArrayOf<Type>::sanitize (c, this); 121cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 1226f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 1236f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 1246f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 125cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbodstruct RangeRecord 126cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod{ 127cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod inline int cmp (hb_codepoint_t g) const { 128cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod hb_codepoint_t a = start, b = end; 129cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod return g < a ? -1 : g <= b ? 0 : +1 ; 130cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod } 131cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod 132cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 133cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod TRACE_SANITIZE (); 134cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod return c->check_struct (this); 135cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod } 136cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod 137cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod GlyphID start; /* First GlyphID in the range */ 138cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod GlyphID end; /* Last GlyphID in the range */ 139cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod USHORT value; /* Value */ 140cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod public: 141cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod DEFINE_SIZE_STATIC (6); 142cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod}; 143cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad EsfahbodDEFINE_NULL_DATA (RangeRecord, "\000\001"); 144cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod 145cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod 146b5db4f1e4eefa266a71a28b5496f47ff9d1a81e8Behdad Esfahbodstruct IndexArray : ArrayOf<Index> 147bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod{ 148e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_indexes (unsigned int start_offset, 149e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *_count /* IN/OUT */, 150e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *_indexes /* OUT */) const 151bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { 152e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod if (_count) { 1534f5f1c34dda1e0629bfa6d7b0ffa2e1ce003b7c7Behdad Esfahbod const USHORT *array = this->sub_array (start_offset, _count); 15448de3730cdf91b9f6473509e22260a902ccec992Behdad Esfahbod unsigned int count = *_count; 155e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod for (unsigned int i = 0; i < count; i++) 156e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod _indexes[i] = array[i]; 157e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod } 158e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod return this->len; 159bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod } 160bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod}; 161bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod 162bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod 1636f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodstruct Script; 1646f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodstruct LangSys; 1656f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodstruct Feature; 1666f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 1676f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 16860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LangSys 16960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 170bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline unsigned int get_feature_count (void) const 171bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return featureIndex.len; } 172bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline hb_tag_t get_feature_index (unsigned int i) const 173bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return featureIndex[i]; } 174e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_feature_indexes (unsigned int start_offset, 175e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *feature_count /* IN/OUT */, 176e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *feature_indexes /* OUT */) const 177e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod { return featureIndex.get_indexes (start_offset, feature_count, feature_indexes); } 1786f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 179cc6c644ff2af5f6669b6ec100ff13e904872b21cBehdad Esfahbod inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; } 1803d44fb6f15177dc6518166e435597936b044acc1Behdad Esfahbod inline unsigned int get_required_feature_index (void) const 18160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 1826f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod if (reqFeatureIndex == 0xffff) 183b5db4f1e4eefa266a71a28b5496f47ff9d1a81e8Behdad Esfahbod return Index::NOT_FOUND_INDEX; 1846f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return reqFeatureIndex;; 1856f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 1866f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 187d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 1883e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 189d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return c->check_struct (this) 190d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && featureIndex.sanitize (c); 191cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 192cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 1936f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod Offset lookupOrder; /* = Null (reserved for an offset to a 1946f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * reordering table) */ 1956f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT reqFeatureIndex;/* Index of a feature required for this 1966f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * language system--if no required features 1976f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * = 0xFFFF */ 198bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod IndexArray featureIndex; /* Array of indices into the FeatureList */ 199569da92bc6956f42d9b2d65c784e184fb6380efeBehdad Esfahbod public: 2000eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (6, featureIndex); 2016f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 20265f46b00333e20ab8a52a4b350747507541ec1dbBehdad EsfahbodDEFINE_NULL_DATA (LangSys, "\0\0\xFF\xFF"); 2036f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2046f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 20560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Script 20660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 207bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline unsigned int get_lang_sys_count (void) const 208bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return langSys.len; } 209bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline const Tag& get_lang_sys_tag (unsigned int i) const 210bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return langSys.get_tag (i); } 211e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_lang_sys_tags (unsigned int start_offset, 212e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *lang_sys_count /* IN/OUT */, 213e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod hb_tag_t *lang_sys_tags /* OUT */) const 214e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod { return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); } 21560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline const LangSys& get_lang_sys (unsigned int i) const 21660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 217b5db4f1e4eefa266a71a28b5496f47ff9d1a81e8Behdad Esfahbod if (i == Index::NOT_FOUND_INDEX) return get_default_lang_sys (); 2186f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return this+langSys[i].offset; 2196f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 220bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const 221bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return langSys.find_index (tag, index); } 2226f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 223cc6c644ff2af5f6669b6ec100ff13e904872b21cBehdad Esfahbod inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } 22460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } 2256f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 226d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 2273e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 228d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return defaultLangSys.sanitize (c, this) 229d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && langSys.sanitize (c, this); 230cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 231cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 2326f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 2336f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod OffsetTo<LangSys> 2346f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod defaultLangSys; /* Offset to DefaultLangSys table--from 2356f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * beginning of Script table--may be Null */ 236cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod RecordArrayOf<LangSys> 2376f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod langSys; /* Array of LangSysRecords--listed 2386f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * alphabetically by LangSysTag */ 239b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 2400eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (4, langSys); 2416f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 2426f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2436f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodtypedef RecordListOf<Script> ScriptList; 2446f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2456f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 24660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Feature 24760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 248bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline unsigned int get_lookup_count (void) const 249bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return lookupIndex.len; } 250bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod inline hb_tag_t get_lookup_index (unsigned int i) const 251bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod { return lookupIndex[i]; } 252e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod inline unsigned int get_lookup_indexes (unsigned int start_index, 253e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *lookup_count /* IN/OUT */, 254e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod unsigned int *lookup_tags /* OUT */) const 255e21899bc3593aa0d3adf64cee21c5de2ea219783Behdad Esfahbod { return lookupIndex.get_indexes (start_index, lookup_count, lookup_tags); } 2566f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 257d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 2583e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 259d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return c->check_struct (this) 260d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && lookupIndex.sanitize (c); 261cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 262cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 2636f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod Offset featureParams; /* Offset to Feature Parameters table (if one 2646f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * has been defined for the feature), relative 2656f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * to the beginning of the Feature Table; = Null 2666f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * if not required */ 267bff3c0fde5da04a70d1f7aeeb9fa2a75fe5c07f6Behdad Esfahbod IndexArray lookupIndex; /* Array of LookupList indices */ 268b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 2690eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (4, lookupIndex); 2706f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 2716f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2726f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodtypedef RecordListOf<Feature> FeatureList; 2736f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2746f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 27560d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct LookupFlag : USHORT 27660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 2774fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod enum { 2784fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod RightToLeft = 0x0001u, 2794fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod IgnoreBaseGlyphs = 0x0002u, 2804fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod IgnoreLigatures = 0x0004u, 2814fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod IgnoreMarks = 0x0008u, 282aa87d951739f6beacb66daa235cd033fdcfcadd7Behdad Esfahbod IgnoreFlags = 0x000Eu, 283d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod UseMarkFilteringSet = 0x0010u, 284d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod Reserved = 0x00E0u, 2858f034d5849627ee95a5889fa34c9ba294fff13caBehdad Esfahbod MarkAttachmentType = 0xFF00u 2864fa77d3c4305a76b956de8c1a9b83a961d035a80Behdad Esfahbod }; 287b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 288b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod DEFINE_SIZE_STATIC (2); 2896f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 2906f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 29160d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Lookup 29260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 29360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline unsigned int get_subtable_count (void) const { return subTable.len; } 2946f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 2956f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod inline unsigned int get_type (void) const { return lookupType; } 2968c69e65abed961002d90024c92e18538c6516262Behdad Esfahbod 2978c69e65abed961002d90024c92e18538c6516262Behdad Esfahbod /* lookup_props is a 32-bit integer where the lower 16-bit is LookupFlag and 2988c69e65abed961002d90024c92e18538c6516262Behdad Esfahbod * higher 16-bit is mark-filtering-set if the lookup uses one. 2998c69e65abed961002d90024c92e18538c6516262Behdad Esfahbod * Not to be confused with glyph_props which is very similar. */ 3008c69e65abed961002d90024c92e18538c6516262Behdad Esfahbod inline uint32_t get_props (void) const 301d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod { 302d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod unsigned int flag = lookupFlag; 30364d3fc8d0dada673245cc8c0b1c12cd849b30997Behdad Esfahbod if (unlikely (flag & LookupFlag::UseMarkFilteringSet)) 304d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod { 305e961c86c579fd98ee604342a9c70c4e7f8d4f220Behdad Esfahbod const USHORT &markFilteringSet = StructAfter<USHORT> (subTable); 30609c292e3b688a67fbae67b645d1e6ffcf8d8eb6eBehdad Esfahbod flag += (markFilteringSet << 16); 307d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod } 308d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod return flag; 309d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod } 3106f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 311d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 3123e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 3133b2c2df41b90f2a1d9e33b3dc15a92cff58a689aBehdad Esfahbod /* Real sanitize of the subtables is done by GSUB/GPOS/... */ 314d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod if (!(c->check_struct (this) 315d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && subTable.sanitize (c))) return false; 31664d3fc8d0dada673245cc8c0b1c12cd849b30997Behdad Esfahbod if (unlikely (lookupFlag & LookupFlag::UseMarkFilteringSet)) 317cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod { 318e961c86c579fd98ee604342a9c70c4e7f8d4f220Behdad Esfahbod USHORT &markFilteringSet = StructAfter<USHORT> (subTable); 319d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod if (!markFilteringSet.sanitize (c)) return false; 320cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 321cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod return true; 322cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod } 323cd3827ee567612c5500206b62840702fc956e0f5Behdad Esfahbod 324d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod USHORT lookupType; /* Different enumerations for GSUB and GPOS */ 325d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod USHORT lookupFlag; /* Lookup qualifiers */ 3263b2c2df41b90f2a1d9e33b3dc15a92cff58a689aBehdad Esfahbod ArrayOf<Offset> 327d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod subTable; /* Array of SubTables */ 328d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod USHORT markFilteringSetX[VAR]; /* Index (base 0) into GDEF mark glyph sets 329d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod * structure. This field is only present if bit 330d7df42d7ee586219475878d160f85ae5a188bd59Behdad Esfahbod * UseMarkFilteringSet of lookup flags is set. */ 331569da92bc6956f42d9b2d65c784e184fb6380efeBehdad Esfahbod public: 3320eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY2 (6, subTable, markFilteringSetX); 3336f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 3346f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3356f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbodtypedef OffsetListOf<Lookup> LookupList; 3366f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3376f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3386f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 3396f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Coverage Table 3406f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 3416f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 34260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CoverageFormat1 34360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 3446f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod friend struct Coverage; 3456f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3466f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 34760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline unsigned int get_coverage (hb_codepoint_t glyph_id) const 34860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 349cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod int i = glyphArray.search (glyph_id); 350cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod if (i != -1) 3516f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return i; 3526f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return NOT_COVERED; 3536f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 3546f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 355d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 3563e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 357d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return glyphArray.sanitize (c); 35870de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 35970de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 36070de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod private: 3616f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT coverageFormat; /* Format identifier--format = 1 */ 362cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod SortedArrayOf<GlyphID> 3636f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod glyphArray; /* Array of GlyphIDs--in numerical order */ 364b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 3650eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (4, glyphArray); 3666f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 3676f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 36860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct CoverageFormat2 36960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 3706f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod friend struct Coverage; 3716f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 3726f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 37360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod inline unsigned int get_coverage (hb_codepoint_t glyph_id) const 37460d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 375cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod int i = rangeRecord.search (glyph_id); 376cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod if (i != -1) { 377cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod const RangeRecord &range = rangeRecord[i]; 378cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod return (unsigned int) range.value + (glyph_id - range.start); 3796f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 3806f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return NOT_COVERED; 3816f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 3826f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 383d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 3843e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 385d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return rangeRecord.sanitize (c); 38670de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 38770de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 38870de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod private: 3896f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT coverageFormat; /* Format identifier--format = 2 */ 390cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod SortedArrayOf<RangeRecord> 3916f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod rangeRecord; /* Array of glyph ranges--ordered by 3926f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Start GlyphID. rangeCount entries 3936f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * long */ 394b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 3950eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (4, rangeRecord); 3966f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 3976f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 39860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Coverage 39960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 40000e23fcc6fd0eee5c582251bf3de6a2703fbbd3eBehdad Esfahbod inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); } 40170de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 40220b035dad41247076815a2bbb0346d63058b322fBehdad Esfahbod inline unsigned int get_coverage (hb_codepoint_t glyph_id) const 40360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 4046f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod switch (u.format) { 405dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod case 1: return u.format1.get_coverage(glyph_id); 406dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod case 2: return u.format2.get_coverage(glyph_id); 4076f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod default:return NOT_COVERED; 4086f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 4096f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 4106f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 411d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 4123e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 413d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod if (!u.format.sanitize (c)) return false; 41470de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod switch (u.format) { 415d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod case 1: return u.format1.sanitize (c); 416d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod case 2: return u.format2.sanitize (c); 41770de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod default:return true; 41870de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 41970de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 4206f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 4216f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 4226f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod union { 4236f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT format; /* Format identifier */ 424dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod CoverageFormat1 format1; 425dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod CoverageFormat2 format2; 4266f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } u; 427ed07422c33bbb52ff4d79e65986171e3f07697d8Behdad Esfahbod public: 428596e471aa5053d955fb5d5b5923088c8814469b1Behdad Esfahbod DEFINE_SIZE_UNION (2, format); 4296f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 4306f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 4316f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 4326f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 4336f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Class Definition Table 4346f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 4356f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 43660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct ClassDefFormat1 43760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 4386f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod friend struct ClassDef; 4396f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 4406f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 44198370e89d1bff248737b482d129c2a4deb8bfd95Behdad Esfahbod inline unsigned int get_class (hb_codepoint_t glyph_id) const 44260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 4436f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod if ((unsigned int) (glyph_id - startGlyph) < classValue.len) 4446f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return classValue[glyph_id - startGlyph]; 4456f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return 0; 4466f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 4476f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 448d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 4493e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 450d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return c->check_struct (this) 451d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && classValue.sanitize (c); 45270de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 45370de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 4546f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT classFormat; /* Format identifier--format = 1 */ 4556f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod GlyphID startGlyph; /* First GlyphID of the classValueArray */ 4566f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod ArrayOf<USHORT> 4576f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod classValue; /* Array of Class Values--one per GlyphID */ 458b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 4590eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (6, classValue); 4606f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 4616f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 46260d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct ClassDefFormat2 46360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 4646f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod friend struct ClassDef; 4656f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 4666f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 46798370e89d1bff248737b482d129c2a4deb8bfd95Behdad Esfahbod inline unsigned int get_class (hb_codepoint_t glyph_id) const 46860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 469cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod int i = rangeRecord.search (glyph_id); 470cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod if (i != -1) 471cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod return rangeRecord[i].value; 4726f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod return 0; 4736f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 4746f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 475d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 4763e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 477d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return rangeRecord.sanitize (c); 47870de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 47970de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 4806f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT classFormat; /* Format identifier--format = 2 */ 481cc8a4abea68f2dba26feb5785f9e518e6853c744Behdad Esfahbod SortedArrayOf<RangeRecord> 4826f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod rangeRecord; /* Array of glyph ranges--ordered by 4836f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Start GlyphID */ 484b3651231bf80bb7009214547a75ed90e21815c68Behdad Esfahbod public: 4850eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (4, rangeRecord); 4866f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 4876f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 48860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct ClassDef 48960d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 49098370e89d1bff248737b482d129c2a4deb8bfd95Behdad Esfahbod inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_class (glyph_id); } 49170de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod 49298370e89d1bff248737b482d129c2a4deb8bfd95Behdad Esfahbod inline unsigned int get_class (hb_codepoint_t glyph_id) const 49360d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 4946f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod switch (u.format) { 495dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod case 1: return u.format1.get_class(glyph_id); 496dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod case 2: return u.format2.get_class(glyph_id); 4976f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod default:return 0; 4986f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 4996f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } 5006f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 501d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 5023e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 503d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod if (!u.format.sanitize (c)) return false; 50470de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod switch (u.format) { 505d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod case 1: return u.format1.sanitize (c); 506d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod case 2: return u.format2.sanitize (c); 50770de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod default:return true; 50870de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 50970de50c11ed7037b20eb6814ff60f6e32a9944e4Behdad Esfahbod } 510aa3d7adca5c821c91a2a1b5380fd6b3d19656ab1Behdad Esfahbod 5116f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 5126f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod union { 5136f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod USHORT format; /* Format identifier */ 514dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod ClassDefFormat1 format1; 515dacebcadae36b35531d635d81df2afb937677b7aBehdad Esfahbod ClassDefFormat2 format2; 5166f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod } u; 517ed07422c33bbb52ff4d79e65986171e3f07697d8Behdad Esfahbod public: 518596e471aa5053d955fb5d5b5923088c8814469b1Behdad Esfahbod DEFINE_SIZE_UNION (2, format); 5196f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 5206f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 5216f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 5226f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod/* 5236f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod * Device Tables 5246f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod */ 5256f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 52660d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbodstruct Device 52760d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod{ 528b634beb39e0a4fef7167a8af646f6b2d8cafe69bBehdad Esfahbod 529abcfe9b59b4475eb02dd679aac4bc59616713b28Behdad Esfahbod inline hb_position_t get_x_delta (hb_font_t *font) const 530abcfe9b59b4475eb02dd679aac4bc59616713b28Behdad Esfahbod { return get_delta (font->x_ppem, font->x_scale); } 531b634beb39e0a4fef7167a8af646f6b2d8cafe69bBehdad Esfahbod 532abcfe9b59b4475eb02dd679aac4bc59616713b28Behdad Esfahbod inline hb_position_t get_y_delta (hb_font_t *font) const 533abcfe9b59b4475eb02dd679aac4bc59616713b28Behdad Esfahbod { return get_delta (font->y_ppem, font->y_scale); } 534b634beb39e0a4fef7167a8af646f6b2d8cafe69bBehdad Esfahbod 535da975419884a535281745f30f4b32fee0bc8a7a1Behdad Esfahbod inline int get_delta (unsigned int ppem, int scale) const 5365bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod { 5375bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod if (!ppem) return 0; 5385bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod 5395bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod int pixels = get_delta_pixels (ppem); 5405bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod 5415bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod if (!pixels) return 0; 5425bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod 5435bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod return pixels * (int64_t) scale / ppem; 5445bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod } 5455bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod 5465bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod 5475bd1e95236320aed60fb29ca1e93b9595d4aeeecBehdad Esfahbod inline int get_delta_pixels (unsigned int ppem_size) const 54860d77cf05fddc5304b4b1fc19cdedba15cbee1e9Behdad Esfahbod { 549056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod unsigned int f = deltaFormat; 55064d3fc8d0dada673245cc8c0b1c12cd849b30997Behdad Esfahbod if (unlikely (f < 1 || f > 3)) 551056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod return 0; 5526f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 553056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod if (ppem_size < startSize || ppem_size > endSize) 554056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod return 0; 5556f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 556056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod unsigned int s = ppem_size - startSize; 5576f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 558056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod unsigned int byte = deltaValue[s >> (4 - f)]; 55909c292e3b688a67fbae67b645d1e6ffcf8d8eb6eBehdad Esfahbod unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f))); 56009c292e3b688a67fbae67b645d1e6ffcf8d8eb6eBehdad Esfahbod unsigned int mask = (0xFFFF >> (16 - (1 << f))); 561056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod 562056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod int delta = bits & mask; 563056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod 56415164d9258a74122a4db748d35532bd72c47cec2Behdad Esfahbod if ((unsigned int) delta >= ((mask + 1) >> 1)) 565056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod delta -= mask + 1; 566056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod 567056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod return delta; 568056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod } 569056c7ec1aea1eca60a3b20b583b8a8072be9d758Behdad Esfahbod 5707f97d2cd904ea999c099c73c52187c5d65aeec67Behdad Esfahbod inline unsigned int get_size (void) const 571dc9c4d93cd0f3ac991f32df08c1c17fc389054c0Behdad Esfahbod { 572dc9c4d93cd0f3ac991f32df08c1c17fc389054c0Behdad Esfahbod unsigned int f = deltaFormat; 573b961518b9611471ff7060e97686e5625974847ebBehdad Esfahbod if (unlikely (f < 1 || f > 3 || startSize > endSize)) return 3 * USHORT::static_size; 574b961518b9611471ff7060e97686e5625974847ebBehdad Esfahbod return USHORT::static_size * (4 + ((endSize - startSize) >> (4 - f))); 575dc9c4d93cd0f3ac991f32df08c1c17fc389054c0Behdad Esfahbod } 576dc9c4d93cd0f3ac991f32df08c1c17fc389054c0Behdad Esfahbod 577d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod inline bool sanitize (hb_sanitize_context_t *c) { 5783e2401f6c53d2b047954d75c37aef5e5e7cdc51aBehdad Esfahbod TRACE_SANITIZE (); 579d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod return c->check_struct (this) 580d7cfb3b2d1dd2e9fdae2b3e540bbe313660895e8Behdad Esfahbod && c->check_range (this, this->get_size ()); 581dc9c4d93cd0f3ac991f32df08c1c17fc389054c0Behdad Esfahbod } 5826f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 5836f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod private: 5840795b784dd1009976c185482a376df250167e73bBehdad Esfahbod USHORT startSize; /* Smallest size to correct--in ppem */ 5850795b784dd1009976c185482a376df250167e73bBehdad Esfahbod USHORT endSize; /* Largest size to correct--in ppem */ 586caff7db93d205e32a535d49e51a3cad70f91dfddBehdad Esfahbod USHORT deltaFormat; /* Format of DeltaValue array data: 1, 2, or 3 587caff7db93d205e32a535d49e51a3cad70f91dfddBehdad Esfahbod * 1 Signed 2-bit value, 8 values per uint16 588caff7db93d205e32a535d49e51a3cad70f91dfddBehdad Esfahbod * 2 Signed 4-bit value, 4 values per uint16 589caff7db93d205e32a535d49e51a3cad70f91dfddBehdad Esfahbod * 3 Signed 8-bit value, 2 values per uint16 590caff7db93d205e32a535d49e51a3cad70f91dfddBehdad Esfahbod */ 591d3480ba37fbb5d4be75b094060f5b2f1ce98fb53Behdad Esfahbod USHORT deltaValue[VAR]; /* Array of compressed data */ 592569da92bc6956f42d9b2d65c784e184fb6380efeBehdad Esfahbod public: 5930eb9fc6e37935707dba2bf4b3705de2161a08cb7Behdad Esfahbod DEFINE_SIZE_ARRAY (6, deltaValue); 5946f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod}; 5956f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 5966f20f72e9c58ba23db2e31afa5d331acfea3d77eBehdad Esfahbod 597acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_BEGIN_DECLS 598acdba3f90b232fc12fcb200dca2584481b339118Behdad EsfahbodHB_END_DECLS 599acdba3f90b232fc12fcb200dca2584481b339118Behdad Esfahbod 6005f5b24f99f52bbc922e238b65c06061ba07c8548Behdad Esfahbod#endif /* HB_OT_LAYOUT_COMMON_PRIVATE_HH */ 601