1a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod/* 22409d5f8d7dd8b535ce5ea29e933f7db27d33793Behdad Esfahbod * Copyright © 2010 Google, Inc. 3a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * 4a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * This is part of HarfBuzz, a text shaping library. 5a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * 6a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * Permission is hereby granted, without written agreement and without 7a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this 8a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * software and its documentation for any purpose, provided that the 9a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * above copyright notice and the following two paragraphs appear in 10a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * all copies of this software. 11a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * 12a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 13a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 14a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 15a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 16a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * DAMAGE. 17a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * 18a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 19a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 20a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 21a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 22a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 23a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * 24a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod * Google Author(s): Behdad Esfahbod 25a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod */ 26a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 27a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod#ifndef HB_OT_SHAPE_PRIVATE_HH 28a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod#define HB_OT_SHAPE_PRIVATE_HH 29a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 30c57d454accff66e5f2c58006e8fb40bc020b6182Behdad Esfahbod#include "hb-private.hh" 31a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 32895fb5d364e7ae5d9d2e34b9f68b8651804369efBehdad Esfahbod#include "hb-ot-map-private.hh" 332265be0a620bc76ab65f12fedde67791beb51314Behdad Esfahbod#include "hb-ot-layout-private.hh" 3416c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod 35a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 36a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 3713403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbodstruct hb_ot_shape_plan_t 3813403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod{ 3916c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod hb_segment_properties_t props; 4016c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod const struct hb_ot_complex_shaper_t *shaper; 4113403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod hb_ot_map_t map; 42a8c6da90f4c6e8d27a3a1b758a55476776d9f750Behdad Esfahbod const void *data; 435497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod hb_mask_t rtlm_mask, frac_mask, numr_mask, dnom_mask; 445497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod hb_mask_t kern_mask; 455497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod unsigned int has_frac : 1; 465497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod unsigned int has_kern : 1; 47a82165248cddb720576464b8e59a986491d3f2e9Behdad Esfahbod unsigned int has_mark : 1; 488bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod 49f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod inline void collect_lookups (hb_tag_t table_tag, hb_set_t *lookups) const 50f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod { 51f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod unsigned int table_index; 52f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod switch (table_tag) { 53f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod case HB_OT_TAG_GSUB: table_index = 0; break; 54f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod case HB_OT_TAG_GPOS: table_index = 1; break; 55f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod default: return; 56f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod } 57f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod map.collect_lookups (table_index, lookups); 58f30641038ba96e83950729b1bd9d86d2e98e46c5Behdad Esfahbod } 598bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); } 608bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); } 618bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod 628bb5deba9630d35878eb6edb4643ecfabf99f15fBehdad Esfahbod void finish (void) { map.finish (); } 635393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod}; 645393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod 655393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbodstruct hb_ot_shape_planner_t 665393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod{ 675393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod /* In the order that they are filled in. */ 685393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod hb_face_t *face; 695393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod hb_segment_properties_t props; 7016c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod const struct hb_ot_complex_shaper_t *shaper; 715393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod hb_ot_map_builder_t map; 725393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod 735393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod hb_ot_shape_planner_t (const hb_shape_plan_t *master_plan) : 74f47b9219546edcfdeb3991ee27f6d9ba455c3e08Behdad Esfahbod face (master_plan->face_unsafe), 755393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod props (master_plan->props), 765393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod shaper (NULL), 776fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod map (face, &props) {} 785393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod ~hb_ot_shape_planner_t (void) { map.finish (); } 795393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod 805393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod inline void compile (hb_ot_shape_plan_t &plan) 815393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod { 8216c6a27b4bffc19026944c7bea9cf0a3a8ff1d8fBehdad Esfahbod plan.props = props; 835393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod plan.shaper = shaper; 846fddf2d7397411bba8a23ac535e8b851495d3105Behdad Esfahbod map.compile (plan.map); 855497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod 865497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.rtlm_mask = plan.map.get_1_mask (HB_TAG ('r','t','l','m')); 875497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c')); 885497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.numr_mask = plan.map.get_1_mask (HB_TAG ('n','u','m','r')); 895497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.dnom_mask = plan.map.get_1_mask (HB_TAG ('d','n','o','m')); 905497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod 915497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.kern_mask = plan.map.get_mask (HB_DIRECTION_IS_HORIZONTAL (plan.props.direction) ? 925497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod HB_TAG ('k','e','r','n') : HB_TAG ('v','k','r','n')); 935497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod 945497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.has_frac = plan.frac_mask || (plan.numr_mask && plan.dnom_mask); 955497a8a274a7066c0230c850baadef681785c8bbBehdad Esfahbod plan.has_kern = !!plan.kern_mask; 96a82165248cddb720576464b8e59a986491d3f2e9Behdad Esfahbod plan.has_mark = !!plan.map.get_1_mask (HB_TAG ('m','a','r','k')); 975393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod } 985393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod 995393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod private: 1005393e3a62ba09fd7bcf3767b36225c8f49badb9dBehdad Esfahbod NO_COPY (hb_ot_shape_planner_t); 10113403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod}; 10213403bc67a01e0d4908fb964093fd02ddd11c580Behdad Esfahbod 103a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod 104a806762a314e83154793d96ee665e6668d6b56deBehdad Esfahbod#endif /* HB_OT_SHAPE_PRIVATE_HH */ 105